api: finalize windowActivity (#210491)

Closes #181569
This commit is contained in:
Connor Peet 2024-04-16 11:03:14 -07:00 committed by GitHub
parent 21c66842b7
commit 97df4dad38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 13 additions and 29 deletions

View file

@ -52,8 +52,7 @@
"treeViewActiveItem",
"treeViewReveal",
"workspaceTrust",
"telemetry",
"windowActivity"
"telemetry"
],
"private": true,
"activationEvents": [],

View file

@ -749,7 +749,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return _asExtensionEvent(extHostTerminalShellIntegration.onDidEndTerminalShellExecution)(listener, thisArg, disposables);
},
get state() {
return extHostWindow.getState(extension);
return extHostWindow.getState();
},
onDidChangeWindowState(listener, thisArg?, disposables?) {
return _asExtensionEvent(extHostWindow.onDidChangeWindowState)(listener, thisArg, disposables);

View file

@ -3,16 +3,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event, Emitter } from 'vs/base/common/event';
import { ExtHostWindowShape, MainContext, MainThreadWindowShape, IOpenUriOptions } from './extHost.protocol';
import { WindowState } from 'vscode';
import { URI } from 'vs/base/common/uri';
import { Emitter, Event } from 'vs/base/common/event';
import { Schemas } from 'vs/base/common/network';
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { IRelaxedExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
import { WindowState } from 'vscode';
import { ExtHostWindowShape, IOpenUriOptions, MainContext, MainThreadWindowShape } from './extHost.protocol';
export class ExtHostWindow implements ExtHostWindowShape {
@ -28,7 +26,7 @@ export class ExtHostWindow implements ExtHostWindowShape {
private _state = ExtHostWindow.InitialState;
getState(extension: Readonly<IRelaxedExtensionDescription>): WindowState {
getState(): WindowState {
// todo@connor4312: this can be changed to just return this._state after proposed api is finalized
const state = this._state;
@ -37,7 +35,6 @@ export class ExtHostWindow implements ExtHostWindowShape {
return state.focused;
},
get active() {
checkProposedApiEnabled(extension, 'windowActivity');
return state.active;
},
};

View file

@ -122,7 +122,6 @@ export const allApiProposals = Object.freeze({
treeViewReveal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.treeViewReveal.d.ts',
tunnelFactory: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.tunnelFactory.d.ts',
tunnels: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.tunnels.d.ts',
windowActivity: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.windowActivity.d.ts',
workspaceTrust: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.workspaceTrust.d.ts'
});
export type ApiProposalName = keyof typeof allApiProposals;

View file

@ -10299,6 +10299,12 @@ declare module 'vscode' {
* Whether the current window is focused.
*/
readonly focused: boolean;
/**
* Whether the window has been interacted with recently. This will change
* immediately on activity, or after a short time of user inactivity.
*/
readonly active: boolean;
}
/**

View file

@ -1,17 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
// https://github.com/microsoft/vscode/issues/181569 @connor4312
export interface WindowState {
/**
* Indicates whether the window has been interacted with recently. This will
* change immediately on activity, or after a short time of user inactivity.
*/
readonly active: boolean;
}
}