Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wayland support #32

Open
CrystalGamma opened this issue Jul 8, 2015 · 41 comments
Open

Wayland support #32

CrystalGamma opened this issue Jul 8, 2015 · 41 comments
Labels
enhancement workaround there's a workaround for this bug

Comments

@CrystalGamma
Copy link

First, I'd like to thank you, deadalnix. Since my previous solution with Status Title Bar and a metacity theme hack broke with 3.16, I've been on the lookout for something that actually worked, and this one does.

So, since this extension uses xprop, it only works on X windows. Since I use Wayland, GTK3 applications do not shed their titlebar when maximized. This is generally not dramatic because most of them have an action bar anyway, but Evolution still uses a simple title bar. It would be great if I could remove its titlebar as well.

@aquatix
Copy link

aquatix commented Oct 7, 2016

Same with gnome-terminal, for example.

@Nowrouz
Copy link

Nowrouz commented Nov 17, 2016

Hi, I'm using gnome 3.22.2 on Xorg and this extension doesn't work with any of applications with simple title bar, and I think this extension is a "must have", so I'll appreciate if you consider a fix.

@dLobatog
Copy link

Same problem here - how can I help by looking into adapting this to Wayland?

@jhasse
Copy link

jhasse commented Nov 24, 2016

I'm not sure, but there needs to be some kind of support for this in Gtk+3, right? So the first thing to do would be to open a bug report at their Bugzilla page.

@cesarizu
Copy link

cesarizu commented Nov 24, 2016

The main problem I believe is the function guessWindowXID(win) in decoration.js that tries to use xwininfo and xprop to find the window id and then getOriginalState(win) and others that use that function. The problem is that AFAIK there's no replacement on wayland for those functions.

@deadalnix
Copy link
Collaborator

deadalnix commented Nov 24, 2016 via email

@cesarizu
Copy link

pixel-saver sets the _GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED x property that the mutter understands and hides the decoration. The problem will be how to communicate that to mutter when using wayland, since mutter is the wayland compositor for gnome shell.

@jhasse
Copy link

jhasse commented Nov 24, 2016

Mutter isn't drawing the decorations anymore, but e. g. Gtk+ 3.

@cesarizu
Copy link

@jhasse Do you know where is that happening?

I'm really not sure how it works exactly but mutter has a hide_titlebar_when_maximized on the MetaWindow class that is set by _GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED on X11. This is used both in x11 and wayland to hide the title bar when the window is either maximized or tiled to the left or right.

I believe that, if it would be possible to set that property from the proxy window in js, the title bar should be gone without all the xprop stuff.

@cesarizu
Copy link

cesarizu commented Nov 25, 2016

I've just added a PR that adds support for future mutter versions over wayland. See #98.

Sadly mutter ignores the hide_titlebar_when_maximized MetaWindow property on Wayland and does not undecorate windows. I've opened a bug for this problem with mutter at https://bugzilla.gnome.org/show_bug.cgi?id=775061

In any case the PR still works for X11 without the need to call xprop or any other program directly (provided that you are using a patched mutter).

@essen
Copy link

essen commented Nov 25, 2016

I can confirm that it works with patched mutter and patched pixel-saver. Thanks!

@deadalnix
Copy link
Collaborator

@cesarizu do you think this can be merged in mutter soonish ? If so, any idea how long before this is widespread ?

Awesome detective work, BTW !

@cesarizu
Copy link

cesarizu commented Nov 25, 2016

I'm not really sure. And it's not really working completely with wayland. I'm still looking into how to set the hide_titlebar_when_maximized on the GtkWindow, but it doesn't seem easy. Right now this patch just enables Pixel Saver to set hide_titlebar_when_maximized directly on the MetaWindow without using any x calls, but the MetaWindow is only used by mutter to hide the titlebar for X11 apps and not for wayland apps.

@deadalnix
Copy link
Collaborator

I assume a native wayland app wouldn't use any kind of standard title bar, so not sure there is a way to collapse it anyway. Just like Chromium for instance, or recent gnome apps with all kind of features in their title, there is not much you can do (and that's fine, their title bar is utilized efficiently, rather than wasted).

@cesarizu
Copy link

I've only looked into gtk+ apps like gnome-terminal.

AFAIK Qt was implementing their own wayland protocol for SSD but I'm not sure if that's done and if mutter understands it and respects the hide_titlebar_when_maximized, or if the Qt app just switches to CSD when the compositor doesn't implement their protocol. See this for more info.

Also I believe that the rest of X11 apps running on wayland (like firefox, chrome) do respect the hide_titlebar_when_maximized option because mutter is painting their titlebar. Chrome is special, by default it requests not to be decorated and paints it's own titlebar.

TL;DR I think this needs to be solved first for gtk+ apps on wayland, then for other wayland apps. X11 apps on wayland are not a problem.

@hamiller
Copy link

Maybe here are some additional ideas worth mentioning (they use wmctrl). Haven't checked and Wayland is only mentioned in two sentences... but hey, just my 2 cent

@aldoridhoni
Copy link

aldoridhoni commented Nov 26, 2016

For those who wants to run gtk+ apps using x11(xwayland), use this command

export XDG_SESSION_TYPE=x11; export GDK_BACKEND=x11; export DISPLAY=:0; dbus-launch gnome-terminal 

@cesarizu
Copy link

cesarizu commented Nov 26, 2016

Thanks @hamiller ... that link was very useful. I found Florian Müllner's small test program and it allowed me to replicate the same non hiding problem on X11 too for gtk+ windows with csd. It also helped me verify that setting the hide_titlebar_when_maximized property on the GtkWindow does solve the problem on X11 and wayland for gtk+ windows with csd.

Now for the solution I'm starting to think that for those cases that don't hide the titlebar (gtk with csd) it would be easier to patch gtk and make hide_titlebar_when_maximized the default or maybe create a dconf setting. It might be easier than trying to make that property accessible from a gnome-shell extension.

@cesarizu
Copy link

cesarizu commented Nov 27, 2016

I've just posted a new patch for gtk at the gnome's bugzilla that adds a GSettings configuration option to hide windows' title bars when maximized. This takes care of gtk+ top level windows with csd (the ones that pixel saver cannot handle).

I built patched packages for openSUSE tumbleweed here:

https://build.opensuse.org/project/show/home:cesarizu:branches:GNOME:Factory EDIT: I'm in the process of updating this patches

After installing those packages you just need to run:

gsettings set org.gtk.Settings hide-titlebar-when-maximized true

After that (with or without pixel-saver) all gtk+ apps (csd and ssd) will hide their title bars when maximized.

@jhasse
Copy link

jhasse commented Nov 27, 2016

Wow. Thank you so much :)

@deadalnix
Copy link
Collaborator

@cesarizu Would that hide title bar for window that use the new gnome3 style title bar ? I don't think that' desirable because you'd lose functionality and you'd have to unmaximize, use the button and remaximize.

@cesarizu
Copy link

@deadalnix, no, it won't. It just takes care of normal old-style titlebars.

What this actually does is set the hide_titlebar_when_maximized property on all new windows when created. It's basically the same thing that pixel-saver does, but when the window is created and reading from dconf using GSettings.

@cesarizu
Copy link

cesarizu commented Nov 27, 2016

Basically patch # 1 (for mutter) allows pixel-saver to access hide_titlebar_when_maximized without the need of xprop or any other X11 tool. This is accompanied by the #98 PR.

Patch # 2 (gtk) sets the hide_titlebar_when_maximized on window creation so that all gtk windows with csd have their title hidden correctly when maximized (on wayland and X11).

There's still the question about other wayland apps, like qt wayland apps. I haven't tried yet any so I cannot comment on that.

@deadalnix
Copy link
Collaborator

deadalnix commented Nov 27, 2016

@cesarizu Awesome. Let's see how the upstream process goes.

Also, I noticed that the hide title bar behavior by default in gtk changed for window that are maximized left/right . Maybe a show_title_bar(true/false) would be more useful in the general case ?

@cesarizu
Copy link

@deadalnix I think it's a bug. Tiled windows should also hide their title bars as well. I'll try to post a new patch that fixes that case.

@deadalnix
Copy link
Collaborator

As far as Pixel saver is concerned, window that are maximized left/right shouldn't see their title bar disapear. At some point, they started to be, but I'm not sure what version changed this.

@jhasse
Copy link

jhasse commented Nov 27, 2016

I would also prefer if tiled windows keep their titlebar :)

@cesarizu
Copy link

cesarizu commented Nov 27, 2016

Looking at mutter's history there was a period of time (jun 2015 - jan 2016) that it didn't hide tiled windows title bars, but it was considered a bug and "fixed". The gtk code is really similar and they are interconnected, so I believe that this difference in behavior is just an overlook and the gtk developers meant to hide the title bars in both cases. Most tiling window managers do hide titlebars when windows are tiled, so I think this is was it's aimed for.

Mutter has a very limited tiling capability, but as @deadalnix said, a more general show/hide function for titlebars would allow better control of this case so extensions that want to control that more specifically, like this one, can do that.

In any case right now I can not find a way to access wayland gtk windows from a gnome-extension, so it's not possible to control those properties for those windows from the extension, that's why I created the dconf patch. Im waiting for some feedback from the gnome developers to see how I should proceed.

@phcerdan
Copy link

phcerdan commented Jun 23, 2017

Hi, great stuff, using wayland in gnome3 here. Do we still need your patch to set the hide-titlebar-when-maximized gtk property? Is it planned to be merged in gtk? Thanks

gsettings set org.gtk.Settings hide-titlebar-when-maximized true

@jhasse
Copy link

jhasse commented Jul 3, 2017

Yes. It is not planned to be merged, see https://bugzilla.gnome.org/show_bug.cgi?id=775061

@spacepluk
Copy link
Contributor

@jhasse I understood it would go into GTK+ 4, is that right?

@jhasse
Copy link

jhasse commented Jul 3, 2017

If I understand it correctly: No, Gtk+ 4 just removed the hide_titlebar_when_maximized property and "fixed" the bug by saying: "it works in Xorg but not Wayland? Well now it doesn't work in both, bug fixed!"

@afranke
Copy link

afranke commented Jul 3, 2017

The correct way to do it now would probably be to use CSS.

@spacepluk
Copy link
Contributor

That only works for gtk+ apps though :/

@afranke
Copy link

afranke commented Jul 3, 2017

Just like hide-titlebar-when-maximized did.

@pcercuei
Copy link

pcercuei commented Jul 3, 2017

This is annoying, this is honestly the only thing that prevents me from running always on Wayland now.

@spacepluk
Copy link
Contributor

Well at least it did work with X11, but now it won't work at all after GTK+ 4 which I also find very annoying. I guess we should be used to have features taken away by now...

I hope somebody finds a workaround :(

@zaphot
Copy link

zaphot commented Sep 22, 2017

Hi, first thanks for this wonderful screen-space-saving extension and it's unfortunate that it's not working on wayland.

Fortunately, someone posted a gtk.css config which completely removes titlebars by using negative margins and this works even on wayland:
https://joshtronic.com/2017/07/26/hide-title-bars-in-gnome-shell/

Titlebars are completely gone with this (I am using ubuntu gnome 17.04). However, one has to get used to it (tip: you can drag windows around by pressing alt and grabbing it with the mouse) but for me this solution is good enough. Maybe this addon could make use of theses css tricks.

@franglais125
Copy link

franglais125 commented Oct 9, 2017

I got a first part of this working in my fork, using the CSS style. The work is based off what was done in the "unite" extension.

It only works for title bars, not for the whole CSD bar (as it would remove too many tools). Comments appreciated.

[7059f4a]

@SavchenkoValeriy
Copy link

SavchenkoValeriy commented Sep 16, 2019

@franglais125 first of all, thank you for your work. I tried using the latest version on Fedora 30 (with Wayland) and after enabling pixel-saver it works for a little bit, and then hangs gnome shell so I can't move my mouse or switch to console.

@tallero
Copy link
Collaborator

tallero commented Oct 12, 2020

Right now pixel saver works well on X.org applications inside Wayland.

A feasible workaround for GTK3 applications (QT still uses X.org inside Shell wayland session) which still use a titlebar is to launch them with

GDK_BACKEND=x11 application_name

@tallero tallero added the workaround there's a workaround for this bug label Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement workaround there's a workaround for this bug
Projects
None yet
Development

No branches or pull requests