[gtk+] x11: add missing checks that a hint is supported



commit 2fcbe3a9b44491059170b71f75e07b3b24138c4a
Author: Geoff Reedy <geoff programmer-monk net>
Date:   Wed Jan 9 21:40:04 2013 -0700

    x11: add missing checks that a hint is supported
    
    Before acting on any hint that is set by the window manager we must
    first check that the hint is supported by the current window manager.
    Checking that a property has a value is insufficient as it may have
    been set by a previous window manager which did support the hint.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691515

 gdk/x11/gdkscreen-x11.c |    8 ++++++++
 gdk/x11/gdkwindow-x11.c |   12 +++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index a6d8ba6..b5767b5 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -280,6 +280,10 @@ get_current_desktop (GdkScreen *screen)
   unsigned char *data_return = NULL;
   int workspace = 0;
 
+  if (!gdk_x11_screen_supports_net_wm_hint (screen,
+                                            gdk_atom_intern_static_string ("_NET_CURRENT_DESKTOP")))
+    return workspace;
+
   display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
   win = XRootWindow (display, GDK_SCREEN_XNUMBER (screen));
 
@@ -330,6 +334,10 @@ get_work_area (GdkScreen    *screen,
   area->width = gdk_screen_get_width (screen);
   area->height = gdk_screen_get_height (screen);
 
+  if (!gdk_x11_screen_supports_net_wm_hint (screen,
+                                            gdk_atom_intern_static_string ("_NET_WORKAREA")))
+    return;
+
   if (workarea == None)
     return;
 
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 150f58e..70a6ba0 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -1738,7 +1738,9 @@ static void
 move_to_current_desktop (GdkWindow *window)
 {
   if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
-					   gdk_atom_intern_static_string ("_NET_WM_DESKTOP")))
+					   gdk_atom_intern_static_string ("_NET_WM_DESKTOP")) &&
+      gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
+					   gdk_atom_intern_static_string ("_NET_CURRENT_DESKTOP")))
     {
       Atom type;
       gint format;
@@ -2717,7 +2719,9 @@ gdk_x11_window_get_frame_extents (GdkWindow    *window,
   xwindow = GDK_WINDOW_XID (window);
 
   /* first try: use _NET_FRAME_EXTENTS */
-  if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), xwindow,
+  if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
+                                           gdk_atom_intern_static_string ("_NET_FRAME_EXTENTS")) &&
+      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,
@@ -2764,7 +2768,9 @@ gdk_x11_window_get_frame_extents (GdkWindow    *window,
   /* use NETWM_VIRTUAL_ROOTS if available */
   root = GDK_WINDOW_XROOTWIN (window);
 
-  if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), root,
+  if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
+                                           gdk_atom_intern_static_string ("_NET_VIRTUAL_ROOTS")) &&
+      XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), root,
 			  gdk_x11_get_xatom_by_name_for_display (display, 
 								 "_NET_VIRTUAL_ROOTS"),
 			  0, G_MAXLONG, False, XA_WINDOW, &type_return,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]