mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
api: WindowState
This commit is contained in:
@@ -310,11 +310,11 @@ export function createApiFactory(
|
||||
onDidCloseTerminal(listener, thisArg?, disposables?) {
|
||||
return extHostTerminalService.onDidCloseTerminal(listener, thisArg, disposables);
|
||||
},
|
||||
get isFocused() {
|
||||
return extHostWindow.isFocused;
|
||||
get state() {
|
||||
return extHostWindow.state;
|
||||
},
|
||||
onDidChangeWindowFocus: proposedApiFunction(extension, (listener, thisArg?, disposables?) => {
|
||||
return extHostWindow.onDidChangeWindowFocus(listener, thisArg, disposables);
|
||||
onDidChangeWindowState: proposedApiFunction(extension, (listener, thisArg?, disposables?) => {
|
||||
return extHostWindow.onDidChangeWindowState(listener, thisArg, disposables);
|
||||
}),
|
||||
showInformationMessage(message, first, ...rest) {
|
||||
return extHostMessageService.showMessage(Severity.Info, message, first, rest);
|
||||
|
||||
@@ -7,28 +7,33 @@
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
import { ExtHostWindowShape, MainContext, MainThreadWindowShape } from './extHost.protocol';
|
||||
import { WindowState } from 'vscode';
|
||||
|
||||
export class ExtHostWindow implements ExtHostWindowShape {
|
||||
|
||||
private static InitialState: WindowState = {
|
||||
focused: true
|
||||
};
|
||||
|
||||
private _proxy: MainThreadWindowShape;
|
||||
|
||||
private _onDidChangeWindowFocus = new Emitter<boolean>();
|
||||
readonly onDidChangeWindowFocus: Event<boolean> = this._onDidChangeWindowFocus.event;
|
||||
private _onDidChangeWindowState = new Emitter<WindowState>();
|
||||
readonly onDidChangeWindowState: Event<WindowState> = this._onDidChangeWindowState.event;
|
||||
|
||||
private _isFocused = true;
|
||||
get isFocused(): boolean { return this._isFocused; }
|
||||
private _state = ExtHostWindow.InitialState;
|
||||
get state(): WindowState { return this._state; }
|
||||
|
||||
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) {
|
||||
$onDidChangeWindowFocus(focused: boolean): void {
|
||||
if (focused === this._state.focused) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._isFocused = isFocused;
|
||||
this._onDidChangeWindowFocus.fire(isFocused);
|
||||
this._state = { ...this._state, focused };
|
||||
this._onDidChangeWindowState.fire(this._state);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user