PCMan / gtk3-nocsd

A hack to disable gtk+ 3 client side decoration
GNU Lesser General Public License v2.1
320 stars 41 forks source link

Does not work with libgtk 3.14 #12

Closed pasky closed 9 years ago

pasky commented 9 years ago

Hi! I tried to use gtk3-nocsd with libgtk-3.14.5, which is the Debian Jessie version, to no avail, even though the README says "older than 3.16.1".

(Upgrading to libgtk 3.18.2 from Debian Unstable makes this work beautifully, though!)

chris-se commented 9 years ago

Oh, the README is out of date, it should work with all Gtk+3 versions released so far (obviously, CSDs were introduced with 3.10, so there's no effect before that version).

I have a Jessie system myself with Gtk+3 in version 3.14.5-1+deb8u1, and gtk3-nocsd (version 2) works fine here. What do you mean: "does not work?" How did you compile/install it? How are you running Gtk+3 programs?

pasky commented 9 years ago

I now tried downgrading back to 3.10 and gtk3-nocsd stopped working again. Stopped working == the app starts fine, gtk3-nocsd is preloaded, but it looks exactly like without nocsd, the wm toolbar is not shown.

I grabbed the latest master, make + make install, launching with exported LD_PRELOAD and GTK_CSD=0, ldd confirms it's preloaded, or trying to use the ./gtk3-nocsd wrapper. With gtk3 from unstable, the exact same way leads to the desired effect.

chris-se commented 9 years ago

I assume you mean 3.14, because Jessie doesn't come with 3.10. ;-)

What application are you testing this with? I'm testing this with gedit and nautilus - and with a Jessie system (amd64) and Jessie's Gtk+3/glib doing the same as you said it works for me...

pasky commented 9 years ago

Er, right, 3.14:

ii  libgtk-3-0:amd64                               3.14.5-1+deb8u1              amd64                        GTK+ graphical user interface library
ii  libgtk-3-bin                                   3.14.5-1+deb8u1              amd64                        programs for the GTK+ graphical user interface library
ii  libgtk-3-common                                3.14.5-1+deb8u1              all                          common files for the GTK+ graphical user interface library
ii  libgtk-3-dev:amd64                             3.14.5-1+deb8u1              amd64                        development files for the GTK+ library

I'm testing with evince and gedit:

ii  evince                                         3.14.1-2                     amd64                        Document (PostScript, PDF) viewer
ii  gedit                                          3.14.0-3                     amd64                        official text editor of the GNOME desktop environment

Both behave the same.

Any recommendations on how to debug why is nocsd not kicking in?

chris-se commented 9 years ago

Ok, first of all you can try the following (in the build directory of gtk3-nocsd master with it built):

./gtk3-nocsd env | grep LD_PRELOAD
./gtk3-nocsd env | grep GTK_CSD

that should give you something like

LD_PRELOAD=/path/to/libgtk3-nocsd.so.0
GTK_CSD=0

Verify that the /path/to/libgtk3-nocsd.so.0 exists. Also, are you preloading other things? This might be relevant. Also check that no older version of libgtk3-nocsd.so.0 is installed somewhere.

Then you could try to use gdb on gedit. Sample session on my system (same versions of gedit and libgtk-3*:

./gtk3-nocsd gdb --args gedit
[...]
(gdb) break gtk_window_set_titlebar
Function "gtk_window_set_titlebar" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (gtk_window_set_titlebar) pending.
(gdb) run
Starting program: /usr/bin/gedit 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffee422700 (LWP 29047)]
[New Thread 0x7fffecf53700 (LWP 29048)]

Breakpoint 1, gtk_window_set_titlebar (window=0x78f1f0, titlebar=0x80e190) at gtk3-nocsd.c:380
380     extern void gtk_window_set_titlebar (GtkWindow *window, GtkWidget *titlebar) {
(gdb) c
Continuing.

Breakpoint 1, 0x00007ffff5e16ba0 in gtk_window_set_titlebar () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
(gdb) c
Continuing.
[New Thread 0x7fffe7904700 (LWP 29049)]
[New Thread 0x7fffe649d700 (LWP 29050)]
[Thread 0x7fffe649d700 (LWP 29050) exited]
[Thread 0x7fffe7904700 (LWP 29049) exited]
[Thread 0x7fffecf53700 (LWP 29048) exited]
[Thread 0x7fffee422700 (LWP 29047) exited]
[Inferior 1 (process 29043) exited normally]
(gdb) quit

So two things here: first set the breakpoint (gdb will not find it initially), then run the program, and then it should hit the breakpoint twice: once in libgtk3-nocsd.so and once in the original gtk library. (c means continue execution in gdb) After the final c for continue the editor window should open and then I immediately close it, then exit gdb.

If the same thing happens on your system, then you know for sure that at least gtk3-nocsd's code is executed, and we then can figure out what's so different between our systems that it works for me and it doesn't for you. If on the other hand the debugger only breaks in the original gtk library, then we need to figure out why libgtk3-nocsd isn't used in your case.

Oh, and could you also run debsums libgtk-3-0? (You don't need to be root for that if it's installed.) To check whether the gtk library is actually the same as in the archive and nothing on your system has accidentally modified it or so? (dpkg-divert --list and check if it appears there - it shouldn't - is also a good idea.)

pasky commented 9 years ago

On Sat, Oct 17, 2015 at 03:38:04PM -0700, Christian Seiler wrote:

Ok, first of all you can try the following (in the build directory of gtk3-nocsd master with it built):

./gtk3-nocsd env | grep LD_PRELOAD
./gtk3-nocsd env | grep GTK_CSD

that should give you something like

LD_PRELOAD=/path/to/libgtk3-nocsd.so.0
GTK_CSD=0

That's right.

pasky@machine[1:0]~/src/gtk3-nocsd$ ./gtk3-nocsd env | grep LD_PRELOAD
LD_PRELOAD=/usr/local/lib/libgtk3-nocsd.so.0
pasky@machine[1:0]~/src/gtk3-nocsd$ ./gtk3-nocsd env | grep GTK_CSD
GTK_CSD=0

Verify that the /path/to/libgtk3-nocsd.so.0 exists. Also, are you preloading other things? This might be relevant. Also check that no older version of libgtk3-nocsd.so.0 is installed somewhere.

-rwxr-xr-x 1 root staff 94800 Oct 17 22:19 /usr/local/lib/libgtk3-nocsd.so.0

Then you could try to use gdb on gedit. Sample session on my system (same versions of gedit and libgtk-3*:

./gtk3-nocsd gdb --args gedit
[...]
(gdb) break gtk_window_set_titlebar
Function "gtk_window_set_titlebar" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (gtk_window_set_titlebar) pending.
(gdb) run
Starting program: /usr/bin/gedit 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffee422700 (LWP 29047)]
[New Thread 0x7fffecf53700 (LWP 29048)]

Breakpoint 1, gtk_window_set_titlebar (window=0x78f1f0, titlebar=0x80e190) at gtk3-nocsd.c:380
380     extern void gtk_window_set_titlebar (GtkWindow *window, GtkWidget *titlebar) {
(gdb) c
Continuing.

Breakpoint 1, 0x00007ffff5e16ba0 in gtk_window_set_titlebar () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
(gdb) c
Continuing.
[New Thread 0x7fffe7904700 (LWP 29049)]
[New Thread 0x7fffe649d700 (LWP 29050)]
[Thread 0x7fffe649d700 (LWP 29050) exited]
[Thread 0x7fffe7904700 (LWP 29049) exited]
[Thread 0x7fffecf53700 (LWP 29048) exited]
[Thread 0x7fffee422700 (LWP 29047) exited]
[Inferior 1 (process 29043) exited normally]
(gdb) quit

I get the very same output here (modulo pointer values, of course).

So gtk3-nocsd code is being executed.

Oh, and could you also run debsums libgtk-3-0? (You don't need to be root for that if it's installed.) To check whether the gtk library is actually the same as in the archive and nothing on your system has accidentally modified it or so? (dpkg-divert --list and check if it appears there - it shouldn't - is also a good idea.)

This all fits.

There's also another thing - probably more of a point of interest for bystanders. Even without nocsd, with the libgtk from unstable (N.B. I tested all of the above with libgtk from Jessie) the CSD is somehow fixed so that I can move and resize the windows from fluxbox using the CSD.

chris-se commented 9 years ago

Well, you could try to do the following: run the same gdb command again (from the directory of where you've compiled gtk3-nocsd), set the same breakpoint, and then once you've reached the gtk_window_set_titlebar function, step through that with gdb's next command (you can also use n) - until you reach the end of the function.

Also, while you're in that function, try issuing the following debugger commands:

print is_compatible_gtk_version()
print are_csd_disabled()

(Note that either command might cause a dconf warning about a timeout, ignore that, what I'm interested in is whether they return 0 or 1 - it should be 1 in both cases if you disable CSDs.)

Ideally, before you do that, recompile the library without optimization, that makes debugging easier (e.g. CFLAGS="-O0 -ggdb" make clean all && sudo make install).

Then, post the output here to see what codepath is taken on your system. Ideally it should execute the code past the orig_impl: label and ignore the other two paths (for disabled and for gtk 3.16+).

pasky commented 9 years ago

Hi! Both functions return true and the orig_impl code block gets run.

pasky commented 9 years ago

Also verified that gdk_screen_is_composited() returns false and gdk_window_set_decorations() calls the orig with GDK_DECOR_ALL.

chris-se commented 9 years ago

Ok, so I have no idea what's going on there. I've installed fluxbox on my system (because I thought maybe it's the window manager) but starting gedit works just fine here.

I've also tried the following: install a clean VM with Jessie, install fluxbox and then a) copy libgtk3-nocsd.so.0 + the wrapper script from my own system onto that and just try (without having the development packages of gtk etc. installed) to run it and b) install the development packages of gtk etc. and then compile it inside the VM. In both cases, under fluxbox, gtk3-nocsd just works when I try to run gedit.

I'm also kind of out of ideas - I basically have the same system here (Jessie, amd64, gtk3-nocsd master), even tried the same window manager as you, even tried this in a clean VM - and I just can't reproduce it. :-(

Please try to reproduce this in a clean virtual machine running Jessie. If you can't, then you need to figure out what the difference is between your own system and the VM. If you can, could you somehow make this available to me? (Or at least the instructions required to create it, because a VM with a GUI will probably be quite large and not ideal for sending that to me on the internet.)

pasky commented 9 years ago

Hi! Thanks for the investigation. I'm afraid I probably won't go through the VM step, especially as gtk3-nocsd is not essential for me anymore given that things work with libgtk 3.18. Maybe someone else comes along with the same problem...

chris-se commented 9 years ago

Ok, closing this issue as unreproducible - if somebody else also has this problem and is willing to debug this, please reopen.

yuphorian6 commented 8 years ago

I have debian 8.2 jessie stable with cinnamon desktop environment and up-to-date packages.

I installed packages pkg-config, libgtk-3-dev, libgirepository1.0-dev Downloaded the git source and compiled with make.

Now running an app from script like ./gtk3-nocsd gedit will work as expected.

But after adding the environment variables to ~/.bashrc and reboot, the window manager doesn't appear. The environment variable are fine. Checked the values of $GTK_CSD and $LD_PRELOAD from terminal and they are fine. Even opening an app (gedit) from terminal enables the window manager.

But when opening the app from launcher, the window manager doesn't appear.

yuphorian6 commented 8 years ago

Tried this in debian testing stretch as well with cinnamon and xfce desktop environments, and the same issue persists with both desktop environments.

When opening gtk3 app from terminal with GTK_CSD and LD_PRELOAD variables, the window manager works fine. But when opening the app from launcher with variables in bashrc , window manager doesn't appear.