diff options
| author | Po Lu | 2022-08-19 10:06:29 +0800 |
|---|---|---|
| committer | Po Lu | 2022-08-19 10:06:29 +0800 |
| commit | b90192b50e59ff987ef2102c1538e94b7864b1fd (patch) | |
| tree | 812785403ef603c511d5a389183aa15483df88ae /src | |
| parent | f1f2bbbc0880f1033feff69fa786d551875ec5e6 (diff) | |
| download | emacs-b90192b50e59ff987ef2102c1538e94b7864b1fd.tar.gz emacs-b90192b50e59ff987ef2102c1538e94b7864b1fd.zip | |
Fix more calls to XQueryPointer for MPX
* src/xterm.c (x_dnd_begin_drag_and_drop): Set DND devices to -1
if XI2 is not supported on the given display.
(x_query_pointer): Make wrapper around x_query_pointer_1.
(x_query_pointer_1): Split off most of x_query_pointer to this
function. Allow a specific client pointer to be specified.
(x_dnd_update_tooltip_now, x_dnd_update_state): Use
x_query_pointer_1 with the right device instead of
XQueryPointer.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 77 |
1 files changed, 60 insertions, 17 deletions
diff --git a/src/xterm.c b/src/xterm.c index a329ca59d0f..12c7b7d4dcc 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -12186,6 +12186,11 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, | |||
| 12186 | if (device) | 12186 | if (device) |
| 12187 | x_dnd_keyboard_device = device->attachment; | 12187 | x_dnd_keyboard_device = device->attachment; |
| 12188 | } | 12188 | } |
| 12189 | else | ||
| 12190 | { | ||
| 12191 | x_dnd_pointer_device = -1; | ||
| 12192 | x_dnd_keyboard_device = -1; | ||
| 12193 | } | ||
| 12189 | 12194 | ||
| 12190 | #endif | 12195 | #endif |
| 12191 | 12196 | ||
| @@ -13401,18 +13406,17 @@ get_keysym_name (int keysym) | |||
| 13401 | return value; | 13406 | return value; |
| 13402 | } | 13407 | } |
| 13403 | 13408 | ||
| 13404 | /* Like XQueryPointer, but always use the right client pointer | 13409 | static Bool |
| 13405 | device. */ | 13410 | x_query_pointer_1 (struct x_display_info *dpyinfo, |
| 13406 | 13411 | int client_pointer_device, Window w, | |
| 13407 | Bool | 13412 | Window *root_return, Window *child_return, |
| 13408 | x_query_pointer (Display *dpy, Window w, Window *root_return, | 13413 | int *root_x_return, int *root_y_return, |
| 13409 | Window *child_return, int *root_x_return, | 13414 | int *win_x_return, int *win_y_return, |
| 13410 | int *root_y_return, int *win_x_return, | 13415 | unsigned int *mask_return) |
| 13411 | int *win_y_return, unsigned int *mask_return) | ||
| 13412 | { | 13416 | { |
| 13413 | Bool rc; | 13417 | Bool rc; |
| 13418 | Display *dpy; | ||
| 13414 | #ifdef HAVE_XINPUT2 | 13419 | #ifdef HAVE_XINPUT2 |
| 13415 | struct x_display_info *dpyinfo; | ||
| 13416 | bool had_errors; | 13420 | bool had_errors; |
| 13417 | XIModifierState modifiers; | 13421 | XIModifierState modifiers; |
| 13418 | XIButtonState buttons; | 13422 | XIButtonState buttons; |
| @@ -13421,9 +13425,10 @@ x_query_pointer (Display *dpy, Window w, Window *root_return, | |||
| 13421 | unsigned int state; | 13425 | unsigned int state; |
| 13422 | #endif | 13426 | #endif |
| 13423 | 13427 | ||
| 13428 | dpy = dpyinfo->display; | ||
| 13429 | |||
| 13424 | #ifdef HAVE_XINPUT2 | 13430 | #ifdef HAVE_XINPUT2 |
| 13425 | dpyinfo = x_display_info_for_display (dpy); | 13431 | if (client_pointer_device != -1) |
| 13426 | if (dpyinfo && dpyinfo->client_pointer_device != -1) | ||
| 13427 | { | 13432 | { |
| 13428 | /* Catch errors caused by the device going away. This is not | 13433 | /* Catch errors caused by the device going away. This is not |
| 13429 | very expensive, since XIQueryPointer will sync anyway. */ | 13434 | very expensive, since XIQueryPointer will sync anyway. */ |
| @@ -13463,6 +13468,31 @@ x_query_pointer (Display *dpy, Window w, Window *root_return, | |||
| 13463 | return rc; | 13468 | return rc; |
| 13464 | } | 13469 | } |
| 13465 | 13470 | ||
| 13471 | Bool | ||
| 13472 | x_query_pointer (Display *dpy, Window w, Window *root_return, | ||
| 13473 | Window *child_return, int *root_x_return, | ||
| 13474 | int *root_y_return, int *win_x_return, | ||
| 13475 | int *win_y_return, unsigned int *mask_return) | ||
| 13476 | { | ||
| 13477 | struct x_display_info *dpyinfo; | ||
| 13478 | |||
| 13479 | dpyinfo = x_display_info_for_display (dpy); | ||
| 13480 | |||
| 13481 | if (!dpyinfo) | ||
| 13482 | emacs_abort (); | ||
| 13483 | |||
| 13484 | #ifdef HAVE_XINPUT2 | ||
| 13485 | return x_query_pointer_1 (dpyinfo, dpyinfo->client_pointer_device, | ||
| 13486 | w, root_return, child_return, root_x_return, | ||
| 13487 | root_y_return, win_x_return, win_y_return, | ||
| 13488 | mask_return); | ||
| 13489 | #else | ||
| 13490 | return x_query_pointer_1 (dpyinfo, -1, w, root_return, child_return, | ||
| 13491 | root_x_return, root_y_return, win_x_return, | ||
| 13492 | win_y_return, mask_return); | ||
| 13493 | #endif | ||
| 13494 | } | ||
| 13495 | |||
| 13466 | /* Mouse clicks and mouse movement. Rah. | 13496 | /* Mouse clicks and mouse movement. Rah. |
| 13467 | 13497 | ||
| 13468 | Formerly, we used PointerMotionHintMask (in standard_event_mask) | 13498 | Formerly, we used PointerMotionHintMask (in standard_event_mask) |
| @@ -16902,11 +16932,19 @@ x_dnd_update_tooltip_now (void) | |||
| 16902 | 16932 | ||
| 16903 | dpyinfo = FRAME_DISPLAY_INFO (x_dnd_frame); | 16933 | dpyinfo = FRAME_DISPLAY_INFO (x_dnd_frame); |
| 16904 | 16934 | ||
| 16935 | #ifndef HAVE_XINPUT2 | ||
| 16905 | rc = XQueryPointer (dpyinfo->display, | 16936 | rc = XQueryPointer (dpyinfo->display, |
| 16906 | dpyinfo->root_window, | 16937 | dpyinfo->root_window, |
| 16907 | &root, &child, &root_x, | 16938 | &root, &child, &root_x, |
| 16908 | &root_y, &win_x, &win_y, | 16939 | &root_y, &win_x, &win_y, |
| 16909 | &mask); | 16940 | &mask); |
| 16941 | #else | ||
| 16942 | rc = x_query_pointer_1 (dpyinfo, x_dnd_pointer_device, | ||
| 16943 | dpyinfo->root_window, | ||
| 16944 | &root, &child, &root_x, | ||
| 16945 | &root_y, &win_x, &win_y, | ||
| 16946 | &mask); | ||
| 16947 | #endif | ||
| 16910 | 16948 | ||
| 16911 | if (rc) | 16949 | if (rc) |
| 16912 | x_dnd_update_tooltip_position (root_x, root_y); | 16950 | x_dnd_update_tooltip_position (root_x, root_y); |
| @@ -16926,12 +16964,17 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp) | |||
| 16926 | xm_drop_start_message dsmsg; | 16964 | xm_drop_start_message dsmsg; |
| 16927 | bool was_frame; | 16965 | bool was_frame; |
| 16928 | 16966 | ||
| 16929 | if (XQueryPointer (dpyinfo->display, | 16967 | if (x_query_pointer_1 (dpyinfo, |
| 16930 | dpyinfo->root_window, | 16968 | #ifdef HAVE_XINPUT2 |
| 16931 | &dummy, &dummy_child, | 16969 | x_dnd_pointer_device, |
| 16932 | &root_x, &root_y, | 16970 | #else |
| 16933 | &dummy_x, &dummy_y, | 16971 | -1, |
| 16934 | &dummy_mask)) | 16972 | #endif |
| 16973 | dpyinfo->root_window, | ||
| 16974 | &dummy, &dummy_child, | ||
| 16975 | &root_x, &root_y, | ||
| 16976 | &dummy_x, &dummy_y, | ||
| 16977 | &dummy_mask)) | ||
| 16935 | { | 16978 | { |
| 16936 | target = x_dnd_get_target_window (dpyinfo, root_x, | 16979 | target = x_dnd_get_target_window (dpyinfo, root_x, |
| 16937 | root_y, &target_proto, | 16980 | root_y, &target_proto, |