zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
46.59k stars 2.64k forks source link

[Linux] Add option to disable client side decoration / enable native titlebar #14165

Open DenysMb opened 1 month ago

DenysMb commented 1 month ago

Check for existing issues

Describe the feature

Hello!

Would be nice if we have an option to disable the client side decoration (enable the default native titlebar).

This way, we could integrate the editor way better with the environment.

Here is an example of VS Code using native titlebar instead of its own: image

And here is Zed: image

The window buttons (to close, minimize and maximize) are different and the border radius are different. With others windows opened, it looks out of place.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

JackNWhite commented 1 month ago

Another example of why this is important image

sangelxyz commented 1 month ago

It would be nice if there is a setting to remove the title bar all together. It takes up space and doesn't really add anything.

wildcart commented 1 month ago

I would also like to have the option to enable a native titlebar/window decoration.

Different Linux Desktop Environments (DE) provide different functionality, some of which include

None of these features are implemented by the zed titlebar. Instead, these features are currently inaccessible or are only accessible knowing the keyboard shortcut to open a window manager specific window menu (Alt+F3 on KDE/Plasma), if the Linux DE provides such a shortcut.

Applications like Firefox, Chromium, VS Code, Intellij (new UI), and others allow to toggle between an application specific and a native titlebar/window decoration. zed unfortunately doesn't even allow to show the native titlebar/window decoration on top of the application specific toolbar. Instead, the menu option to toggle the native titlebar is disabled in KDE/Plasma's window menu.

To close my post: I do like the editor, which feels more responsive than some editors I am currently (loving that the editor comes with build in VIM mode).

apricotbucket28 commented 1 month ago

You can actually switch to window decorations by running with ZED_WINDOW_DECORATIONS=server (original comment)

A setting in settings.json like VSCode has would still be nice though.

only accessible knowing the keyboard shortcut to open a window manager specific window menu (Alt+F3 on KDE/Plasma), if the Linux DE provides such a shortcut.

FYI Zed actually supports the menu you're talking about. image

LSeelig commented 1 month ago

You can actually switch to window decorations by running with ZED_WINDOW_DECORATIONS=server (original comment)

A setting in settings.json like VSCode has would still be nice though.

only accessible knowing the keyboard shortcut to open a window manager specific window menu (Alt+F3 on KDE/Plasma), if the Linux DE provides such a shortcut.

FYI Zed actually supports the menu you're talking about. image

Unfortunately, some desktops (GNOME) have not and do not plan to add SSD support on Wayland. Libdecor, however, should work fine.

If you or other contributors are interested, I think the setting ZED_WINDOW_DECORATIONS should have three options instead of two: client, server, and native, which would use libdecor.

wildcart commented 1 month ago

@apricotbucket28 thanks for pointing out the environment variable.

Regarding the window menu: I know that I can access the menu (using the keyboard shortcut) but without setting ZED_WINDOW_DECORATIONS=server, the option No Titlebar and Frame is disabled. The option is located in the More Actions sub menu.

tmke8 commented 3 weeks ago

Wouldn't the following work?

apricotbucket28 commented 3 weeks ago

Wouldn't the following work?

if the Wayland compositor supports the [xdg-decoration](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml) protocol, use it for the titlebar to get a native-looking titlebar

if the Wayland compositor does not support the protocol (which will be the case for GNOME – they will never implement it), draw client-side decorations

You can already do that with the aforementioned ZED_WINDOW_DECORATIONS=server environment variable. I don't think anyone is willing to add libdecor support and the Zed team has already said that they want CSD as the default.

I think a setting in settings.json for toggling CSD/SSD would be nice though, and a PR for that would likely be accepted. Something like "window_decorations": "server" 🙂

adityainduraj commented 2 weeks ago

I understand that Gnome doesn't plan on integrating SSD, but a sizeable chunk of linux users do use Gnome. And if VSCode can draw native titlebars, I don't see why Zed can't implement the same.

LSeelig commented 2 weeks ago

I understand that Gnome doesn't plan on integrating SSD, but a sizeable chunk of linux users do use Gnome. And if VSCode can draw native titlebars, I don't see why Zed can't implement the same.

VSCode is an electron app, so it uses the Electron implementation, which builds on Chromium. Zed is novel.

If GNOME users want system window decorations, there are a few possibilities:

  1. Implement libdecor, which provides the decorations. According to @apricotbucket28, there isn't really an appetite for this, but I would note the existence of libdecor-rs, which, while outdated, may still form the basis of a much simpler implementation Unfortunately, libdecor itself is problematic with modern GNOME as it does not support Libadwaita or even GTK4, and GTK3 themes don't solve some very ugly shadows.

  2. Themeable CSD - this is what my money is on, if this problem gets solved. As @apricotbucket28 also said, the Zed team prefers client-side decorations, and this has been a fairly common approach. Many applications (such as Firefox and Chromium, to my knowledge), aren't actually QT or GTK, but simply take the gtk or qt theme's colors and buttons to use in their CSD. LibreOffice takes this even further, with its own GUI toolkit it hooks into GTK and QT not just for CSD but (most?) UI widgets. If Zed's theming capabilities improve to the point icons and spacing can be modified, I would not be surprised if user themes like Zedwaita do so. There are downsides, however. If it is only supported through third-party themes, less popular themes and DEs may not get nice CSD. There may be other discrepancies. Very few apps (Firefox being a recent exception) that don't use libadwaita but imitate it modify corners or shadows to match libadwaita, and other behavior (headerbar color changing when window is focused/unfocused, hovering over close button, etc) might not be implemented.

  3. XWayland - currently, running zed with the envvar WAYLAND_DISPLAY="" (and ZED_WINDOW_DECORATIONS=server) still has proper SSD on GNOME. This is what I would recommend to most GNOME users in the present, however xwayland doesn't support fractional scaling well until at least GNOME 47, and even then, I don't know what the results will be on Zed.

  4. GNOME changes their mind and implements xdg-decoration. I hope this will happen, but I don't have much confidence. The GNOME team seems to believe decorations are an essential part of modern (Wayland) applications, so only xwayland, which is intended for legacy applications that don't support wayland, can have SSD.

After writing this out, I get the feeling there should be a separate issue thread, titled something like "Better/Themeable CSD on Linux" or "Native (style) decorations on GNOME". Zed already supports disabling CSD and enabling a native titlebar through the env var, as has been mentioned. What is there to discuss other than adding it to the Zed settings?