From de8d6ee60165fd753e0fb763823bc86a9df733d3 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <fourdan.olivier@wanadoo.fr>
Date: Thu, 8 Apr 2004 19:46:44 +0000
Subject: [PATCH] Grab the pointer instead of flushing all EnterEvent on
 workspace switch

(Old svn revision: 11693)
---
 src/workspaces.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/workspaces.c b/src/workspaces.c
index 5bfba9b7a..43212cd8e 100644
--- a/src/workspaces.c
+++ b/src/workspaces.c
@@ -64,6 +64,10 @@ workspaceSwitch (int new_ws, Client * c2)
         return;
     }
 
+    /* Grab the pointer to avoid side effects with EnterNotify events */
+    XGrabPointer (dpy, gnome_win, FALSE, EnterWindowMask, GrabModeAsync,
+                       GrabModeAsync, None, None, CurrentTime);
+
     workspace = new_ws;
     if (c2)
     {
@@ -147,18 +151,13 @@ workspaceSwitch (int new_ws, Client * c2)
     XChangeProperty (dpy, root, net_current_desktop, XA_CARDINAL, 32,
         PropModeReplace, (unsigned char *) data, 1);
     workspaceUpdateArea (margins, gnome_margins);
+    
+    /* Ungrab the pointer we grabbed before mapping/unmapping all windows */
+    XUngrabPointer (dpy, CurrentTime);
+
     if (!(params.click_to_focus))
     {
-        XEvent an_event;
-        /* Just get rid of EnterNotify events when using focus follow mouse */
-        XSync (dpy, FALSE);
-        while (XCheckTypedEvent (dpy, EnterNotify, &an_event))
-        {
-            last_timestamp = stashEventTime (last_timestamp, &an_event);
-        }    
-        if (!(c2)
-            && (XQueryPointer (dpy, root, &dr, &window, &rx, &ry, &wx, &wy,
-                    &mask)))
+        if (!(c2) && (XQueryPointer (dpy, root, &dr, &window, &rx, &ry, &wx, &wy, &mask)))
         {
             c = clientAtPosition (rx, ry, NULL);
             if (c)
-- 
GitLab