diff options
| author | Po Lu | 2021-12-22 11:13:23 +0800 |
|---|---|---|
| committer | Po Lu | 2021-12-22 11:13:23 +0800 |
| commit | f703232b7ff3453640179c6c1e9415e9ff1af987 (patch) | |
| tree | 921c0719be58945e03d8767770ef0830952ed3c7 /src | |
| parent | 026804b60631d4766bb99bf94a4ad04e13ae0d07 (diff) | |
| download | emacs-f703232b7ff3453640179c6c1e9415e9ff1af987.tar.gz emacs-f703232b7ff3453640179c6c1e9415e9ff1af987.zip | |
Use XI2 calls to warp the client pointer
* src/xfns.c (Fx_set_mouse_absolute_pixel_position):
* src/xterm.c (frame_set_mouse_pixel_position): Replace
calls to XWarpPointer with calls to XIWarpPointer with
the client pointer explictly specified. This avoids the
odd situation where the client pointer of the root window
is not the client pointer of the frame.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 19 | ||||
| -rw-r--r-- | src/xterm.c | 19 |
2 files changed, 34 insertions, 4 deletions
diff --git a/src/xfns.c b/src/xfns.c index 30ed358fb28..168debc8f33 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -5643,8 +5643,23 @@ The coordinates X and Y are interpreted in pixels relative to a position | |||
| 5643 | int yval = check_integer_range (y, INT_MIN, INT_MAX); | 5643 | int yval = check_integer_range (y, INT_MIN, INT_MAX); |
| 5644 | 5644 | ||
| 5645 | block_input (); | 5645 | block_input (); |
| 5646 | XWarpPointer (FRAME_X_DISPLAY (f), None, DefaultRootWindow (FRAME_X_DISPLAY (f)), | 5646 | #ifdef HAVE_XINPUT2 |
| 5647 | 0, 0, 0, 0, xval, yval); | 5647 | int deviceid; |
| 5648 | |||
| 5649 | if (FRAME_DISPLAY_INFO (f)->supports_xi2) | ||
| 5650 | { | ||
| 5651 | if (XIGetClientPointer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 5652 | &deviceid)) | ||
| 5653 | { | ||
| 5654 | XIWarpPointer (FRAME_X_DISPLAY (f), deviceid, None, | ||
| 5655 | DefaultRootWindow (FRAME_X_DISPLAY (f)), | ||
| 5656 | 0, 0, 0, 0, xval, yval); | ||
| 5657 | } | ||
| 5658 | } | ||
| 5659 | else | ||
| 5660 | #endif | ||
| 5661 | XWarpPointer (FRAME_X_DISPLAY (f), None, DefaultRootWindow (FRAME_X_DISPLAY (f)), | ||
| 5662 | 0, 0, 0, 0, xval, yval); | ||
| 5648 | unblock_input (); | 5663 | unblock_input (); |
| 5649 | 5664 | ||
| 5650 | return Qnil; | 5665 | return Qnil; |
diff --git a/src/xterm.c b/src/xterm.c index 33396cc9ab4..070ee7d671e 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -13223,9 +13223,24 @@ void | |||
| 13223 | frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) | 13223 | frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) |
| 13224 | { | 13224 | { |
| 13225 | block_input (); | 13225 | block_input (); |
| 13226 | #ifdef HAVE_XINPUT2 | ||
| 13227 | int deviceid; | ||
| 13226 | 13228 | ||
| 13227 | XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f), | 13229 | if (FRAME_DISPLAY_INFO (f)->supports_xi2) |
| 13228 | 0, 0, 0, 0, pix_x, pix_y); | 13230 | { |
| 13231 | if (XIGetClientPointer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | ||
| 13232 | &deviceid)) | ||
| 13233 | { | ||
| 13234 | XIWarpPointer (FRAME_X_DISPLAY (f), | ||
| 13235 | deviceid, None, | ||
| 13236 | FRAME_X_WINDOW (f), | ||
| 13237 | 0, 0, 0, 0, pix_x, pix_y); | ||
| 13238 | } | ||
| 13239 | } | ||
| 13240 | else | ||
| 13241 | #endif | ||
| 13242 | XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f), | ||
| 13243 | 0, 0, 0, 0, pix_x, pix_y); | ||
| 13229 | unblock_input (); | 13244 | unblock_input (); |
| 13230 | } | 13245 | } |
| 13231 | 13246 | ||