mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
@@ -36,6 +36,7 @@ import { ExtHostApiCommands } from 'vs/workbench/api/node/extHostApiCommands';
|
||||
import { ExtHostTask } from 'vs/workbench/api/node/extHostTask';
|
||||
import { ExtHostDebugService } from 'vs/workbench/api/node/extHostDebugService';
|
||||
import { ExtHostCredentials } from 'vs/workbench/api/node/extHostCredentials';
|
||||
import { ExtHostWindow } from 'vs/workbench/api/node/extHostWindow';
|
||||
import * as extHostTypes from 'vs/workbench/api/node/extHostTypes';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
@@ -96,6 +97,7 @@ export function createApiFactory(
|
||||
const extHostSCM = col.define(ExtHostContext.ExtHostSCM).set<ExtHostSCM>(new ExtHostSCM(threadService, extHostCommands));
|
||||
const extHostTask = col.define(ExtHostContext.ExtHostTask).set<ExtHostTask>(new ExtHostTask(threadService));
|
||||
const extHostCredentials = col.define(ExtHostContext.ExtHostCredentials).set<ExtHostCredentials>(new ExtHostCredentials(threadService));
|
||||
const extHostWindow = col.define(ExtHostContext.ExtHostWindow).set<ExtHostWindow>(new ExtHostWindow(threadService));
|
||||
col.define(ExtHostContext.ExtHostExtensionService).set(extensionService);
|
||||
col.finish(false, threadService);
|
||||
|
||||
@@ -308,6 +310,12 @@ export function createApiFactory(
|
||||
onDidCloseTerminal(listener, thisArg?, disposables?) {
|
||||
return extHostTerminalService.onDidCloseTerminal(listener, thisArg, disposables);
|
||||
},
|
||||
get isFocused() {
|
||||
return extHostWindow.isFocused;
|
||||
},
|
||||
onDidChangeWindowFocus: proposedApiFunction(extension, (listener, thisArg?, disposables?) => {
|
||||
return extHostWindow.onDidChangeWindowFocus(listener, thisArg, disposables);
|
||||
}),
|
||||
showInformationMessage(message, first, ...rest) {
|
||||
return extHostMessageService.showMessage(Severity.Info, message, first, rest);
|
||||
},
|
||||
|
||||
@@ -356,6 +356,10 @@ export abstract class MainThreadCredentialsShape {
|
||||
$deleteSecret(service: string, account: string): Thenable<boolean> { throw ni(); }
|
||||
}
|
||||
|
||||
export abstract class MainThreadWindowShape {
|
||||
$getWindowVisibility(): TPromise<boolean> { throw ni(); }
|
||||
}
|
||||
|
||||
// -- extension host
|
||||
|
||||
export abstract class ExtHostCommandsShape {
|
||||
@@ -515,6 +519,10 @@ export abstract class ExtHostDebugServiceShape {
|
||||
export abstract class ExtHostCredentialsShape {
|
||||
}
|
||||
|
||||
export abstract class ExtHostWindowShape {
|
||||
$onDidChangeWindowFocus(value: boolean): void { throw ni(); }
|
||||
}
|
||||
|
||||
// --- proxy identifiers
|
||||
|
||||
export const MainContext = {
|
||||
@@ -541,6 +549,7 @@ export const MainContext = {
|
||||
MainThreadSCM: createMainId<MainThreadSCMShape>('MainThreadSCM', MainThreadSCMShape),
|
||||
MainThreadTask: createMainId<MainThreadTaskShape>('MainThreadTask', MainThreadTaskShape),
|
||||
MainThreadCredentials: createMainId<MainThreadCredentialsShape>('MainThreadCredentials', MainThreadCredentialsShape),
|
||||
MainThreadWindow: createMainId<MainThreadWindowShape>('MainThreadWindow', MainThreadWindowShape),
|
||||
};
|
||||
|
||||
export const ExtHostContext = {
|
||||
@@ -563,4 +572,5 @@ export const ExtHostContext = {
|
||||
ExtHostTask: createExtId<ExtHostTaskShape>('ExtHostTask', ExtHostTaskShape),
|
||||
ExtHostWorkspace: createExtId<ExtHostWorkspaceShape>('ExtHostWorkspace', ExtHostWorkspaceShape),
|
||||
ExtHostCredentials: createExtId<ExtHostCredentialsShape>('ExtHostCredentials', ExtHostCredentialsShape),
|
||||
ExtHostWindow: createExtId<ExtHostWindowShape>('ExtHostWindow', ExtHostWindowShape),
|
||||
};
|
||||
|
||||
34
src/vs/workbench/api/node/extHostWindow.ts
Normal file
34
src/vs/workbench/api/node/extHostWindow.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import { ExtHostWindowShape, MainContext, MainThreadWindowShape } from './extHost.protocol';
|
||||
|
||||
export class ExtHostWindow implements ExtHostWindowShape {
|
||||
|
||||
private _proxy: MainThreadWindowShape;
|
||||
|
||||
private _onDidChangeWindowFocus = new Emitter<boolean>();
|
||||
get onDidChangeWindowFocus(): Event<boolean> { return this._onDidChangeWindowFocus.event; }
|
||||
|
||||
private _isFocused = false;
|
||||
get isFocused(): boolean { return this._isFocused; }
|
||||
|
||||
constructor(threadService: IThreadService) {
|
||||
this._proxy = threadService.get(MainContext.MainThreadWindow);
|
||||
this._proxy.$getWindowVisibility().then(isFocused => this.$onDidChangeWindowFocus(isFocused));
|
||||
}
|
||||
|
||||
$onDidChangeWindowFocus(isFocused: boolean): void {
|
||||
if (isFocused === this._isFocused) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._isFocused = isFocused;
|
||||
this._onDidChangeWindowFocus.fire(isFocused);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user