Blame SOURCES/0001-wayland-Check-stylus-serials-on-meta_wayland_seat_ca.patch

7cc7ff
From f2b3dd318f1165849b45a86251724939b100ef7d Mon Sep 17 00:00:00 2001
7cc7ff
From: Carlos Garnacho <carlosg@gnome.org>
7cc7ff
Date: Mon, 28 Oct 2019 18:07:31 +0100
7cc7ff
Subject: [PATCH] wayland: Check stylus serials on
7cc7ff
 meta_wayland_seat_can_popup()
7cc7ff
7cc7ff
This allows xdg_popup.grab() to work with styli. Without this check
7cc7ff
we would bail out and emit xdg_popup.popup_done, leaving stylus users
7cc7ff
unable to interact with popup menus, comboboxes, etc...
7cc7ff
7cc7ff
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/886
7cc7ff
---
7cc7ff
 src/wayland/meta-wayland-seat.c        | 10 +++++++++-
7cc7ff
 src/wayland/meta-wayland-tablet-seat.c | 17 +++++++++++++++++
7cc7ff
 src/wayland/meta-wayland-tablet-seat.h |  2 ++
7cc7ff
 src/wayland/meta-wayland-tablet-tool.c |  7 +++++++
7cc7ff
 src/wayland/meta-wayland-tablet-tool.h |  2 ++
7cc7ff
 5 files changed, 37 insertions(+), 1 deletion(-)
7cc7ff
7cc7ff
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
7cc7ff
index 91fe376ff..cf41d6eb8 100644
7cc7ff
--- a/src/wayland/meta-wayland-seat.c
7cc7ff
+++ b/src/wayland/meta-wayland-seat.c
7cc7ff
@@ -504,9 +504,17 @@ gboolean
7cc7ff
 meta_wayland_seat_can_popup (MetaWaylandSeat *seat,
7cc7ff
                              uint32_t         serial)
7cc7ff
 {
7cc7ff
+  MetaWaylandCompositor *compositor;
7cc7ff
+  MetaWaylandTabletSeat *tablet_seat;
7cc7ff
+
7cc7ff
+  compositor = meta_wayland_compositor_get_default ();
7cc7ff
+  tablet_seat =
7cc7ff
+    meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager, seat);
7cc7ff
+
7cc7ff
   return (meta_wayland_pointer_can_popup (seat->pointer, serial) ||
7cc7ff
           meta_wayland_keyboard_can_popup (seat->keyboard, serial) ||
7cc7ff
-          meta_wayland_touch_can_popup (seat->touch, serial));
7cc7ff
+          meta_wayland_touch_can_popup (seat->touch, serial) ||
7cc7ff
+          meta_wayland_tablet_seat_can_popup (tablet_seat, serial));
7cc7ff
 }
7cc7ff
 
7cc7ff
 gboolean
7cc7ff
diff --git a/src/wayland/meta-wayland-tablet-seat.c b/src/wayland/meta-wayland-tablet-seat.c
7cc7ff
index b4bc4aa58..b1964714a 100644
7cc7ff
--- a/src/wayland/meta-wayland-tablet-seat.c
7cc7ff
+++ b/src/wayland/meta-wayland-tablet-seat.c
7cc7ff
@@ -552,3 +552,20 @@ meta_wayland_tablet_seat_set_pad_focus (MetaWaylandTabletSeat *tablet_seat,
7cc7ff
   while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &pad))
7cc7ff
     meta_wayland_tablet_pad_set_focus (pad, surface);
7cc7ff
 }
7cc7ff
+
7cc7ff
+gboolean
7cc7ff
+meta_wayland_tablet_seat_can_popup (MetaWaylandTabletSeat *tablet_seat,
7cc7ff
+                                    uint32_t               serial)
7cc7ff
+{
7cc7ff
+  MetaWaylandTabletTool *tool;
7cc7ff
+  GHashTableIter iter;
7cc7ff
+
7cc7ff
+  g_hash_table_iter_init (&iter, tablet_seat->tools);
7cc7ff
+  while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &tool))
7cc7ff
+    {
7cc7ff
+      if (meta_wayland_tablet_tool_can_popup (tool, serial))
7cc7ff
+        return TRUE;
7cc7ff
+    }
7cc7ff
+
7cc7ff
+  return FALSE;
7cc7ff
+}
7cc7ff
diff --git a/src/wayland/meta-wayland-tablet-seat.h b/src/wayland/meta-wayland-tablet-seat.h
7cc7ff
index c083dec5f..e3be5f264 100644
7cc7ff
--- a/src/wayland/meta-wayland-tablet-seat.h
7cc7ff
+++ b/src/wayland/meta-wayland-tablet-seat.h
7cc7ff
@@ -75,5 +75,7 @@ MetaWaylandTablet     *meta_wayland_tablet_seat_lookup_paired_tablet (MetaWaylan
7cc7ff
                                                                       MetaWaylandTabletPad  *pad);
7cc7ff
 GList                 *meta_wayland_tablet_seat_lookup_paired_pads   (MetaWaylandTabletSeat *tablet_seat,
7cc7ff
                                                                       MetaWaylandTablet     *tablet);
7cc7ff
+gboolean               meta_wayland_tablet_seat_can_popup            (MetaWaylandTabletSeat *tablet_seat,
7cc7ff
+                                                                      uint32_t               serial);
7cc7ff
 
7cc7ff
 #endif /* META_WAYLAND_TABLET_SEAT_H */
7cc7ff
diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c
7cc7ff
index c02831d73..065c834bb 100644
7cc7ff
--- a/src/wayland/meta-wayland-tablet-tool.c
7cc7ff
+++ b/src/wayland/meta-wayland-tablet-tool.c
7cc7ff
@@ -1018,3 +1018,10 @@ meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
7cc7ff
   return ((tool->down_serial == serial || tool->button_serial == serial) &&
7cc7ff
           tablet_tool_can_grab_surface (tool, surface));
7cc7ff
 }
7cc7ff
+
7cc7ff
+gboolean
7cc7ff
+meta_wayland_tablet_tool_can_popup (MetaWaylandTabletTool *tool,
7cc7ff
+                                    uint32_t               serial)
7cc7ff
+{
7cc7ff
+  return tool->down_serial == serial || tool->button_serial == serial;
7cc7ff
+}
7cc7ff
diff --git a/src/wayland/meta-wayland-tablet-tool.h b/src/wayland/meta-wayland-tablet-tool.h
7cc7ff
index 71bc86643..315e26bde 100644
7cc7ff
--- a/src/wayland/meta-wayland-tablet-tool.h
7cc7ff
+++ b/src/wayland/meta-wayland-tablet-tool.h
7cc7ff
@@ -85,5 +85,7 @@ void     meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool  *t
7cc7ff
 gboolean meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
7cc7ff
                                                     MetaWaylandSurface    *surface,
7cc7ff
                                                     uint32_t               serial);
7cc7ff
+gboolean meta_wayland_tablet_tool_can_popup        (MetaWaylandTabletTool *tool,
7cc7ff
+                                                    uint32_t               serial);
7cc7ff
 
7cc7ff
 #endif /* META_WAYLAND_TABLET_TOOL_H */
7cc7ff
-- 
7cc7ff
2.23.0
7cc7ff