Skip to content

Linux - Provide window borders and title bar buttons approprate for the user's desktop environment #44540

Description

@acerspyro

Preflight Checklist

Problem Description

It is my understanding that Windows and macOS impose window border shapes and appearances through their respective window managers. These operating systems also provide native title bar buttons upon request or overlay them automatically.

In contrast, Linux platforms delegate the responsibility for border styles, title bar buttons, their positioning, appearance, and quantity to the Electron application itself.

This approach shifts the burden of proper desktop integration to the application developer. Often, developers opt for a simplified solution: an undrawn square border with three generic buttons (minimize, maximize, and close) positioned in the top-right corner. However, this generic approach may not align with user preferences or conform to the conventions of the current desktop environment.

Image

Proposed Solution

Electron should provide a platform-specific window border and apply two sets of title bar buttons (left and right) to the application upon request.

This system could support multiple desktop environments with unique title bar styling, including but not limited to:

  • GNOME
  • KDE
  • Elementary
  • COSMIC

While the extent of matching user preferences may vary, this approach would require exposing a generic interface to the underlying application. This interface would automatically apply the correct title bar button styling and appearance using a strategy pattern.

Alternatives Considered

I've explored the possibility of developing a Web Components library that would provide three key components:

  1. A window wrapper component:

    • Implements the correct border (and shadow, if necessary) for the platform
    • Optionally includes a simple title bar
  2. A component for the left bank of title bar buttons

  3. A component for the right bank of title bar buttons

This approach would enable developers to incorporate environment-specific window controls without the need to create custom solutions specifically for the Linux platform.

Additional Information

No response

Activity

  1. fxzxzyra commented on Mar 20, 2025

    @fxzxzyra

    Does this help with the following problem?

    Image
    Image

    WM: hyprland

  2. acerspyro commented on Mar 28, 2025

    @acerspyro
    Author

    Does this help with the following problem?

    Image Image

    WM: hyprland

    Assuming I'm understanding what's going on in your screenshot, hyprland might be offering some native way of rounding the title bar buttons.

    However, most WMs don't support this, and it would still mean the application could display the wrong number of buttons for the user's config, on place them on the wrong side of the title bar with the wrong icons for the user's environment.

    What I'm calling for is for Electron to either bundle native GTK 4 / Qt6 window decorations to wrap the window with, or provide a config-based lookalike frame for the most common DEs with a fallback to GTK4.

  3. fxzxzyra commented on Mar 29, 2025

    @fxzxzyra

    Actually, I'm not talking about the shape of the buttons, I'm talking about the buttons on the far right (like close). I'm sorry that I thought it was obvious.
    In some WM, that buttons on the far right of the application don't make sense, so they ask the application to hide them.

  4. flying-sheep commented on May 6, 2025

    @flying-sheep
    Contributor

    Letting the theme engine draw the buttons is the only solution that makes sense. E.g. I’m on KDE Plasma, but I configured it to show the buttons on the left. Electron apps not only completely ignore button shape and icons, but also position:

    Image

  5. do-sch commented on Aug 2, 2025

    @do-sch

    This system could support multiple desktop environments with unique title bar styling, including but not limited to:

    * GNOME
    
    * KDE
    
    * Elementary
    
    * COSMIC
    

    While the extent of matching user preferences may vary, this approach would require exposing a generic interface to the underlying application. This interface would automatically apply the correct title bar button styling and appearance using a strategy pattern.

    Instead of parsing settings for each individual desktop environment, electron could just call this DBus method:
    org.freedesktop.portal.Desktop
    /org/freedesktop/portal/desktop
    org.freedesktop.portal.Settings.Read("org.gnome.desktop.wm.preferences", "button-layout")

    It could as well listen to 'org.freedesktop.portal.Settings.SettingsChanged' to receive changes of this setting.

    Even if it says org.gnome.desktop this setting is exposed by every major desktop environment including KDE, XFCE and Elementary. It returns a string describing arrangement of buttons in the window title bar.

    Alternatively, electron could query this string via GtkSettings ("gtk-decoration-layout"), since electron already links with GTK.

    The string always contains ":" representing title bar as well as a comma separated list of the following:
    "close", "minimize", "maximize", "icon", "menu", "appmenu".

    On elementary it would always return "close:maximize". Default setting for vanilla GNOME would be "appmenu:close". Default setting for KDE would be "icon:minimize,maximize,close".

    Dependent on this information electron could build two areas in which the wanted buttons are drawn in Linux desktop environments. In Mac OS it can just draw the traffic light indicators on the left and draw nothing on the right. In Windows it could draw the application icon on the left and minimize, maximize and close on the right and the other way around when language is set to rtl languages such as arabic, hebrew or persian.

    When it comes to the individual icons of the buttons, window border and border radius on top and bottom corners it gets much harder as there is no universal interface to obtain these settings from. Google Chrome and Firefox both call GTK library functions to load the icons. To get window border information, Chrome parses the GTK Theme and Firefox calls GDK functions. This works on KDE too because KDE generates a GTK Theme to let GTK application look as native as possible.

  6. xushengfeng commented on Oct 29, 2025

    @xushengfeng

    It looks like we need a new Wayland protocol for WOC

  7. hsnfirdaus commented on Dec 8, 2025

    @hsnfirdaus

    Many apps like vscode and discord now using custom window decoration trough WCO in Linux, i'm wondering what make this "decoration" doesn't implemented yet in electron. Is electron already use this: https://docs.gtk.org/gtk4/class.WindowControls.html

  8. tarik02 commented on Apr 13, 2026

    @tarik02
    Contributor
  9. nikwen commented on Apr 13, 2026

    @nikwen
    Member

    @mitchchn What is your thought on this? Should we do this?

    Everyone else, read Mitch's great article here where he goes into topics like this one: https://www.electronjs.org/blog/tech-talk-wayland

  10. mitchchn commented on Jun 15, 2026

    @mitchchn
    Member

    Update for everyone here -- Electron 43 honours the platform titlebar settings for:

    • Button relative order
    • Button visibility (e.g. there won't be a minimize button by default on GNOME)
    • Leading/trailing configuration (whether some or all buttons will be on the left or right side of the window)

    So a large part of this issue can be considered resolved as of 43.0.

    The part that is less straightforward is using the actual themed widgets from the platform. Even if we just stick to one toolkit (GTK), Electron allows developers to apply colors to window controls so they will blend well with web content. I don't know how well this would work with GTK buttons but I am going to try it out.

  11. eyelash commented on Jun 15, 2026

    @eyelash

    What about using the right icon theme for the close, maximize, and minimize buttons? All the screenshots in this issue show the same (presumably Adwaita) icons. The Ubuntu default theme (Yaru) has thinner icons. KDE (Breeze) also has different icons. Chromium and Electron already have the ability to use the right icons for example if you set the title bar style to native in VSCode on Wayland.

    One other thing is the placement of the buttons. They are too close together and the rightmost button almost touches the right edge of the window.

  12. eyelash commented on Jun 15, 2026

    @eyelash

    I just took the following screenshot of a few different applications on Ubuntu 24.04. As you can see the buttons are not identical between these apps but they are similar enough. VSCode really sticks out here because of the icons and the button placement.

    Image
  13. mitchchn commented on Jun 15, 2026

    @mitchchn
    Member

    Thanks for the comparison @eyelash. It is certainly possible for Electron to draw themed titlebar icons from GTK. In fact that's already what happens when you create a window with frame: true (or "show system titlebar").

    It is just more challenging to do this for apps that show edge-to-edge web content, since the rest of the row is not a standard GTK titlebar. Electron has to make choices about which values to apply/ignore so it won't conflict with the top row of the web app taking up the same space. It's possible, but we have to be careful. See this prototype using Breeze (GTK theme) on KDE:

    Image
  14. acerspyro commented on Jun 15, 2026

    @acerspyro
    Author

    @mitchchn Been a while since I wrote Electron, is your example simply with frame: true or is there more to it? I thought frame: true would show a bog standard system titlebar and frame with no ability to draw on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions