提交 774b83b0 编写于 作者: B Benjamin Pasero 提交者: GitHub

Merge pull request #13255 from the-ress/send-foreground-love

Call AllowSetForegroundWindow before sending IPC
......@@ -268,6 +268,7 @@ function packageTask(platform, arch, opts) {
.pipe(util.cleanNodeModule('oniguruma', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], ['**/*.node']))
.pipe(util.cleanNodeModule('windows-mutex', ['binding.gyp', 'build/**', 'src/**'], ['**/*.node']))
.pipe(util.cleanNodeModule('native-keymap', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], ['**/*.node']))
.pipe(util.cleanNodeModule('windows-foreground-love', ['binding.gyp', 'build/**', 'src/**'], ['**/*.node']))
.pipe(util.cleanNodeModule('gc-signals', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], ['**/*.node', 'src/index.js']))
.pipe(util.cleanNodeModule('pty.js', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], ['build/Release/**']));
......
......@@ -414,6 +414,11 @@
"from": "vscode-textmate@2.2.0",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-2.2.0.tgz"
},
"windows-foreground-love": {
"version": "0.1.0",
"from": "windows-foreground-love@0.1.0",
"resolved": "https://registry.npmjs.org/windows-foreground-love/-/windows-foreground-love-0.1.0.tgz"
},
"windows-mutex": {
"version": "0.2.0",
"from": "windows-mutex@>=0.2.0 <0.3.0",
......
......@@ -108,6 +108,7 @@
}
},
"optionalDependencies": {
"windows-foreground-love": "0.1.0",
"windows-mutex": "^0.2.0",
"fsevents": "0.3.8"
}
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'windows-foreground-love' {
export function allowSetForegroundWindow(pid?: number): boolean;
}
\ No newline at end of file
......@@ -21,10 +21,12 @@ export interface IStartArguments {
export interface ILaunchService {
start(args: ParsedArgs, userEnv: IProcessEnvironment): TPromise<void>;
getMainProcessId(): TPromise<number>;
}
export interface ILaunchChannel extends IChannel {
call(command: 'start', arg: IStartArguments): TPromise<void>;
call(command: 'get-main-process-id', arg: null): TPromise<any>;
call(command: string, arg: any): TPromise<any>;
}
......@@ -33,10 +35,13 @@ export class LaunchChannel implements ILaunchChannel {
constructor(private service: ILaunchService) { }
call(command: string, arg: any): TPromise<any> {
const { args, userEnv } = arg as IStartArguments;
switch (command) {
case 'start': return this.service.start(args, userEnv);
case 'start':
const { args, userEnv } = arg as IStartArguments;
return this.service.start(args, userEnv);
case 'get-main-process-id':
return this.service.getMainProcessId();
}
}
}
......@@ -48,6 +53,10 @@ export class LaunchChannelClient implements ILaunchService {
start(args: ParsedArgs, userEnv: IProcessEnvironment): TPromise<void> {
return this.channel.call('start', { args, userEnv });
}
getMainProcessId(): TPromise<number> {
return this.channel.call('get-main-process-id', null);
}
}
export class LaunchService implements ILaunchService {
......@@ -105,4 +114,9 @@ export class LaunchService implements ILaunchService {
return TPromise.as(null);
}
getMainProcessId(): TPromise<number> {
this.logService.log('Received request for process ID from other instance.');
return TPromise.as(process.pid);
}
}
\ No newline at end of file
......@@ -299,7 +299,22 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
const channel = client.getChannel<ILaunchChannel>('launch');
const service = new LaunchChannelClient(channel);
return service.start(environmentService.args, process.env)
let promise = TPromise.as(null);
if (platform.isWindows) {
promise = service.getMainProcessId()
.then(processId => {
logService.log('Sending some foreground love to the running instance:', processId);
try {
const { allowSetForegroundWindow } = <any>require.__$__nodeRequire('windows-foreground-love');
allowSetForegroundWindow(processId);
} catch (e) {
// noop
}
});
}
return promise
.then(() => service.start(environmentService.args, process.env))
.then(() => client.dispose())
.then(() => TPromise.wrapError('Sent env to running instance. Terminating...'));
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册