summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorAlynx Zhou <alynx.zhou@gmail.com>2020-04-29 15:45:22 +0800
committerAlynx Zhou <alynx.zhou@gmail.com>2020-04-30 10:16:25 +0800
commit721ce22a869b61de618cb676fcc7f668984c4bf3 (patch)
tree2619b7d8ae116df863f84d371e2b2b005dd1cbae /gtk
parentcd78e080b104b9124c77b2a6d9fd0ce1449f840f (diff)
downloadgtk+-721ce22a869b61de618cb676fcc7f668984c4bf3.tar.gz
menu: Fix touch support by using pointer emulation under X11
GtkMenu under X11 cannot handle touch events properly, so just disable touchscreen grabbing for it, which makes it fallback to pointer emulation. Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/945 menu: Fix grab on other backend
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkmenu.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 64e4b98d9f..a416e42ea2 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -140,6 +140,9 @@
#include "a11y/gtkmenuaccessible.h"
#include "gdk/gdk-private.h"
+#ifdef GDK_WINDOWING_X11
+#include "gdk/x11/gdkx.h"
+#endif
#define NAVIGATION_REGION_OVERSHOOT 50 /* How much the navigation region
* extends below the submenu
@@ -1775,8 +1778,26 @@ popup_grab_on_window (GdkWindow *window,
{
GdkGrabStatus status;
GdkSeat *seat;
+#ifdef GDK_WINDOWING_X11
+ GdkDisplay *display;
+#endif
seat = gdk_device_get_seat (pointer);
+#ifdef GDK_WINDOWING_X11
+ display = gdk_window_get_display (window);
+#endif
+
+#ifdef GDK_WINDOWING_X11
+/* Let GtkMenu use pointer emulation instead of touch events under X11. */
+#define GDK_SEAT_CAPABILITY_NO_TOUCH (GDK_SEAT_CAPABILITY_POINTER | \
+ GDK_SEAT_CAPABILITY_TABLET_STYLUS | \
+ GDK_SEAT_CAPABILITY_KEYBOARD)
+ if (GDK_IS_X11_DISPLAY (display))
+ status = gdk_seat_grab (seat, window,
+ GDK_SEAT_CAPABILITY_NO_TOUCH, TRUE,
+ NULL, NULL, NULL, NULL);
+ else
+#endif
status = gdk_seat_grab (seat, window,
GDK_SEAT_CAPABILITY_ALL, TRUE,
NULL, NULL, NULL, NULL);