changeset 1479:1d414e81a099

FIXME: Workaround on GTK for Compiz not sending property notify events for certain window styles causing a deadlock. Implement a timeout and if the timeout expires push the event back.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 22 Dec 2011 12:09:43 +0000
parents 7216f4301364
children 559f434dcfbd
files gtk/dw.c gtk3/dw.c
diffstat 2 files changed, 33 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Thu Dec 22 09:53:02 2011 +0000
+++ b/gtk/dw.c	Thu Dec 22 12:09:43 2011 +0000
@@ -10126,12 +10126,16 @@
 
 union extents_union { guchar **gu_extents; unsigned long **extents; };
 static Atom extents_atom = 0;
+static time_t extents_time = 0;
 
 static Bool property_notify_predicate(Display *xdisplay, XEvent *event, XPointer window_id)
 {
    unsigned long *window = (unsigned long *)window_id;
-
-   if(event->xany.type == PropertyNotify && event->xany.window == *window && event->xproperty.atom == extents_atom)
+   time_t currtime = time(NULL);
+
+   /* If it is the event we are looking for... or if the timeout has expired */
+   if((event->xany.type == PropertyNotify && event->xany.window == *window && event->xproperty.atom == extents_atom) ||
+      (currtime - extents_time) > 1)
       return True;
    return False;
 }
@@ -10171,11 +10175,21 @@
       xevent.xclient.window = window_id;
       xevent.xclient.format = 32;
 
+      /* Send the property request */
       XSendEvent(xdisplay, xroot_window, False,
 		          (SubstructureRedirectMask | SubstructureNotifyMask),
                 &xevent);
-
+      
+      /* Record the request time */
+      time(&extents_time);
+      
+      /* Look for the property notify event */
       XIfEvent(xdisplay, &notify_xevent, property_notify_predicate, (XPointer)&window_id);
+      
+      /* If we didn't get the notification... put the event back onto the stack */
+      if(notify_xevent.xany.type != PropertyNotify || notify_xevent.xany.window != window_id
+         || notify_xevent.xproperty.atom != extents_atom)
+            XPutBackEvent(xdisplay, &notify_xevent);
    }
    
    /* Attempt to retrieve window's frame extents. */
--- a/gtk3/dw.c	Thu Dec 22 09:53:02 2011 +0000
+++ b/gtk3/dw.c	Thu Dec 22 12:09:43 2011 +0000
@@ -8511,12 +8511,16 @@
 
 union extents_union { guchar **gu_extents; unsigned long **extents; };
 static Atom extents_atom = 0;
+static time_t extents_time = 0;
 
 static Bool property_notify_predicate(Display *xdisplay, XEvent *event, XPointer window_id)
 {
    unsigned long *window = (unsigned long *)window_id;
-
-   if(event->xany.type == PropertyNotify && event->xany.window == *window && event->xproperty.atom == extents_atom)
+   time_t currtime = time(NULL);
+
+   /* If it is the event we are looking for... or if the timeout has expired */
+   if((event->xany.type == PropertyNotify && event->xany.window == *window && event->xproperty.atom == extents_atom) ||
+      (currtime - extents_time) > 1)
       return True;
    return False;
 }
@@ -8557,11 +8561,21 @@
       xevent.xclient.window = window_id;
       xevent.xclient.format = 32;
 
+      /* Send the property request */
       XSendEvent(xdisplay, xroot_window, False,
 		          (SubstructureRedirectMask | SubstructureNotifyMask),
                 &xevent);
 
+      /* Record the request time */
+      time(&extents_time);
+      
+      /* Look for the property notify event */
       XIfEvent(xdisplay, &notify_xevent, property_notify_predicate, (XPointer)&window_id);
+      
+      /* If we didn't get the notification... put the event back onto the stack */
+      if(notify_xevent.xany.type != PropertyNotify || notify_xevent.xany.window != window_id
+         || notify_xevent.xproperty.atom != extents_atom)
+            XPutBackEvent(xdisplay, &notify_xevent);
    }
    
    /* Attempt to retrieve window's frame extents. */