elementary / gala

Gala Window Manager for elementary OS and Pantheon
https://elementary.io
GNU General Public License v3.0
272 stars 77 forks source link

Windows requesting decorations get double decorations #244

Closed aggalex closed 3 years ago

aggalex commented 6 years ago

When I ran PlayOnLinux on elementary OS Juno build I have I noticed gala givesit two decorations: one normally and one around the whole window, including the shadows. It is really ugly, and don't know if it applies to other apps.

screenshot from 2018-05-07 08 47 22

PS: Tried to see if other apps have the same problem, mainly non GTK3 apps, but the ones I tried (LibreOffice, VLC & "about XFCE4" that I found in the appcenter) don't have such problems. I believe it has to do with the too-small-default-sized window of it, thus making gala think elements go out of it and thus making gala think it needs another decoration for it as a second widget border. You can see how the list widget on the "PlayOnLinux Install menu" overlaps the it's parent window.

screenshot from 2018-05-07 09 12 44

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/58036486-windows-requesting-decorations-get-double-decorations?utm_campaign=plugin&utm_content=tracker%2F62872462&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F62872462&utm_medium=issues&utm_source=github).
davidmhewitt commented 6 years ago

I can confirm this, although I'm not sure whether it's a gala issue, a stylesheet issue or an issue with the applications themselves.

The further information I can add is that this seems to affect wxPython applications. For example, you can run the wxPython "Hello, World" application from their website and see the same effect: https://www.wxpython.org/pages/overview/#hello-world

aggalex commented 6 years ago

Perhaps there is a way to patch it around, after all that problem didn't exist on Loki.

Edit: As I said earlier, widgets tend to pop out of the parent window in PlayOnLinux, and seems like this is also the case with wxPython apps, since they also have the same problems. To confirm my assumption I will try to make a wxPython app with something very long that violates the window's boundaries, and see if the second boundary gala applies will cut the widget. If yes, then my assumption is correct, and this might be an interesting clue for you. Will do when I find the time.

EDIT: It's been quite a while and I can't seem to find sufficient time to try this. I think I'll call this off.

lsrzj commented 6 years ago

Not only POL, MySQL Workbench too, and with the latest version, I'm using Loki from a clean installation. And it always happen in child windows, not on main windows.

captura de tela de 2018-07-12 10-56-27

davidmhewitt commented 6 years ago

Further information on this: I can also reproduce this issue in Eclipse IDE, only with child windows like the above comment about MySQL workbench.

I've done some testing and ruled out the elementary stylesheet by running both Ubuntu Budgie and Ubuntu GNOME (both 18.04) and using the elementary stylesheet. In these cases, the issue cannot be reproduced. So it's something in the window manager or desktop environment.

The MySQL workbench case is interesting though, as I think that's a native GTK3 app, so I'll have to do a bit more digging into that one and see if there's anything obvious there.

apellizcos commented 6 years ago

Para cuando una solución?

cmcgarry commented 5 years ago

I'm seeing this issue with Juno now since recently doing a clean install. Used to run Playonlinux on Loki just fine. Any suggestions?

rwoolf commented 5 years ago

I'm noticing the same problem with POL and Eclipse on Juno. It seems there is a high percentage of apps that have this problem. With POL it makes the app non functional.

davidmhewitt commented 5 years ago

Found out some more information on this today. The affected applications are requesting extra window decorations via legacy Motif Window Manager hints. It's possible to build a Vala/GTK3 sample that reproduces the issue with the following code:

public class Application : Gtk.Window {
    public Application () {
        window_position = Gtk.WindowPosition.CENTER;
        set_default_size (350, 70);

        realize.connect (() => {
            get_window ().set_decorations (Gdk.WMDecoration.ALL);
        });
    }

    public static int main (string[] args) {
        Gtk.init (ref args);

        Application app = new Application ();
        app.show_all ();
        Gtk.main ();
        return 0;
    }
}

Still need to figure out why Gala does stuff with these when GNOME shell and Budgie don't.

Jiab77 commented 5 years ago

Same issue using the BOINC Manager Application.

I guess it also use wxPython.

Jiab77 commented 5 years ago

There is another open issue concerning the same problem: https://github.com/elementary/gala/issues/299

Jiab77 commented 5 years ago

@davidmhewitt Loki is not impacted. So by comparing changes done you should be able to see what's causing this issue?

MichelFrade commented 5 years ago

Same issue using Dbeaver 5.2.4 (version 5.2.3 OK), Eclipse and Play on Linux.

davidmhewitt commented 5 years ago

Some further information: This does not appear to be caused by Gala. The previous testing I've done with GNOME shell and Budgie have been under Ubuntu GNOME and Ubuntu Budgie respectively, and windows do not get double decorations there.

However, if you install and run a GNOME session on elementary (still using the stylesheet and config, etc...), you still get the double decorations. I even installed an unpatched version of mutter and this still happens.

So it would appear that the issue lives in some config or other patched packages rather than Gala itself, as it can be reproduced with vanilla Mutter running on elementary.

Jiab77 commented 5 years ago

@davidmhewitt The issue was also present in the beta versions of Juno. So I think it was introduced again during the development of Juno. I never had this issue while running Loki. Same goes with GNOME Shell as you said, I didn't had this issue too.

davidmhewitt commented 5 years ago

Okay, found the cause.

There's a shell script (/etc/profile.d/gtk-csd.sh) that exports GTK_CSD=1. I would highly recommend not deleting this shell script as it makes all of the dialog boxes look a bit weird and breaks the open file/folder dialog in some cases.

But, if you have an application that's experiencing this issue, run it with GTK_CSD=0 name-of-double-decorations-app, and this should resolve the issue. (e.g. GTK_CSD=0 eclipse)

MichelFrade commented 5 years ago

Other software I use at work has presented this problem. SmartSVN

captura de tela de 2018-12-05 11-19-50

megatux commented 5 years ago

PlayOnLinux, smartsvn, Eclipse, dbeaver are all Java apps and, if I'm not wrong, using the same graphics toolkit, SWT (that uses Gtk+ in Linux). I think the problem lies there.

megatux commented 5 years ago

Could Gala check if the app is using CSD api? maybe some window property, like the ones listed with xprop command?. e.g running dbeaver with & without GTK_CSD=0, respectively, gives me differences captura realizada el 2018-12-11 18 54 15

davidmhewitt commented 5 years ago

As I have written above, this is not caused by Gala, and trying to do anything in Gala to fix this would be really hacky if not impossible.

Fixing this involves patching GTK.

In vanilla GNOME, dialogs are coded to have CSD by default because they want put the action buttons in the headerbar (e.g. in the save dialog, the save button is in the top right of the window, in the titlebar). However, when you change the GTK setting that stops them from being in the headerbar (because this doesn't meet elementary UI guidelines), dialog windows become server side decorated by default, this is hardcoded into GTK.

So, to enforce CSD on dialogs, elementary exports GTK_CSD=1 in the session, and either GTK or Mutter doesn't handle this well.

megatux commented 5 years ago

I'm not sure if I follow you but if there is no way to have both apps with AND without CSD at the same time, for the same GTK 3.x version then I think it's a bug that should be fixed. I assume there is an open GTK issue for this.

aggalex commented 5 years ago

Oops my fault for closing the issue... sorry...

Sticcia commented 5 years ago

Thanks @davidmhewitt for the workaround For those wondering how to change the .desktop file appropriately, set: Exec=env GTK_CSD=0 <executable path> For example for Eclipse I did this: Exec=env GTK_CSD=0 /opt/eclipse/eclipse

kkinder commented 5 years ago

There's a shell script (/etc/profile.d/gtk-csd.sh) that exports GTK_CSD=1. I would highly recommend not deleting this shell script as it makes all of the dialog boxes look a bit weird and breaks the open file/folder dialog in some cases.

It still seems to me the solution should be deleting /etc/profile.d/gtk-csd.sh while patching whatever depends on that environment variable being set to not.

I'd also add, it might be worth reconsidering the low priority status of the ticket. As far as I can tell, this affects any Java application on Elementary OS. It would be lovely if there were native apps for everything, but that's just not the case, and most people at some point need to use Java software in the course of their jobs. Or even to play a movie on their TV across the house.

bilelmoussaoui commented 5 years ago

That's probably the proper solution to this issue https://github.com/elementary/stylesheet/issues/468 (Haven't tried it).

SyntevoAlex commented 5 years ago

Related SWT issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=542451

SyntevoAlex commented 5 years ago

For reference, here's a GTK snippet written in C that shows the problem:

#include <gtk/gtk.h>

int main(int argc, char* argv[])
{
    gtk_init(&argc, &argv);

    // With 0, it works fine.
    // With 1, a "ghost" window appears around the expected window. 
    printf("GTK_CSD=%s\n", g_getenv("GTK_CSD"));

    GtkWidget* shellHandle = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_show(shellHandle);
    g_signal_connect(shellHandle, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    GdkWindow* gdkResource = gtk_widget_get_window(shellHandle);
    gdk_window_set_decorations(gdkResource, GDK_DECOR_MINIMIZE);

    gtk_main();
    return 0;
}

This is a very reduced code similar to what SWT does. The same problem is seen on Ubuntu with export GTK_CSD=1

ericwill commented 5 years ago

Hi, SWT-GTK maintainer here.

The reason we set this flag is that SWT supports various different style bit combinations for our Shells. The SWT style bits map to the GDK ones and then we set them via gdk_window_set_decorations().

Now, I am wondering why GTK_CSD=1 is causing the problem here, because the GTK docs state:

The default value of this environment variable is 1. If changed to 0, this disables the default use of client-side decorations on GTK+ windows, thus making the window manager responsible for drawing the decorations of windows that do not have a custom titlebar widget. CSD is always used for windows with a custom titlebar widget set, as the WM should not draw another titlebar or other decorations around the custom one.

If GTK_CSD is 1 by default, elementaryOS setting it in that script shouldn't cause any different behaviour. Is it possible this is a theming related issue as suggested a few comments above? Is it reproducible when running the Adwaita theme (default GTK theme shipped with GTK)? I am going to try and reproduce the issue on my Fedora 29 box with GNOME and export GTK_CSD=1.

ericwill commented 5 years ago

I can confirm the issue does not reproduce natively using GNOME, Fedora 29, with both the Adwaita and Clearlooks-phenix themes. GTK_CSD=1 or GTK_CSD=0 makes no difference.

SyntevoAlex commented 5 years ago

Reproducible on Fedora if you also export GDK_BACKEND=x11.

ericwill commented 5 years ago

Ah yes I forgot to mention I am on Wayland.

kapildverma commented 5 years ago

Any update about fix for this issue? I am facing the same issue with Eclipse on Elementary Juno:

image

SyntevoAlex commented 5 years ago

I fixed the problem in SWT: https://bugs.eclipse.org/bugs/show_bug.cgi?id=542451 Should be released with next Eclipse version.

novusabeo commented 5 years ago

Having this same issue. I see there is a workaround but I'm not exactly sure how to go about it --- makes certain "non-curated" apps unusable for me.

echavez2623 commented 5 years ago

Pueden crear un script y pegarlo en /usr/share/playonlinux/run.sh que contenga:

Exex=env GTK_CSD=0 /usr/share/playonlinux/playonlinux

Después editan su lanzador de playonlinux y cambian las variables por /usr/share/playonlinux/./run.sh

Solo desactivan en el lanzador que no habrá la terminal para ejecutarlo.

Así me ah estado funcionando normalmente.

ajkr196 commented 5 years ago

Can we expect fix for this in the near future update? Or it will be released in next version? In 6?

a-tokarev commented 5 years ago

I have this issue in DisplayCAL calibration software. I have reported it to the developer. His reply was:

Hi, not fixable by me:

#!/usr/bin/env python2
import wx
app = wx.App(0)
f = wx.Frame(None)
f.Show()
app.MainLoop()

Please report upstream to python-wxgtk3.0 package.

ajkr195 commented 5 years ago

So there is no possibility of its fix with regular updates?

yozachar commented 5 years ago

Thanks @davidmhewitt for the workaround For those wondering how to change the .desktop file appropriately, set: Exec=env GTK_CSD=0 <executable path> For example for Eclipse I did this: Exec=env GTK_CSD=0 /opt/eclipse/eclipse

Worked in eOS 5.0 Juno

PlayOnLinux Modified Desktop Entry

[Desktop Entry]
Version=1.0
Name=PlayOnLinux
Comment=Front-end application for the wine
Type=Application
Exec=env GTK_CSD=0 playonlinux %F
Icon=playonlinux
Categories=Utility;Emulator;
cmcgarry commented 5 years ago

This worked for me as well. Finally, PlayOnLinux without the extra window.

Thank you!

Thanks @davidmhewitt for the workaround For those wondering how to change the .desktop file appropriately, set: Exec=env GTK_CSD=0 <executable path> For example for Eclipse I did this: Exec=env GTK_CSD=0 /opt/eclipse/eclipse

Worked in eOS 5.0 Juno

PlayOnLinux Modified Desktop Entry

[Desktop Entry] Version=1.0 Name=PlayOnLinux Comment=Front-end application for the wine Type=Application Exec=env GTK_CSD=0 playonlinux %F Icon=playonlinux Categories=Utility;Emulator;

Akryum commented 5 years ago

Just to report it's still an issue on DBeaver, making it unusable (some buttons on dialogs are hidden no matter the size of the window).

aggalex commented 5 years ago

@Akryum you can use the suggested workaround: add env GTK_CSD=0 before everything else inside the exec entry inside DBeaver's application file, which is inside /usr/share/applications

So, eg: Exec=blahblah %U should become Exec=env GTK_CSD=0 blahblah %U. Make sure to change blahblah %U with whatever the Exec entry had before you edited it.

Akryum commented 5 years ago

Yeah I did that, but still just a workaround :(

aggalex commented 5 years ago

@Akryum better than nothing. Bear with, it at least for now. I've done this with POL, and didn't have to do anything else ever since, so I don't think it's such an annoying workaround.

Akryum commented 5 years ago

It's pretty annoying, since I have to do it again every time I update DBeaver :sweat:

Akryum commented 5 years ago

I have just hit another issue: with the env GTK_CSD=0 workaround, DBeaver can't open System's File select dialog. For example, I tried executing a huge SQL script on a database:

Screenshot from 2019-07-26 12-27-21

The folder icon does nothing when I add env GTK_CSD=0 to launch DBeaver, but it opens the file select dialog when I don't use the workaround -- the DBeaver dialog still being unusable because the action buttons are below the visible area of the dialog.

Is there anything else I can try?

amrit9193 commented 4 years ago

I am not a developer, just a regular user using Hera recently upgraded from Juno. I am seeing this problem for Veracrypt and Youtube-dl-gui. Both these program show the following when started form terminal.

** BUG In pixman_region32_init_rect: Invalid rectangle passed Set a breakpoint on '_pixman_log_error' to debug**

\I have also recently used pop OS! and this problem doesn't appear there.