Otherwise some versions of Motif will emit a warning and hang,
and lwlib will fail to destroy the menu window. */
- if (dpyinfo->num_devices)
+ if (dpyinfo->supports_xi2
+ && xi_frame_selected_for (f, XI_ButtonPress))
{
for (int i = 0; i < dpyinfo->num_devices; ++i)
{
if (dpyinfo->devices[i].grab)
- {
- XIUngrabDevice (dpyinfo->display, dpyinfo->devices[i].device_id,
- CurrentTime);
- }
+ XIUngrabDevice (dpyinfo->display,
+ dpyinfo->devices[i].device_id,
+ CurrentTime);
}
}
#endif
}
#if !defined HAVE_GTK3 && defined HAVE_XINPUT2
- if (FRAME_DISPLAY_INFO (f)->num_devices)
+ if (FRAME_DISPLAY_INFO (f)->supports_xi2
+ && xi_frame_selected_for (f, XI_ButtonPress))
{
for (int i = 0; i < FRAME_DISPLAY_INFO (f)->num_devices; ++i)
{
if (dpyinfo->supports_xi2)
XGrabServer (dpyinfo->display);
- if (dpyinfo->num_devices)
+ if (dpyinfo->supports_xi2
+ && xi_frame_selected_for (f, XI_ButtonPress))
{
for (int i = 0; i < dpyinfo->num_devices; ++i)
{
struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
/* Clear the XI2 grab so a core grab can be set. */
- if (dpyinfo->num_devices)
+ if (dpyinfo->supports_xi2
+ && xi_frame_selected_for (f, XI_ButtonPress))
{
for (int i = 0; i < dpyinfo->num_devices; ++i)
{
#endif
+#ifdef HAVE_XINPUT2
+bool
+xi_frame_selected_for (struct frame *f, unsigned long event)
+{
+ XIEventMask *masks;
+ int i;
+
+ masks = FRAME_X_OUTPUT (f)->xi_masks;
+
+ if (!masks)
+ return false;
+
+ for (i = 0; i < FRAME_X_OUTPUT (f)->num_xi_masks; ++i)
+ {
+ if (masks[i].mask_len >= XIMaskLen (event)
+ && XIMaskIsSet (masks[i].mask, event))
+ return true;
+ }
+
+ return false;
+}
+#endif
+
static void
x_toolkit_position (struct frame *f, int x, int y,
bool *menu_bar_p, bool *tool_bar_p)
xi_device->touchpoints = NULL;
#endif
- xi_device->master_p = (device->use == XIMasterKeyboard
- || device->use == XIMasterPointer);
+ xi_device->use = device->use;
#ifdef HAVE_XINPUT2_2
xi_device->direct_p = false;
#endif
the root window, so we can get notified when window stacking
changes, a common operation during drag-and-drop. */
- block_input ();
XGetWindowAttributes (FRAME_X_DISPLAY (f),
FRAME_DISPLAY_INFO (f)->root_window,
&root_window_attrs);
current_hold_quit = &hold_quit;
#endif
+ block_input ();
#ifdef USE_GTK
gtk_main_iteration ();
#else
&next_event, &finish, &hold_quit);
#endif
#endif
+ unblock_input ();
if (x_dnd_movement_frame)
{
XSelectInput (FRAME_X_DISPLAY (f),
FRAME_DISPLAY_INFO (f)->root_window,
root_window_attrs.your_event_mask);
- unblock_input ();
quit ();
}
}
#endif
x_dnd_movement_frame = NULL;
+ block_input ();
/* Restore the old event mask. */
XSelectInput (FRAME_X_DISPLAY (f),
FRAME_DISPLAY_INFO (f)->root_window,
root_window_attrs.your_event_mask);
-
unblock_input ();
if (x_dnd_return_frame == 3
if (info)
{
if (device && info->enabled)
- device->master_p = (info->use == XIMasterKeyboard
- || info->use == XIMasterPointer);
+ device->use = info->use;
else if (device)
disabled[n_disabled++] = hev->info[i].deviceid;
#ifdef HAVE_X_I18N
if (FRAME_XIC (f))
free_frame_xic (f);
-
- if (f->output_data.x->preedit_chars)
- xfree (f->output_data.x->preedit_chars);
#endif
#ifdef USE_CAIRO
xfree (f->output_data.x->saved_menu_event);
xfree (f->output_data.x);
+
+#ifdef HAVE_X_I18N
+ if (f->output_data.x->preedit_chars)
+ xfree (f->output_data.x->preedit_chars);
+#endif
+
+#ifdef HAVE_XINPUT2
+ if (f->output_data.x->xi_masks)
+ XFree (f->output_data.x->xi_masks);
+#endif
+
f->output_data.x = NULL;
dpyinfo->reference_count--;