about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2019-06-16T00·00+0000
committerChris Feng <chris.w.feng@gmail.com>2019-06-16T00·00+0000
commitaa92c7be8cb92ae74617b8d3d431431d2aa7edac (patch)
tree6ff2b980f1f7994e68e4f2eabac5c1daeaf033be
parent8a54504152220e660b7df33dacda3b58b7532563 (diff)
Avoid workspace switch loop with `mouse-autoselect-window' enabled
* exwm-input.el (exwm-input--last-enter-notify-position): New variable
storing last mouse position.
(exwm-input--on-EnterNotify): Avoid switching workspace when mouse
position is not changed (the event is a result of a workspace switch).
-rw-r--r--exwm-input.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/exwm-input.el b/exwm-input.el
index eeea36e5a256..22c8002be6a3 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -219,6 +219,8 @@ ARGS are additional arguments to CALLBACK."
                (cdr exwm-input--timestamp-callback))
         (setq exwm-input--timestamp-callback nil)))))
 
+(defvar exwm-input--last-enter-notify-position nil)
+
 (defun exwm-input--on-EnterNotify (data _synthetic)
   "Handle EnterNotify events."
   (let ((evt (make-instance 'xcb:EnterNotify))
@@ -228,7 +230,9 @@ ARGS are additional arguments to CALLBACK."
       (setq buffer (exwm--id->buffer event)
             window (get-buffer-window buffer t))
       (exwm--log "buffer=%s; window=%s" buffer window)
-      (when (and buffer window (not (eq window (selected-window))))
+      (when (and buffer window (not (eq window (selected-window)))
+                 (not (equal exwm-input--last-enter-notify-position
+                             (vector root-x root-y))))
         (setq frame (window-frame window)
               frame-xid (frame-parameter frame 'exwm-id))
         (unless (eq frame exwm-workspace--current)
@@ -260,7 +264,8 @@ ARGS are additional arguments to CALLBACK."
                            :destination frame-xid
                            :event-mask xcb:EventMask:NoEvent
                            :event (xcb:marshal fake-evt exwm--connection)))
-        (xcb:flush exwm--connection)))))
+        (xcb:flush exwm--connection))
+      (setq exwm-input--last-enter-notify-position (vector root-x root-y)))))
 
 (defun exwm-input--on-keysyms-update ()
   (exwm--log)