]> Pileus Git - ~andy/gtk/commitdiff
Recheck _NET_SUPPORTING_WM_CHECK every now and then to avoid getting stuck
authorMatthias Clasen <mclasen@redhat.com>
Sun, 4 Jan 2009 04:50:36 +0000 (04:50 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sun, 4 Jan 2009 04:50:36 +0000 (04:50 +0000)
2009-01-03  Matthias Clasen  <mclasen@redhat.com>

        * gdk/x11/gdkscreen-x11.h:
        * gdk/x11/gdkevents-x11.c (fetch_net_wm_check_window): Recheck
        _NET_SUPPORTING_WM_CHECK every now and then to avoid getting
        stuck on the id of a former wmcheck window that got reused by
        another client (see RH bug 471927)

svn path=/trunk/; revision=22058

ChangeLog
gdk/x11/gdkevents-x11.c
gdk/x11/gdkscreen-x11.h

index 064fb7cddeed554a84c11341d2675f9d5f27eb84..d3c3d29754ba86e827387058f96e5ca38111ba27 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-01-03  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/x11/gdkscreen-x11.h:
+       * gdk/x11/gdkevents-x11.c (fetch_net_wm_check_window): Recheck
+       _NET_SUPPORTING_WM_CHECK every now and then to avoid getting
+       stuck on the id of a former wmcheck window that got reused by
+       another client (see RH bug 471927)
+
 2009-01-03  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtktreesortable.c: Improve the docs
index 2cd817b23858be83c4dc12f383777d148cd795d7..a335feefb6e0ad3cf14c52dffde8f3e8fb0ce44a 100644 (file)
@@ -2612,23 +2612,20 @@ fetch_net_wm_check_window (GdkScreen *screen)
   gulong bytes_after;
   guchar *data;
   Window *xwindow;
-  
-  /* This function is very slow on every call if you are not running a
-   * spec-supporting WM. For now not optimized, because it isn't in
-   * any critical code paths, but if you used it somewhere that had to
-   * be fast you want to avoid "GTK is slow with old WMs" complaints.
-   * Probably at that point the function should be changed to query
-   * _NET_SUPPORTING_WM_CHECK only once every 10 seconds or something.
-   */
+  GTimeVal tv;
   
   screen_x11 = GDK_SCREEN_X11 (screen);
   display = screen_x11->display;
 
   g_return_if_fail (GDK_DISPLAY_X11 (display)->trusted_client);
   
-  if (screen_x11->wmspec_check_window != None)
-    return; /* already have it */
-  
+  g_get_current_time (&tv);
+      
+  if (ABS  (tv.tv_sec - screen_x11->last_wmspec_check_time) < 15)
+    return; /* we've checked recently */
+
+  screen_x11->last_wmspec_check_time = tv.tv_sec;
+
   data = NULL;
   XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), screen_x11->xroot_window,
                      gdk_x11_get_xatom_by_name_for_display (display, "_NET_SUPPORTING_WM_CHECK"),
@@ -2644,6 +2641,12 @@ fetch_net_wm_check_window (GdkScreen *screen)
 
   xwindow = (Window *)data;
 
+  if (screen_x11->wmspec_check_window == *xwindow)
+    {
+      XFree (xwindow);
+      return;
+    }
+
   gdk_error_trap_push ();
   
   /* Find out if this WM goes away, so we can reset everything. */
index c5b191095b5929844ec144167b0b57184352d4f5..4ccc795f5684eac789c7426a00e246ff5925a3a8 100644 (file)
@@ -57,6 +57,7 @@ struct _GdkScreenX11
   GdkWindow *root_window;
 
   /* Window manager */
+  long last_wmspec_check_time;
   Window wmspec_check_window;
   char *window_manager_name;
   /* TRUE if wmspec_check_window has changed since last