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).
This commit is contained in:
Chris Feng 2019-06-16 00:00:00 +00:00
parent 8a54504152
commit aa92c7be8c

View file

@ -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)