* 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.
bool
gui_mouse_grabbed (Display_Info *dpyinfo)
{
- return (dpyinfo->grabbed
+ return ((dpyinfo->grabbed
+ || (dpyinfo->terminal->any_grab_hook
+ && dpyinfo->terminal->any_grab_hook (dpyinfo)))
&& dpyinfo->last_mouse_frame
&& FRAME_LIVE_P (dpyinfo->last_mouse_frame));
}
MENU_BAR_P if X and Y are in FRAME's toolkit menu bar, and true
into TOOL_BAR_P if X and Y are in FRAME's toolkit tool bar. */
void (*toolkit_position_hook) (struct frame *, int, int, bool *, bool *);
+
+#ifdef HAVE_WINDOW_SYSTEM
+ /* Called to determine if the mouse is grabbed on the given display.
+ If either dpyinfo->grabbed or this returns true, then the display
+ will be considered as grabbed. */
+ bool (*any_grab_hook) (Display_Info *);
+#endif
} GCALIGNED_STRUCT;
INLINE bool
unblock_input ();
}
+#ifdef HAVE_XINPUT2
+static bool
+x_have_any_grab (struct x_display_info *dpyinfo)
+{
+ int i;
+
+ if (!dpyinfo->supports_xi2)
+ return false;
+
+ for (i = 0; i < dpyinfo->num_devices; ++i)
+ {
+ if (dpyinfo->devices[i].grab)
+ return true;
+ }
+
+ return false;
+}
+#endif
+
/* Create a struct terminal, initialize it with the X11 specific
functions and make DISPLAY->TERMINAL point to it. */
terminal->delete_frame_hook = x_destroy_window;
terminal->delete_terminal_hook = x_delete_terminal;
terminal->toolkit_position_hook = x_toolkit_position;
+#ifdef HAVE_XINPUT2
+ terminal->any_grab_hook = x_have_any_grab;
+#endif
/* Other hooks are NULL by default. */
return terminal;