From bd321f78eb8db839147a13a8543c0d3ca878f242 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 28 Nov 2021 13:13:06 +0800 Subject: [PATCH] Fix xwidget popups on XI2 * src/gtkutil.c (xg_is_menu_window): Determine whether wdesc is a menu generated by a menu bar more reliably. * src/xwidget.c (xwidget_button_1): Release all XI2 grabs on click. --- src/gtkutil.c | 6 +++++- src/xwidget.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gtkutil.c b/src/gtkutil.c index 9e676cd025b..8f8db4ed372 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -853,7 +853,11 @@ xg_is_menu_window (Display *dpy, Window wdesc) { GtkWidget *fw = gtk_bin_get_child (GTK_BIN (gwdesc)); if (GTK_IS_MENU (fw)) - return true; + { + GtkWidget *parent + = gtk_menu_shell_get_parent_shell (GTK_MENU_SHELL (fw)); + return GTK_IS_MENU_BAR (parent); + } } return false; diff --git a/src/xwidget.c b/src/xwidget.c index 5da2aa1743b..e07b290acbf 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -907,6 +907,10 @@ xwidget_button_1 (struct xwidget_view *view, GdkEvent *xg_event = gdk_event_new (down_p ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE); struct xwidget *model = XXWIDGET (view->model); GtkWidget *target; +#ifdef HAVE_XINPUT2 + struct x_display_info *dpyinfo; + struct xi_device_t *xi_device; +#endif /* X and Y should be relative to the origin of view->wdesc. */ x += view->clip_left; @@ -930,6 +934,16 @@ xwidget_button_1 (struct xwidget_view *view, xg_event->button.time = time; xg_event->button.device = find_suitable_pointer (view->frame); +#ifdef HAVE_XINPUT2 + dpyinfo = FRAME_DISPLAY_INFO (view->frame); + for (int idx = 0; idx < dpyinfo->num_devices; ++idx) + { + xi_device = &dpyinfo->devices[idx]; + + XIUngrabDevice (view->dpy, xi_device->device_id, CurrentTime); + } +#endif + gtk_main_do_event (xg_event); gdk_event_free (xg_event); } -- 2.39.2