microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.36k stars 28.6k forks source link

Allow VS-code to respect native titlebar decorations configuration on GNOME/Linux #176467

Open adhadse opened 1 year ago

adhadse commented 1 year ago

Coming from #21 on vscode-adwaita, on GNOME Desktop environment (and on other distros as well) we can configure what titlebar decorations appear, viz Minimize, maximize buttons can appear or disappear via GNOME tweaks app.

VS-code doesn't support this by default, and for maximum cross-compatibility, we would like this feature to be customizable.

TLDR:

Attaching image of window decorations on VS code with window.titleBarStyle set to custom, GNOME files (Nautilus) on libadwaita 1.2x, GNOME 43.2 and Microsoft Edge browser (Version 109.0.1518.70 (Official build) (64-bit)) with GNOME tweaks, disabling maximise and minimize buttons image

And with GNOME tweaks enabling Maximise/Minimize buttons: image

sbatten commented 1 year ago

This would come from WCO on linux, right @deepak1556

adhadse commented 1 year ago

@sbatten Can I please know what is WCO on linux?

sbatten commented 1 year ago

Window Controls Overlay, a feature of browsers and electron (our platform) which draws native window controls in a reserved area over our application. It allows you to get the same native features of window controls that we cannot implement in HTML/JS

fedorenchik commented 1 year ago

@adhadse @sbatten can we also add feature to respect window titlebar buttons position (left / right side) ?

TomiOhl commented 1 year ago

Let me +1 these. Also, take into account that sometimes not all controls are at the same side, e.g. on elementary OS/Pantheon the close button is on the left, the maximize button is on the right.

suwermave commented 1 year ago

This is needed, please implement.

sousaakira commented 1 year ago

How do I move the title bar buttons to the left side?

VSCodeTriageBot commented 9 months ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

ropodl commented 9 months ago

+1

VSCodeTriageBot commented 9 months ago

:slightly_smiling_face: This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

mbeps commented 9 months ago

+1

rodrigoGA commented 7 months ago

I understand that respecting the configuration also refers to the window corners' rounding being set by the GNOME theme, and the windows title bar color being set by the VS Code theme.

The same behavior that VS Code already offers to Windows and OSX is expected to be offered to Linux as well.

do-sch commented 6 months ago

To get the configured button layout the GSettings key button-layout in org.gnome.desktop.wm.preferences has to be parsed. It is a Gnome setting, but other desktop environments like KDE or Cinnamon change this key too, so that GTK applications look as native as possible. Therefore, this solution would work everywhere.

It contains a string with the components close, minimize, maximize, icon, appmenu, menu and :. : represents the middle of the title bar. Examples:

Gnome default appmenu:close 2

KDE default and what vscode currently shows icon,appmenu:minimize,maximize,close 1

close:appmenu 3

Even this would be possible close:appmenu,minimize,icon,maximize 4

I have tried to implement this. The title bar is compiled in src/vs/workbench/browser/parts/titlebar/titlebarPart.ts and src/vs/workbench/electron-sandbox/parts/titlebar/titlebarPart.ts. However, I was not able to obtain the GSettings. The cleanest way would be to use the C API. But it would need some additional dependencies to make it work in TypeScript.

Alternatively, the D-Bus service org.freedesktop.portal.Desktop /org.freedesktop/portal/desktop org.freedesktop.portal.Settings.Read("org.gnome.desktop.wm.preferences", "button-layout") could be used to get the value. However, I have not found a native API in TypeScript for this either. In addition, D-Bus would be slower than the C-API and this service has not been around that long, so those who rely on an ancient Debian would not have this implementation available.

The last option would be to call gsettings from the command line. But this would almost certainly not be authorized in a pull request. That's why I didn't even try.

2zqa commented 1 month ago

This would come from WCO on linux, right @deepak1556

WCO has since landed for Linux: https://github.com/electron/electron/pull/41769. Does this mean we will soonTM automatically see GTK-like buttons in VS Code on GNOME?

bpasero commented 1 month ago

👋 we now have a VS Code insiders build ready that can draw native window controls when custom title is enabled:

Can people report back how that feels?

Image

TomiOhl commented 1 month ago

Tried the insiders build. Here is a comparison on elementary OS: stable vs code with native title bar <> the insiders build with custom title bar: image So while this definitely feels less windows-like, there are still two problems:

2zqa commented 1 month ago

Thanks bpasero, this is a great improvement over what it used to be! It is using the correct images for the buttons now.

I feel like it could be improved if it also listens to which buttons are enabled. On Fedora by default, the maximize and minimize buttons are hidden by default, as seen in the attachments of this comment. I am unsure how to detect this, I hope someone else can chip in on that.

And to make it perfect, it would be great if it mirrored the default GNOME theme ("libadwaita") even more, by adding the circles around the images and having more padding. For this, see also the differences in the screenshots provided. I think the Human Interface Guidelines of GNOME could use used as a resource for this, but I don't have any further info on this so far.

Schermafdruk van 2024-08-13 15-54-04 Schermafdruk van 2024-08-13 15-54-07 Schermafdruk van 2024-08-13 15-54-21 Schermafdruk van 2024-08-13 15-54-26

LasseRosenow commented 1 month ago

@2zqa I think this is an Electron issue. I asked in the Pull Request that landed support for Linux support of custom title bar styling, if they intend to fix this :)

See electron/electron#41769

rodrigoGA commented 1 month ago

Although it is an improvement, the images seem far from being a solution to this problem. The maximize icon does not seem to be respected; the size appears to be different, and it causes the window borders to break the operating system's style. I hope there is no intention to consider this change as the solution to this issue, because it does not resolve it.

Jervx commented 4 weeks ago

Awesome! Now it uses the native buttons ❤️.

image

image

image

Also I have a question, is if it possible to detect the native position of the (min, max, close) buttons since linux can be tweaked to move them right or left of the window?

TomiOhl commented 4 weeks ago

Small theme issue: notice the absence of the lines above/next to the controls with high contrast theme image

bpasero commented 3 weeks ago

Small theme issue: notice the absence of the lines above/next to the controls with high contrast theme image

Thanks, pushing a fix. Unfortunately with window control overlays we cannot support a custom window border anymore. We already disable that support on Windows and now will have to do on Linux as well.

uRohan commented 3 weeks ago

Minor issue one:

The position of the buttons changes vertically depending on the state of the window (whether it is maximized or not). You can notice this if you quickly switch between two screenshots.

Here's what it looks like:

Normal window Maximized window
Normal window Maximized window

Minor issue two:

They also look somewhat different from the window control buttons of other applications under Ubuntu 22.04.4 LTS.

Additional screenshots for comparison:

Visual Studio Code:

Light mode Dark mode
Screenshot from 2024-08-20 23-59-57 Screenshot from 2024-08-21 00-00-16
Screenshot from 2024-08-21 00-00-03 Screenshot from 2024-08-21 00-00-24

Other applications:

Light mode Dark mode
Screenshot from 2024-08-21 00-01-14 Screenshot from 2024-08-21 00-32-06
Screenshot from 2024-08-21 00-01-20 Screenshot from 2024-08-21 00-32-10
Screenshot from 2024-08-21 00-00-48 Screenshot from 2024-08-21 00-02-06
Screenshot from 2024-08-21 00-00-53 Screenshot from 2024-08-21 00-02-09

Minor issue three:

It is impossible to grab and move the window in this area of the title bar.

Normal window Maximized window
normal window maximized window