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

Test: Proposed Native Handle API #234778

Closed
3 tasks done
TylerLeonhardt opened this issue Nov 27, 2024 · 5 comments
Closed
3 tasks done

Test: Proposed Native Handle API #234778

TylerLeonhardt opened this issue Nov 27, 2024 · 5 comments

Comments

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Nov 27, 2024

Ref: #233106

Complexity: 3

Create Issue


This iteration we added a new proposed API that allows you to retrieve the native window handle of the focused window. The native window handle is an OS concept that essentially provides a pointer to a particular window. This is useful if you are interacting with native code and need to, say, render a native dialog on top of a window.

declare module 'vscode' {

	export namespace window {
		/**
		 * Retrieves the native window handle of the current active window.
		 * This will be updated when the active window changes.
		 */
		export const nativeHandle: Uint8Array | undefined;
	}
}

This was added specifically for Microsoft Auth so that we could pass the native handle down to the OS so it could render an auth dialog overtop VS Code. It likely won't be finalized in the near future until we get considerable interest for its use... but it should be tested nonetheless.

Prereqs

  • Have an extension (don't have one? create one!)
  • Add the proposed API in the package.json:
    "enabledApiProposals": ["nativeWindowHandle"],
  • Run npx @vscode/dts dev to get the proposed API file

Using the window.nativeHandle

I won't ask you to do anything with this native handle so you don't have to write native code, I just want you to:

  • See if the API makes sense
  • See if it's value is defined when running in a desktop environment
  • See if it updates as you switch between windows and auxiliary windows (an auxiliary window can be created by right clicking on a file and choosing "Move into new window")
@sandy081
Copy link
Member

sandy081 commented Dec 3, 2024

See if it updates as you switch between windows and auxiliary windows (an auxiliary window can be created by right clicking on a file and choosing "Move into new window")

I am not sure if there is a scenario or necessary - Is there a necessary to have a change event when the nativeHandle change?

@sandy081 sandy081 removed their assignment Dec 3, 2024
@TylerLeonhardt
Copy link
Member Author

@sandy081 at the moment, there's no scenario. We've opted for less API in this case. If something comes up, we can always add.

@isidorn
Copy link
Contributor

isidorn commented Dec 3, 2024

Works great. Just curious what is the primary use case for this new API?

@isidorn isidorn removed their assignment Dec 3, 2024
@osortega osortega removed their assignment Dec 3, 2024
@osortega osortega closed this as completed Dec 4, 2024
@TylerLeonhardt
Copy link
Member Author

@isidorn This was added specifically for Microsoft Auth so that we could pass the native handle down to the OS so it could render an auth dialog overtop VS Code.

See this doc: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/docs/brokering.md#window-parenting

It's an optional property, but without it, the auth dialog was always behind VS Code.

@isidorn
Copy link
Contributor

isidorn commented Dec 4, 2024

Makes sense. Thanks!

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants