Files
vscode/src/vs/workbench/api/node/extHostWindow.ts
Matt Bierner 81767beaca Make Event a named export
There are many places in the code that do `import Event, { ...} from '.../event'`.
2018-03-14 14:25:30 -07:00

39 lines
1.4 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* 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 { ExtHostWindowShape, MainContext, MainThreadWindowShape, IMainContext } from './extHost.protocol';
import { WindowState } from 'vscode';
export class ExtHostWindow implements ExtHostWindowShape {
private static InitialState: WindowState = {
focused: true
};
private _proxy: MainThreadWindowShape;
private _onDidChangeWindowState = new Emitter<WindowState>();
readonly onDidChangeWindowState: Event<WindowState> = this._onDidChangeWindowState.event;
private _state = ExtHostWindow.InitialState;
get state(): WindowState { return this._state; }
constructor(mainContext: IMainContext) {
this._proxy = mainContext.getProxy(MainContext.MainThreadWindow);
this._proxy.$getWindowVisibility().then(isFocused => this.$onDidChangeWindowFocus(isFocused));
}
$onDidChangeWindowFocus(focused: boolean): void {
if (focused === this._state.focused) {
return;
}
this._state = { ...this._state, focused };
this._onDidChangeWindowState.fire(this._state);
}
}