about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2018-08-12T00·00+0000
committerChris Feng <chris.w.feng@gmail.com>2018-08-12T00·00+0000
commit4d43e3119a2d0cb002d87340cd11c1d372ad126e (patch)
treea32c25b4bc96bc59159ea8cf6939616b0da843fe
parente6527227b387d08146963613ada37022ddf33d80 (diff)
Avoid using `set-mouse-position' to warp pointer
* exwm-workspace.el (exwm-workspace-switch): Warp pointer with the
WarpPointer request.
-rw-r--r--exwm-workspace.el15
1 files changed, 12 insertions, 3 deletions
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 6535e11f27e3..1034966374bf 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -607,9 +607,18 @@ for internal use only."
                                                       'exwm-outer-id)))
         (when (or (> win-x (frame-pixel-width frame))
                   (> win-y (frame-pixel-height)))
-          (set-mouse-position frame
-                              (/ (frame-width frame) 2)
-                              (/ (frame-height frame) 2)))))
+          (xcb:+request exwm--connection
+              (make-instance 'xcb:WarpPointer
+                             :src-window xcb:Window:None
+                             :dst-window (frame-parameter frame
+                                                          'exwm-outer-id)
+                             :src-x 0
+                             :src-y 0
+                             :src-width 0
+                             :src-height 0
+                             :dst-x (/ (frame-pixel-width frame) 2)
+                             :dst-y (/ (frame-pixel-height frame) 2)))
+          (xcb:flush exwm--connection))))
     (when (frame-live-p old-frame)
       (with-selected-frame old-frame
         (run-hooks 'focus-out-hook)))