diff options
| author | Po Lu | 2022-06-24 10:57:35 +0800 |
|---|---|---|
| committer | Po Lu | 2022-06-24 10:57:35 +0800 |
| commit | bf5c75465f37ad45934f58287660f18ec0bcf7bf (patch) | |
| tree | 837922f74e8e90f3f357169b72d77842be189d5c /src | |
| parent | ab203b0ce26f4989c7fc80185207c6c40bbfa5fe (diff) | |
| download | emacs-bf5c75465f37ad45934f58287660f18ec0bcf7bf.tar.gz emacs-bf5c75465f37ad45934f58287660f18ec0bcf7bf.zip | |
Improve grabbing detection with multiple master devices (MPX)
* src/frame.c (gui_mouse_grabbed): Respect any_grab_hook.
* src/termhooks.h (GCALIGNED_STRUCT): New hook `any_grab_hook'.
* src/xterm.c (x_have_any_grab): New function.
(x_create_terminal): Define hook on XI2 builds.
Diffstat (limited to 'src')
| -rw-r--r-- | src/frame.c | 4 | ||||
| -rw-r--r-- | src/termhooks.h | 7 | ||||
| -rw-r--r-- | src/xterm.c | 22 |
3 files changed, 32 insertions, 1 deletions
diff --git a/src/frame.c b/src/frame.c index c2f2f8e4642..02c90ea6519 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -5130,7 +5130,9 @@ gui_set_no_special_glyphs (struct frame *f, Lisp_Object new_value, Lisp_Object o | |||
| 5130 | bool | 5130 | bool |
| 5131 | gui_mouse_grabbed (Display_Info *dpyinfo) | 5131 | gui_mouse_grabbed (Display_Info *dpyinfo) |
| 5132 | { | 5132 | { |
| 5133 | return (dpyinfo->grabbed | 5133 | return ((dpyinfo->grabbed |
| 5134 | || (dpyinfo->terminal->any_grab_hook | ||
| 5135 | && dpyinfo->terminal->any_grab_hook (dpyinfo))) | ||
| 5134 | && dpyinfo->last_mouse_frame | 5136 | && dpyinfo->last_mouse_frame |
| 5135 | && FRAME_LIVE_P (dpyinfo->last_mouse_frame)); | 5137 | && FRAME_LIVE_P (dpyinfo->last_mouse_frame)); |
| 5136 | } | 5138 | } |
diff --git a/src/termhooks.h b/src/termhooks.h index d7190e77362..a1e3e2cde9a 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -877,6 +877,13 @@ struct terminal | |||
| 877 | MENU_BAR_P if X and Y are in FRAME's toolkit menu bar, and true | 877 | MENU_BAR_P if X and Y are in FRAME's toolkit menu bar, and true |
| 878 | into TOOL_BAR_P if X and Y are in FRAME's toolkit tool bar. */ | 878 | into TOOL_BAR_P if X and Y are in FRAME's toolkit tool bar. */ |
| 879 | void (*toolkit_position_hook) (struct frame *, int, int, bool *, bool *); | 879 | void (*toolkit_position_hook) (struct frame *, int, int, bool *, bool *); |
| 880 | |||
| 881 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 882 | /* Called to determine if the mouse is grabbed on the given display. | ||
| 883 | If either dpyinfo->grabbed or this returns true, then the display | ||
| 884 | will be considered as grabbed. */ | ||
| 885 | bool (*any_grab_hook) (Display_Info *); | ||
| 886 | #endif | ||
| 880 | } GCALIGNED_STRUCT; | 887 | } GCALIGNED_STRUCT; |
| 881 | 888 | ||
| 882 | INLINE bool | 889 | INLINE bool |
diff --git a/src/xterm.c b/src/xterm.c index 6375b71666b..414a9c0ebed 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -27320,6 +27320,25 @@ x_delete_terminal (struct terminal *terminal) | |||
| 27320 | unblock_input (); | 27320 | unblock_input (); |
| 27321 | } | 27321 | } |
| 27322 | 27322 | ||
| 27323 | #ifdef HAVE_XINPUT2 | ||
| 27324 | static bool | ||
| 27325 | x_have_any_grab (struct x_display_info *dpyinfo) | ||
| 27326 | { | ||
| 27327 | int i; | ||
| 27328 | |||
| 27329 | if (!dpyinfo->supports_xi2) | ||
| 27330 | return false; | ||
| 27331 | |||
| 27332 | for (i = 0; i < dpyinfo->num_devices; ++i) | ||
| 27333 | { | ||
| 27334 | if (dpyinfo->devices[i].grab) | ||
| 27335 | return true; | ||
| 27336 | } | ||
| 27337 | |||
| 27338 | return false; | ||
| 27339 | } | ||
| 27340 | #endif | ||
| 27341 | |||
| 27323 | /* Create a struct terminal, initialize it with the X11 specific | 27342 | /* Create a struct terminal, initialize it with the X11 specific |
| 27324 | functions and make DISPLAY->TERMINAL point to it. */ | 27343 | functions and make DISPLAY->TERMINAL point to it. */ |
| 27325 | 27344 | ||
| @@ -27387,6 +27406,9 @@ x_create_terminal (struct x_display_info *dpyinfo) | |||
| 27387 | terminal->delete_frame_hook = x_destroy_window; | 27406 | terminal->delete_frame_hook = x_destroy_window; |
| 27388 | terminal->delete_terminal_hook = x_delete_terminal; | 27407 | terminal->delete_terminal_hook = x_delete_terminal; |
| 27389 | terminal->toolkit_position_hook = x_toolkit_position; | 27408 | terminal->toolkit_position_hook = x_toolkit_position; |
| 27409 | #ifdef HAVE_XINPUT2 | ||
| 27410 | terminal->any_grab_hook = x_have_any_grab; | ||
| 27411 | #endif | ||
| 27390 | /* Other hooks are NULL by default. */ | 27412 | /* Other hooks are NULL by default. */ |
| 27391 | 27413 | ||
| 27392 | return terminal; | 27414 | return terminal; |