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

[PWA] Make use of the Window Controls Overlay feature to display menus in the title bar area #140694

Open
captainbrosset opened this issue Jan 14, 2022 · 32 comments
Assignees
Labels
feature-request Request for new features or functionality titlebar VS Code main title bar issues web Issues related to running VSCode in the web
Milestone

Comments

@captainbrosset
Copy link

The Window Controls Overlay PWA feature is coming out of origin trial and is shipping with Chrome/Edge 98.

To learn more about it, here are a few resources:

In short, it allows PWAs installed on desktop OSes to regain control of the area normally reserved for the standard title bar. With it, the maximize/minimize/close/pwa buttons appear as overlays on top of the web content, and the rest of the title bar is gone.

It comes with a JS API and some CSS variables that help PWA make efficient use of the regained space.

Using this, the VS Code PWA could display its title bar at the top of the window, just like in its native version.
The hamburger menu version of it could still be used when the title bar area is too narrow (which is easy to detect with the ongeometrychange event).

@captainbrosset
Copy link
Author

Pinging @digitarald who, I think, is looking at the PWA features right now.

@bpasero
Copy link
Member

bpasero commented Jan 14, 2022

Fyi @sbatten

@digitarald
Copy link
Contributor

Very much aligned with @sbatten's work of adding UI to the titlebar; and eventually optimizing that work for PWA.

@Offroaders123
Copy link

Any new information about this? WCO support would be amazing!

@bpasero bpasero added titlebar VS Code main title bar issues web Issues related to running VSCode in the web labels May 31, 2022
@bpasero
Copy link
Member

bpasero commented May 31, 2022

Related: #127449

@yume-chan
Copy link
Contributor

yume-chan commented Jun 2, 2022

image

I did a quick test. With only a little code change it already looks and works great. It really gives the feeling of native applications, if ignoring the two extra buttons at top-right added by the browser.

One remaining issue is that the title bar height is hardcoded now, it needs to be retrieved at runtime but I don't know how.

EDIT: also need to add support for old browsers without WCO.

@bpasero
Copy link
Member

bpasero commented Jun 2, 2022

Wow nice 👏

@captainbrosset
Copy link
Author

One remaining issue is that the title bar height is hardcoded now, it needs to be retrieved at runtime but I don't know how.

You can use the new CSS environment variables for this. In particular env(titlebar-area-height). I wrote some docs about this here: https://developer.mozilla.org/en-US/docs/Web/API/Window_Controls_Overlay_API#css_environment_variables

In fact, if you use these variables, you'll be able to position your menubar and other elements correctly across operating systems (including on Mac where the close/min/max buttons are on the left side).

It really gives the feeling of native applications, if ignoring the two extra buttons at top-right added by the browser.

Yeah, these buttons are annoying when you want to achieve a "native" look. There's work going on right now about this. @diekus will surely be interested in this feedback as I know he's thinking about ways to get rid of the "chevron" icon.

@yume-chan
Copy link
Contributor

yume-chan commented Jun 2, 2022

I know how to use WCO in general. The issue is integrating it with vscode.

Code has its own layout system in JavaScript, so the title bar height must be known in code. I can get it from navigator.windowControlsOverlay on initialize, but changing it (listen to the geometrychange event) really complicates the whole thing: I can't find a good way to notify the layout system to recalculate all the sizes.

On contrast, Code already has support for self-rendered window controls and Electron's WCO integration. In both modes the window controls region size won't change (except by using built-in commands like zoom in/zoom out), so it's one less thing to consider.

My current changes are here: https://github.com/microsoft/vscode/compare/main...yume-chan:pwa-wco?expand=1, the solution I'm thinking is adding all the windowControlsOverlay handling to layout directly, so at least not scattered in multiple parts.

@sbatten
Copy link
Member

sbatten commented Jun 2, 2022

WCO also needs to be enabled in the browser. At least in edge, they are disabled by default.

@diekus
Copy link
Member

diekus commented Jun 6, 2022

It's coming very soon. Hope to have some news to share in some days! Once we have a timeframe, I am more than happy to help in any way to bring WCO to the the code PWA.

@bpasero
Copy link
Member

bpasero commented Aug 9, 2022

@yume-chan curious, what was the change you did in #140694 (comment) to make it work?

@bpasero bpasero added this to the On Deck milestone Aug 9, 2022
@yume-chan
Copy link
Contributor

yume-chan commented Aug 9, 2022

My branch is at https://github.com/yume-chan/vscode/tree/pwa-wco (it's now conflicting with main).

@joaomoreno
Copy link
Member

This is now enabled on https://insiders.vscode.dev. In Edge, make sure you enable the Desktop PWA Window Controls Overlay flag by visiting edge://flags/#enable-desktop-pwas-window-controls-overlay.

image

@sbatten Should this look a little bit better?

image

@diekus
Copy link
Member

diekus commented Nov 7, 2022

That's incredible news! Window Controls Overlay is now on by default in Chromium 105, so no flag needed! Congratulations @joaomoreno and team!

@sbatten
Copy link
Member

sbatten commented Nov 7, 2022

@joaomoreno, yep, I thought I resolved this but I will force the title bar on and move the compact menu when in PWA mode as mentioned here

@joaomoreno
Copy link
Member

Looking good:

image

@captainbrosset
Copy link
Author

This is great to see! Amazing progress.

Just one detail:
I unfortunately forgot to grab a screenshot before dismissing it, but there's a notification banner that appears at the top of the window when you first install the app (it contains link to download VSCode, read the terms, etc.). This banner can't be closed after opting-in to WCO. Its close button is likely hidden behind the control buttons overlay.
You might want to position it using the env(titlebar-area-*) variables.

@eifr
Copy link

eifr commented Nov 10, 2022

Beautiful! small issue in mac (native title bar is like 3 pixels taller) but x100 better
image

@sbatten
Copy link
Member

sbatten commented Nov 10, 2022

@captainbrosset i have a fix going in today that should move the banner below the titlebar (like it is in desktop) when the WCO are shown.

@sbatten sbatten modified the milestones: November 2022, December 2022 Nov 23, 2022
@sbatten
Copy link
Member

sbatten commented Nov 23, 2022

While this is generally done, macos web still has issues, so moving to December to resolve

@fogoplayer
Copy link

Loving the work on this feature. I'm running into some issues on the latest Insider Preview

Running on Chrome/ChromeOS 107.0.5304.110
Screen recording 2022-12-01 12.21.24.webm

@sbatten sbatten added the feature-request Request for new features or functionality label Dec 10, 2022
@sbatten sbatten modified the milestones: January 2023, February 2023 Jan 23, 2023
@sbatten sbatten modified the milestones: February 2023, March 2023 Feb 17, 2023
@sbatten sbatten modified the milestones: March 2023, April 2023, Backlog Mar 20, 2023
@leifwalsh
Copy link

What happened to this issue? It looked close to shipping but never did?

@fogoplayer
Copy link

It's live for me! On Chrome, look for an "up" Chevron near the window controls

@leifwalsh
Copy link

I don't see anything:
image

This is on Windows 10 with Chrome 122.0.6261.95. Is it possible I've got something configured incorrectly?

@leifwalsh
Copy link

Oh, I do see it in Edge on Windows 11. Must be a local configuration difference!

@leifwalsh
Copy link

Ok, I see the difference. I'm using code serve-web and the server it's downloading doesn't have the right manifest.json.

Mine (%USERPROFILE%\.vscode-insiders\cli\serve-web\57028e3d274ebde851c7cc02123def372ca619a6\resources\server\manifest.json):

{
	"name": "Visual Studio Code - Insiders",
	"short_name": "Code - Insiders",
	"start_url": "/",
	"lang": "en-US",
	"display": "standalone",
	"icons": [
		{
			"src": "code-192.png",
			"type": "image/png",
			"sizes": "192x192"
		},
		{
			"src": "code-512.png",
			"type": "image/png",
			"sizes": "512x512"
		}
	]
}

What I'd expect:

"display_override": [
"window-controls-overlay"
],

Do we know why the build it downloads has the older manifest.json?

@inLnx
Copy link

inLnx commented Apr 5, 2024

you have to zoom in to make it look even

@bpasero
Copy link
Member

bpasero commented Apr 8, 2024

@leifwalsh this is a very good catch, looks like we are missing to set "display_override": ["window-controls-overlay"] in that case. A fix will be pushed today and should be available in insiders tomorrow.

@leifwalsh
Copy link

Awesome, thank you! Looking forward to the extra couple lines of editor space! :)

@bpasero
Copy link
Member

bpasero commented Apr 9, 2024

@leifwalsh with todays insider, this landed. Can you maybe verify?

@leifwalsh
Copy link

yep, we see it, thank you!

@sbatten sbatten assigned benibenj and unassigned sbatten Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality titlebar VS Code main title bar issues web Issues related to running VSCode in the web
Projects
None yet
Development

No branches or pull requests

15 participants