Skip to content

[Feature Request] Support CSD in Wayland #27522

Closed

Description

@memeplex

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem Description

In Wayland clients usually render their own decorations, they don't get SSD anymore (although there seems to be a protocol for SSD negotiation that Plasma and some compositors based on wlroots implement). The Wayland build is not very useful until Electron app windows get a proper headerbar. The headerbar can be a stock headerbar similar to old-school SSD or can be customized by the app (for example, by setting its color/theme in accordance with the app contents).

Proposed Solution

Use GTK CSD support, which is also well-integrated in Qt-based environments (mainly Plasma):

https://developer.gnome.org/gtk3/stable/GtkHeaderBar.html:

void gtk_header_bar_set_show_close_button (GtkHeaderBar *bar, gboolean setting);

Sets whether this header bar shows the standard window decorations, including close, maximize, and minimize.

https://developer.gnome.org/gtk3/stable/GtkSettings.html#GtkSettings--gtk-decoration-layout:

“gtk-decoration-layout”    char *

This setting determines which buttons should be put in the titlebar of client-side decorated windows, and whether they should be placed at the left of right.

Alternatives Considered

It doesn't seem to exist much more alternatives. Maybe Qt has a native headerbar implementation, but it won't properly work inside a GTK-based environment like GNOME, while it works the other way around. See https://pointieststick.com/2019/11/30/this-week-in-kde-gtk-csd-support-and-more

Maybe xdg-decoration as suggested in some comments below. But I ignore everything about it and SSD doesn't seem to me the best alternative for Electron apps that tend to be more app-centric than platform-centric by its very nature and so, at least in major platforms, usually customize headerbars.

Additional Information

More details in discussion starting from #10915 (comment)

Activity

  1. Xyene commented on Jan 27, 2021

    @Xyene

    Leaving aside the meat of this request, I did want to point out one misconception:

    In Wayland all clients have to render their own decorations, there are no SSD anymore.

    This is not true.

    There exists a protocol (xdg-decoration) that at least KDE and Sway/wlroots implement, allowing negotiation of SSDs. What is true is that GNOME have made it very clear they will not implement this protocol, such that applications wishing to have decorations on GNOME must implement CSDs.

    See:

  2. ckerr commented on Jan 27, 2021

    @ckerr
    Member

    Thanks for the suggestion!

    I know the Electron project would be very happy to have better Wayland support but I don't think there is anyone on the project actively working on this right now. If anyone in the community wants to contribute work to this, I for one would be very happy about that.

  3. ZanderBrown commented on Jan 27, 2021

    @ZanderBrown

    There exists a protocol

    An unstable optional/extension protocol which even states that a valid xdg-decoration implementation doesn't actually have to support SSD, so whilst it may be something electron is interested in it is not the solution you are looking for as even when xdg-decoration is present (and at least on GNOME it isn't) it may not do anything

  4. memeplex commented on Jan 27, 2021

    @memeplex
    Author

    In Wayland all clients have to render their own decorations, there are no SSD anymore.

    This is not true.

    I didn't know about xdg-decoration, I edited the description to account for this. Thank you.

  5. Xyene commented on Jan 27, 2021

    @Xyene

    .. so whilst it may be something electron is interested in it is not the solution you are looking for ...

    Yes, agreed, I was only pointing out against the (probably unintentional) absolutist "there are no SSDs [in Wayland]" (emphasis mine). There is an extension for negotiating SSDs that KDE and wlroots implement. It's not supported by GNOME. Electron doesn't strictly use core Wayland protocols. Leaving aside personal opinions on the matter, this is the current state of decorations on Wayland :)

    I edited the description to account for this.

    Note that KDE's Wayland support isn't based on wlroots :)

  6. memeplex commented on Jan 27, 2021

    @memeplex
    Author

    I remember having read the post by Tobias @Xyene linked at the time, I mean https://blogs.gnome.org/tbernard/2018/01/26/csd-initiative/. Rereading it now I realize Electron was mentioned as a potentially easy case:

    Many Electron apps might be low-hanging fruit, because they already use CSD on macOS. This means it should be possible to make this happen on GNU/Linux as well without major changes to the app. However, some underlying work in Electron to expose the necessary settings to apps might be required first.

  7. ZanderBrown commented on Jan 27, 2021

    @ZanderBrown

    Note Tobias made that comment from the perspective of app developers using it, not electron providing it

  8. memeplex commented on Jan 27, 2021

    @memeplex
    Author

    Note Tobias made that comment from the perspective of app developers using it, not electron providing it

    Yes, that's true, but I assume that the fact that apps are doing this in MacOS, combining their own widgets with platform provided ones in a coherent way, means that the abstractions are right there in Electron and we need to implement them, not define them. I ignore everything about Electron, TBH, so I'm going to take a look later.

  9. christianrauch commented on Mar 4, 2021

    @christianrauch

    Just want to add here that libdecor could be used specifically to implement client-side decorations under Wayland.

  10. stalkerg commented on Mar 16, 2021

    @stalkerg

    @christianrauch I can't see any much activities there it looks like a prototype. Also, it does not support Enignlement.

  11. christianrauch commented on Mar 16, 2021

    @christianrauch

    I can't see any much activities there it looks like a prototype.

    What activity would you expect? libdecor is a library that only implements window decorations, nothing more. If you need a specific feature, you can open an issue and we can review how feasible this is.
    I hereby officially invite you to become active in the project :-)

    Also, it does not support Enignlement.

    What is "Enignlement"? Is it an application? If the decorations don't work as expected with your application then please open an issue so we can review if this is an issue with libdecor or the client application.

  12. jokeyrhyme commented on Mar 16, 2021

    @jokeyrhyme

    Possibly a reference to the Enlightenment desktop/compositor, which does support client-side decorations in wayland: https://www.enlightenment.org/about-wayland

  13. rohmishra commented on Mar 19, 2021

    @rohmishra

    I'm looking for clarification and also take this with a grain of salt since it's been a while since I last worked on anything electron but:

    AFAIR the buttons used in mac and windows were a bit more bespoke/custom than they looked because since windows & mac both are one singe platforms we knew where the buttons had to be and how they looked so apps just implemented buttons looking like that (and I guess on mac you can request the system to draw the buttons for you). But for true CSD support on Linux it's not that simple because on Linux you can configure where you want the buttons, which buttons do you want and how the buttons look. So for true CSD the apps need to implement a way to handle button arrangement so that it follows the system style (left/right, which buttons) and either devise a way to make sure current button style looks good/usable with their app theme or just use custom assets for the icon.

    Which leads me to my conclusion/questions/clarification:

    • What's missing is a way for apps to read gtk-decoration-layout easily. But once apps can read that, apps can replicate (with a bit or rework and code sharing between Linux left side decoration/mac and right side/windows) button layout and apps should feel more in line with native apps as far as layout goes. (Or is it possible just never done?)
    • there still are edge cases for buttons outside of the standard close, minimize, restore or systems like elementary which has button on both sides where apps need to have more flexible solution for their headers.
    • this only works for apps that have window decorations mixed with their layout and apps are explicitly responsible for placing them like vscode but not apps that usually have system draw decorations for them (native window frame in vsc and other apps/almost all electron apps currently on Linux) so electron still needs to ship something (eg. libdecoration) to draw the buttons for those apps behind the scenes.
    • developers still have to implement it or use a library that does most of the heavy lifting for them especially if they plan to support more exotic decoration config or using system assets for buttons
  14. WhyNotHugo commented on Mar 19, 2021

    @WhyNotHugo

    @rohmishra You are correct.

    In reality, Server Side Decorations are the simplest way to implement thing for developers: applications will be drawn with buttons (and everything else) in whichever way the user configured it in whatever desktop they may be using. It's what works almost everywhere, and works best.

    Gnome is the notable exception, since it requires applications to use CSD. This forces applications to have explicit support for Gnome (my understand is that it's to kinda force applications to have dedicated Gnome-support, further pulling them into the Gnome/Gtk ecosystem).

    I don't think there's any way to have customised decorations with SSDs though; it's generally an all-or-nothing kind of thing.

  15. 27 remaining items

  16. WhyNotHugo commented on Jun 11, 2021

    @WhyNotHugo

    Looks like this is a duplicate of #27016

  17. added 4 commits that reference this issue on Jun 11, 2021
    2779af1
    68b39d9
    b53cc01
    b94cf6d
  18. added 3 commits that reference this issue on Jun 25, 2021
    85eac8c
    3256f0f
    a836080
  19. added 3 commits that reference this issue on Nov 27, 2021
    2c1a98c
    08d06de
    9075d00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions