diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2008-06-02 21:57:51 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2008-06-02 21:57:51 +0000 |
commit | 98f234e73ab7ef84af5027c1dd58ce516aff19d6 (patch) | |
tree | 22db8ea5227bae052c0f4813ef5b46ec35a785eb | |
parent | d88a3d3f7f91a1b5cdb5f6c5a2a3622c52ecb9c2 (diff) | |
download | gdk-pixbuf-98f234e73ab7ef84af5027c1dd58ce516aff19d6.tar.gz |
Bug 524110 - Gdk should not assume reparenting WMs when retrieving
window frame extents
* gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents):
Use _NET_FRAME_EXTENTS, if available. Patch by Danny Baumann.
svn path=/branches/gtk-2-12/; revision=20280
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 58 |
2 files changed, 62 insertions, 6 deletions
@@ -2,6 +2,16 @@ Merge from trunk: + Bug 524110 - Gdk should not assume reparenting WMs when retrieving + window frame extents + + * gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents): + Use _NET_FRAME_EXTENTS, if available. Patch by Danny Baumann. + +2008-06-02 Matthias Clasen <mclasen@redhat.com> + + Merge from trunk: + Bug 522269 - Evince windows sometimes incorrectly unmaximized, caused by missing flag initialization diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 4c476a8c1..cc1f6fd7e 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -3424,6 +3424,7 @@ gdk_window_get_frame_extents (GdkWindow *window, gint i; guint ww, wh, wb, wd; gint wx, wy; + gboolean got_frame_extents = FALSE; g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (rect != NULL); @@ -3449,14 +3450,59 @@ gdk_window_get_frame_extents (GdkWindow *window, if (GDK_WINDOW_DESTROYED (private)) return; + nvroots = 0; + vroots = NULL; + gdk_error_trap_push(); - /* use NETWM_VIRTUAL_ROOTS if available */ display = gdk_drawable_get_display (window); - root = GDK_WINDOW_XROOTWIN (window); + xwindow = GDK_WINDOW_XID (window); - nvroots = 0; - vroots = NULL; + /* first try: use _NET_FRAME_EXTENTS */ + if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), xwindow, + gdk_x11_get_xatom_by_name_for_display (display, + "_NET_FRAME_EXTENTS"), + 0, G_MAXLONG, False, XA_CARDINAL, &type_return, + &format_return, &nitems_return, &bytes_after_return, + &data) + == Success) + { + if ((type_return == XA_CARDINAL) && (format_return == 32) && + (nitems_return == 4) && (data)) + { + guint32 *ldata = (guint32 *) data; + got_frame_extents = TRUE; + + /* try to get the real client window geometry */ + if (XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xwindow, + &root, &wx, &wy, &ww, &wh, &wb, &wd)) + { + rect->x = wx; + rect->y = wy; + rect->width = ww; + rect->height = wh; + } + + /* _NET_FRAME_EXTENTS format is left, right, top, bottom */ + rect->x -= ldata[0]; + rect->y -= ldata[2]; + rect->width += ldata[0] + ldata[1]; + rect->height += ldata[2] + ldata[3]; + } + + if (data) + XFree (data); + } + + if (got_frame_extents) + goto out; + + /* no frame extents property available, which means we either have a WM that + is not EWMH compliant or is broken - try fallback and walk up the window + tree to get our window's parent which hopefully is the window frame */ + + /* use NETWM_VIRTUAL_ROOTS if available */ + root = GDK_WINDOW_XROOTWIN (window); if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), root, gdk_x11_get_xatom_by_name_for_display (display, @@ -3482,7 +3528,7 @@ gdk_window_get_frame_extents (GdkWindow *window, if (!XQueryTree (GDK_DISPLAY_XDISPLAY (display), xwindow, &root, &xparent, &children, &nchildren)) - goto fail; + goto out; if (children) XFree (children); @@ -3508,7 +3554,7 @@ gdk_window_get_frame_extents (GdkWindow *window, rect->height = wh; } - fail: + out: if (vroots) XFree (vroots); |