debt - implement window events and focus tracking

This commit is contained in:
Benjamin Pasero
2019-09-26 08:13:38 +02:00
parent 4a596b4431
commit f0b99530c8
36 changed files with 234 additions and 248 deletions

View File

@@ -14,6 +14,7 @@ bootstrap.avoidMonkeyPatchFromAppInsights();
bootstrapWindow.load(['vs/code/electron-browser/sharedProcess/sharedProcessMain'], function (sharedProcess, configuration) {
sharedProcess.startup({
machineId: configuration.machineId
machineId: configuration.machineId,
windowId: configuration.windowId
});
});
});

View File

@@ -27,8 +27,6 @@ import { TelemetryAppenderChannel } from 'vs/platform/telemetry/node/telemetryIp
import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService';
import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender';
import { ActiveWindowManager } from 'vs/platform/windows/node/windows';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { WindowsService } from 'vs/platform/windows/electron-browser/windowsService';
import { ipcRenderer } from 'electron';
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
import { LoggerChannelClient, FollowerLogService } from 'vs/platform/log/common/logIpc';
@@ -57,9 +55,12 @@ import { UserDataSyncService, UserDataAutoSync } from 'vs/platform/userDataSync/
import { UserDataSyncStoreService } from 'vs/platform/userDataSync/common/userDataSyncStoreService';
import { UserDataSyncChannel } from 'vs/platform/userDataSync/common/userDataSyncIpc';
import { SettingsMergeChannelClient } from 'vs/platform/userDataSync/common/settingsSyncIpc';
import { createChannelSender } from 'vs/platform/ipc/node/ipcChannelCreator';
import { IElectronService } from 'vs/platform/electron/node/electron';
export interface ISharedProcessConfiguration {
readonly machineId: string;
readonly windowId: number;
}
export function startup(configuration: ISharedProcessConfiguration) {
@@ -120,9 +121,6 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
const mainProcessService = new MainProcessService(server, mainRouter);
services.set(IMainProcessService, mainProcessService);
const windowsService = new WindowsService(mainProcessService);
services.set(IWindowsService, windowsService);
// Files
const fileService = new FileService(logService);
services.set(IFileService, fileService);
@@ -170,8 +168,11 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
services.set(ILocalizationsService, new SyncDescriptor(LocalizationsService));
services.set(IDiagnosticsService, new SyncDescriptor(DiagnosticsService));
const electronService = createChannelSender<IElectronService>(mainProcessService.getChannel('electron'), { context: configuration.windowId });
services.set(IElectronService, electronService);
// User Data Sync Contributions
const activeWindowManager = new ActiveWindowManager(windowsService);
const activeWindowManager = new ActiveWindowManager(electronService);
const activeWindowRouter = new StaticRouter(ctx => activeWindowManager.getActiveClientId().then(id => ctx === id));
const settingsMergeChannel = server.getChannel('settingsMerge', activeWindowRouter);
services.set(ISettingsMergeService, new SettingsMergeChannelClient(settingsMergeChannel));

View File

@@ -547,6 +547,7 @@ export class CodeApplication extends Disposable {
const electronService = accessor.get(IElectronService);
const electronChannel = createChannelReceiver(electronService);
electronIpcServer.registerChannel('electron', electronChannel);
sharedProcessClient.then(client => client.registerChannel('electron', electronChannel));
const sharedProcessMainService = accessor.get(ISharedProcessMainService);
const sharedProcessChannel = createChannelReceiver(sharedProcessMainService);
@@ -559,7 +560,6 @@ export class CodeApplication extends Disposable {
const windowsService = accessor.get(IWindowsService);
const windowsChannel = new WindowsChannel(windowsService);
electronIpcServer.registerChannel('windows', windowsChannel);
sharedProcessClient.then(client => client.registerChannel('windows', windowsChannel));
const menubarService = accessor.get(IMenubarService);
const menubarChannel = createChannelReceiver(menubarService);
@@ -587,7 +587,7 @@ export class CodeApplication extends Disposable {
const windowsMainService = this.windowsMainService = accessor.get(IWindowsMainService);
// Create a URL handler which forwards to the last active window
const activeWindowManager = new ActiveWindowManager(windowsService);
const activeWindowManager = new ActiveWindowManager(electronService);
const activeWindowRouter = new StaticRouter(ctx => activeWindowManager.getActiveClientId().then(id => ctx === id));
const urlHandlerRouter = new URLHandlerRouter(activeWindowRouter);
const urlHandlerChannel = electronIpcServer.getChannel('urlHandler', urlHandlerRouter);

View File

@@ -45,7 +45,8 @@ export class SharedProcess implements ISharedProcess {
appRoot: this.environmentService.appRoot,
machineId: this.machineId,
nodeCachedDataDir: this.environmentService.nodeCachedDataDir,
userEnv: this.userEnv
userEnv: this.userEnv,
windowId: this.window.id
});
const url = `${require.toUrl('vs/code/electron-browser/sharedProcess/sharedProcess.html')}?config=${encodeURIComponent(JSON.stringify(config))}`;