]> Dogcows Code - chaz/openbox/blobdiff - openbox/grab.c
grab enter/leave events during mouse grabs and pass events along still during the...
[chaz/openbox] / openbox / grab.c
index 991956da622b291e9ab4a05f5a02a10f086a9de5..a8a6200efa246b62e12bce1192ac90427789b37d 100644 (file)
@@ -26,7 +26,8 @@
 #include <glib.h>
 #include <X11/Xlib.h>
 
-#define GRAB_PTR_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
+#define GRAB_PTR_MASK (ButtonPressMask | ButtonReleaseMask | \
+                       PointerMotionMask | EnterWindowMask | LeaveWindowMask)
 #define GRAB_KEY_MASK (KeyPressMask | KeyReleaseMask)
 
 #define MASK_LIST_SIZE 8
@@ -41,8 +42,16 @@ static Time  grab_time = CurrentTime;
 static Time ungrab_time()
 {
     Time t = event_curtime;
-    if (!(t == 0 || event_time_after(t, grab_time)))
-        t = grab_time;
+    if (!(t == CurrentTime || event_time_after(t, grab_time)))
+        /* When the time moves backward on the server, then we can't use
+           the grab time because that will be in the future. So instead we
+           have to use CurrentTime.
+
+           "XUngrabPointer does not release the pointer if the specified time
+           is earlier than the last-pointer-grab time or is later than the
+           current X server time."
+        */
+        t = CurrentTime; /*grab_time;*/
     return t;
 }
 
@@ -88,7 +97,7 @@ gboolean grab_pointer(gboolean grab, ObCursor cur)
     if (grab) {
         if (pgrabs++ == 0) {
             ret = XGrabPointer(ob_display, screen_support_win,
-                               False, GRAB_PTR_MASK, GrabModeAsync,
+                               True, GRAB_PTR_MASK, GrabModeAsync,
                                GrabModeAsync, None,
                                ob_cursor(cur), event_curtime) == Success;
             if (!ret)
@@ -112,7 +121,7 @@ gboolean grab_pointer_window(gboolean grab, ObCursor cur, Window win)
 
     if (grab) {
         if (pgrabs++ == 0) {
-            ret = XGrabPointer(ob_display, win, False, GRAB_PTR_MASK,
+            ret = XGrabPointer(ob_display, win, True, GRAB_PTR_MASK,
                                GrabModeAsync, GrabModeAsync, None,
                                ob_cursor(cur),
                                event_curtime) == Success;
This page took 0.021771 seconds and 4 git commands to generate.