GNOME Bugzilla – Bug 163910
gtk+ does not respect NETWM VROOTS when querying for frame geometry
Last modified: 2005-01-19 19:56:44 UTC
Please describe the problem: gtk+ does not respect NETWM VROOTS when querying for frame geometry. I have included a patch for this to make it respect VROOTS in the "other information" section. Steps to reproduce: run gimp under any wm that uses virtual roots (and uses netwm to advertise them) Actual results: some apps (like gimp) do not remember their geometry corectly Expected results: they should remember their geometry correctly. Does this happen every time? yes. fixed. see patch. :) Other information: --- gtk+-2.4.14/gdk/x11/gdkdisplay-x11.c.BEFORE 2005-01-13 16:16:38.000000000 +0900 +++ gtk+-2.4.14/gdk/x11/gdkdisplay-x11.c 2005-01-13 16:16:53.000000000 +0900 @@ -82,6 +82,7 @@ "_NET_WM_WINDOW_TYPE", "_NET_WM_WINDOW_TYPE_NORMAL", "_NET_WM_USER_TIME", + "_NET_VIRTUAL_ROOTS", }; GType --- gtk+-2.4.14/gdk/x11/gdkwindow-x11.c.BEFORE 2005-01-13 16:31:30.000000000 +0900 +++ gtk+-2.4.14/gdk/x11/gdkwindow-x11.c 2005-01-13 17:31:28.000000000 +0900 @@ -2819,8 +2819,15 @@ Window xparent; Window root; Window *children; + Window *vroots; + Atom type_return; unsigned int nchildren; - + unsigned int nvroots; + unsigned long nitems_return; + unsigned long bytes_after_return; + int format_return; + int i; + g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (rect != NULL); @@ -2846,7 +2853,21 @@ return; gdk_error_trap_push(); - + + /* use NETWM_VIRTUAL_ROOTS if available */ + nvroots = 0; + vroots = NULL; + if (XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), + GDK_WINDOW_XID(gdk_screen_get_root_window (GDK_WINDOW_SCREEN (window))), + gdk_x11_get_xatom_by_name_for_display (gdk_drawable_get_display (window), "_NET_VIRTUAL_ROOTS"), + 0, 0x7fffffff, False, XA_WINDOW, &type_return, + &format_return, &nitems_return, &bytes_after_return, + (unsigned char **)(&vroots)) + == Success) + { + if ((type_return == XA_WINDOW) && (format_return == 32) && (vroots)) + nvroots = nitems_return; + } xparent = GDK_WINDOW_XID (window); do { @@ -2858,8 +2879,19 @@ if (children) XFree (children); + /* check virtual roots */ + for (i = 0; i < nvroots; i++) + { + if (xparent == vroots[i]) + { + xparent = root; + break; + } + } + if (xparent == root) + break; } - while (xparent != root); + while (1); if (xparent == root) { @@ -2874,6 +2906,8 @@ rect->height = wh; } } + if (vroots) + XFree(vroots); fail: gdk_error_trap_pop ();
Does any wm besides enlightenment use virtual roots ? Note that we do look for ENLIGHTENMENT_DESKTOP in gdk_window_get_deskrelative_origin(), so this should probably cleaned up at the same time.
but gdk_window_get_deskrelative_origin(),() is depreciated and not enabled in gtk2.x the new gtk2 function i patched doesnt even know vroots exist :) thus the above patch. this follows the NETWM extended hints system (freedesktop.org...) so it should work with any wm that uses that system. :) the above patch should solve it just nicely.
still, i would be curious if any wm actually uses it, besides enlightenment...
gdk_window_get_frame_extents () returns the wrong result under enlightenment, and raster claims that his patch will fix it (or at least shows how it can be fixed). Currently the wrong results from this function break eclipse (https://bugs.eclipse.org/bugs/show_bug.cgi?id=77267).
2005-01-19 Matthias Clasen <mclasen@redhat.com> * gdk/x11/gdkdisplay-x11.c: Precache the _NET_VIRTUAL_ROOTS atom. * gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents): Support _NET_VIRTUAL_ROOTS. (#163910, Carsten Haitzler)