Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a handle property that is a string #233267

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extensions/vscode-api-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"interactive",
"languageStatusText",
"mappedEditsProvider",
"nativeWindowHandle",
"notebookCellExecutionState",
"notebookDeprecated",
"notebookLiveShare",
Expand Down
3 changes: 3 additions & 0 deletions src/vs/platform/extensions/common/extensionsApiProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ const _allApiProposals = {
multiDocumentHighlightProvider: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.multiDocumentHighlightProvider.d.ts',
},
nativeWindowHandle: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.nativeWindowHandle.d.ts',
},
newSymbolNamesProvider: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.newSymbolNamesProvider.d.ts',
},
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/window/common/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ export interface IOSConfiguration {

export interface INativeWindowConfiguration extends IWindowConfiguration, NativeParsedArgs, ISandboxConfiguration {
mainPid: number;
handle?: string;

machineId: string;
sqmId: string;
Expand Down
5 changes: 5 additions & 0 deletions src/vs/platform/windows/electron-main/windowImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,11 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
}

// Update window related properties
try {
configuration.handle = this._win.getNativeWindowHandle().toString('base64');
} catch (error) {
this.logService.error(`Error getting native window handle: ${error}`);
}
configuration.fullscreen = this.isFullScreen;
configuration.maximized = this._win.isMaximized();
configuration.partsSplash = this.themeMainService.getWindowSplash();
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
checkProposedApiEnabled(extension, 'resolvers');
return initData.commit;
},
get handle(): string | undefined {
checkProposedApiEnabled(extension, 'nativeWindowHandle');
return initData.handle;
}
};
if (!initData.environment.extensionTestsLocationURI) {
// allow to patch env-function when running tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface INativeWorkbenchEnvironmentService extends IBrowserWorkbenchEnv
// --- Window
readonly window: {
id: number;
handle?: string;
colorScheme: IColorScheme;
maximized?: boolean;
accessibilitySupport?: boolean;
Expand Down Expand Up @@ -83,6 +84,7 @@ export class NativeWorkbenchEnvironmentService extends AbstractNativeEnvironment
get window() {
return {
id: this.configuration.windowId,
handle: this.configuration.handle,
colorScheme: this.configuration.colorScheme,
maximized: this.configuration.maximized,
accessibilitySupport: this.configuration.accessibilitySupport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface IExtensionHostInitData {
consoleForward: { includeStack: boolean; logNative: boolean };
uiKind: UIKind;
messagePorts?: ReadonlyMap<string, MessagePortLike>;
handle?: string;
}

export interface IEnvironment {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost {
loggers: [...this._loggerService.getRegisteredLoggers()],
logsLocation: this._environmentService.extHostLogsPath,
autoStart: (this.startup === ExtensionHostStartup.EagerAutoStart),
uiKind: UIKind.Desktop
uiKind: UIKind.Desktop,
handle: this._environmentService.window.handle
};
}

Expand Down
17 changes: 17 additions & 0 deletions src/vscode-dts/vscode.proposed.nativeWindowHandle.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

// https://github.com/microsoft/vscode/issues/229431

declare module 'vscode' {

export namespace env {
/**
* Retrieves a base64 representation of a native window
* handle of the current window.
*/
export const handle: string | undefined;
}
}
Loading