Skip to content

Native headerbars #11907

Closed
Closed

Description

@1j01

Client-Side Decoration (CSD) support, for native headerbars

eos files headerbar

  • Electron version: 1.8.2 is currently the latest
  • Operating system: Linux

From https://wiki.gnome.org/Initiatives/CSD:

Electron

Many Electron apps should be low-hanging fruit, because they already use CSD on macOS (e.g. Slack).
This likely means very little work would be required on the application side to make this happen on GNU/Linux as well.

However, since some additional complexity is required in order to get the proper GNOME CSD behavior (respecting gsettings etc.), some of this should probably be supported by Electron directly. That would be easier for Electron app developers and make for more consistent behavior.

We should first work with upstream Electron to add GNOME-style CSD support at a platform level. Once that is in place, we can start approaching individual app developers.

Related: atom/atom#2215, #2927 (comment)

Activity

  1. welcome commented on Feb 13, 2018

    @welcome

    👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

    To help make it easier for us to investigate your issue, please follow the contributing guidelines.

  2. bugaevc commented on Feb 13, 2018

    @bugaevc

    Also related: atom/atom#13249, atom/atom#4599.

    For Atom's titlebar implementation for macOS see atom/atom#13616

  3. felixrieseberg commented on Feb 14, 2018

    @felixrieseberg
    Member

    Solid idea. The usual open source rules apply: If you build it, developers might use it.

  4. TingPing commented on Mar 16, 2018

    @TingPing
    Contributor

    Dumb question but this seems to work fine on Linux: https://github.com/electron/electron/blob/master/docs/api/frameless-window.md

    So what is actually needed for applications to use CSD? What method is commonly used to enable it?

    EDIT: Ah titleBarStyle only seems to work on OSX.

  5. ZanderBrown commented on Jun 12, 2018

    @ZanderBrown
  6. Feichtmeier commented on Jun 29, 2018

    @Feichtmeier

    This would be very helpful in Ubuntu since the latest re-introduction of the GNOME shell as the default desktop environment, because in GNOME shell there is no easy way (yes, there are extensions that can be installed) to merge the titlebar of windows with the shell's panel! This would save screenspace and would follow the latest UI trends :)

  7. corebots commented on Aug 29, 2019

    @corebots

    Please add CSD support for Electron apps on GNOME. There are so many nice Electron apps and they all still use the old titlebar :( Imagine the bomb exploding when Electron apps suddenly look like native GNOME ones :)

  8. mld9401 commented on Mar 27, 2020

    @mld9401

    Please add CSD support on Linux

  9. TheGreatHalva commented on Apr 2, 2020

    @TheGreatHalva

    Now that KDE supports headerbars too, there's even more reason to do it.

  10. TingPing commented on Apr 2, 2020

    @TingPing
    Contributor

    Visual Studio Code has been using CSD for like a year on Linux so its clearly possible. It just requires the application manually opt-in for some reason.

  11. teohhanhui commented on Apr 2, 2020

    @teohhanhui

    Visual Studio Code has been using CSD for like a year on Linux

    That's a custom implementation that doesn't respect the native look and feel.

  12. 50 remaining items

  13. alice-mkh commented on Dec 10, 2020

    @alice-mkh

    Passthrough is kinda implicit in GTK, but I don't know for sure if specifically window handle would block it.

  14. alice-mkh commented on Dec 12, 2020

    @alice-mkh

    A quick proof of concept made of GTK4 WebKit minibrowser:

    Screenshot from 2020-12-13 03-51-01

    The top bar is draggable, has context menu etc. However, that area of the web page does not pass any events to the web page, i.e. cannot be clicked other than for window actions, cannot be scrolled etc.

  15. memeplex commented on Jan 27, 2021

    @memeplex

    Given that this is almost sine qua non for Wayland, I have opened an FR #27522. Only later I found out this issue which AFAICS has been disconnected from recent developments in Electron towards Wayland support. I don't know which is the best way to proceed: leaving my Wayland specific FR as part of the Wayland support initiative, leaving this more general one open, leaving both open.

  16. memeplex commented on Jan 27, 2021

    @memeplex

    I'm interested in exploring the approach suggested by @Exalm here #11907 (comment).

    Some questions though:

    • If this were a plausible solution, would it imply full migration of Electron to GTK4?
    • Would that be too hard or even acceptable?

    Regarding the second question, for me the relevant time horizon is tied to Wayland support, so it's clearly not next month but, at best, next year (I'm an optimist). In that light, GTK4 seems less unreasonable.

  17. alice-mkh commented on Jan 27, 2021

    @alice-mkh

    Yes, that's GTK4.

    Too hard in what sense? It's just a bit of widgetry. Of course you'd also need API to control it, but it already works this way on macOS, so...

  18. memeplex commented on Jan 27, 2021

    @memeplex

    Too hard in what sense? It's just a bit of widgetry. Of course you'd also need API to control it, but it already works this way on macOS, so..

    I meant porting Electron to GTK4, not GTK4 per se. I don't know how much of GTK is there in Electron, I assume it's just a scaffolding bit but it's all guessing at this point for me.

    Ah, and also:

    • Being GTK4 controls, would this be supported out of the box by Plasma GTK CSD integration? Anyone knows?
  19. memeplex commented on Jan 30, 2021

    @memeplex

    @Exalm GtkWindowHandle doesn't pass clicks through, but I managed to get it somehow working with a custom gesture controller:

    import gi
    gi.require_version("Gtk", "4.0")
    from gi.repository import Gtk
    
    
    def activate(app):
        win = Gtk.ApplicationWindow(application=app)
        button = Gtk.Button(label="Click me")
        button.connect("clicked", lambda *_: print("Clicked"))
        ctrls = Gtk.WindowControls(side=Gtk.PackType.END)
        ctrls.set_halign(Gtk.Align.END)
        handle = Gtk.WindowHandle()
        handle.set_valign(Gtk.Align.START)
        handle.set_child(ctrls)
        gesture = Gtk.GestureClick()
        gesture.connect("released", lambda *_: button.emit("clicked"))
        handle.add_controller(gesture)
        over = Gtk.Overlay()
        over.add_overlay(button)
        over.add_overlay(handle)
        win.set_child(over)
        win.show()
    
    app = Gtk.Application()
    app.connect("activate", activate)
    app.run()

    Here the main widget is a button, not a webview, but I think that's good enough for a POC. Even though I think it's not that bad, I sort of dislike the idea that every release is passed to the underlying button as a click, I would like to differentiate between single and double clicks, but I don't know of a way to separate them other than waiting for a fraction of second to the second click (n_press = 2).

    Moreover, I don't know if the only event we want to forward is a single click, probably it is but I will have to understand how this is managed by Electron for other platforms first.

  20. memeplex commented on Jan 31, 2021

    @memeplex

    Apart from how to do this GTK side, it seems to me that it would be hard to implement Electron side. AFAICS there is no GTK window to which simply set the overlay as content, but windows come from deep into the aura/ozone layers and have nothing GTK in them. For the MacOS case the entire NativeWindow was reimplemented, look at the header file to get an idea about how many methods were overridden, then a WindowButtonsView was introduced into the window. I might be plain wrong, but I suspect something like that should be done for Linux in order to introduce the overlay, handle and buttons.

    Could someone more savvy take a look at this?

  21. stalkerg commented on Mar 16, 2021

    @stalkerg

    What about KDE/Plasma integration? I mean I hope the Electron will not depend on GTK much.

  22. rohmishra commented on May 23, 2021

    @rohmishra

    @memeplex unfortunately im not to familiar with how electron windows work but you seem to be right. After spending a few hours in there trying to understand it, it seems that to have native headerbars from gtk, it would need huge amount of rework to get those gtk components on screen. And given that most apps dont even bother having client side decorations on linux (slack, discord, etc all use system provided bars, vscode gives an option but it is rather basic and doesnt follow system convention.) it seems unlikely anyone would bother implementing it for gtk/linux. The next best thing would be to allow apps to read the window button configuration (position, options, actual button assets) which would allow apps to use their CSD and still follow somewhat follow the system convention. This is an OK option since usability wise, we are matching the button layout and gnome HIG is open to apps using their style as long as they follow some basic conventions.

  23. RaisinTen commented on Jul 15, 2022

    @RaisinTen
    Contributor

    @1j01 #29618 has landed already. Can we close this issue now?

  24. harmathy commented on Jul 15, 2022

    @harmathy

    @RaisinTen The problem is, that it is not enabled by default and utterly broken (#34820)

  25. RaisinTen commented on Jul 15, 2022

    @RaisinTen
    Contributor

    @harmathy I'm guessing it wasn't enabled by default because it's experimental and has the potential to be broken? To my understanding, this issue is just about having the feature in Electron and not about making sure that it's bug-free or enabled by default.

    Since we have an open issue tracking the bug you mentioned already, what do you think about continuing the discussion there / creating newer issues if more bugs are found? FWIW, the PR author mentioned that they'll take a look at the issue you shared - #34820 (comment).

  26. RaisinTen commented on Jul 18, 2022

    @RaisinTen
    Contributor

    I see there are few PRs up already, attempting to fix that bug. Closing this issue for now, thank you all for the feature request!

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