[mutter/wip/carlosg/there-can-be-only-one: 4879/4879] backends/native: Fix cursor renderer assignment for tablet devices




commit 89ae1c41a63c6d4de7243c7a763a0aa984483cf0
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jan 12 13:56:53 2022 +0100

    backends/native: Fix cursor renderer assignment for tablet devices
    
    We create a cursor renderer per device for those at
    meta_seat_native_handle_event_post() with PROXIMITY_IN events, but
    the MetaWaylandTabletTool handles the event before that, and goes
    with a NULL cursor renderer.
    
    Make MetaBackend::get_cursor_renderer() on the native backend create
    those cursor renderers on demand, and only handle PROXIMITY_OUT in
    handle_event_post() to dispose those. This makes MetaWaylandTabletTool
    happily get a cursor renderer again.

 src/backends/native/meta-seat-native.c | 43 +++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 19 deletions(-)
---
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index 12fead1fb2..0792ebbbfb 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -63,22 +63,7 @@ meta_seat_native_handle_event_post (ClutterSeat        *seat,
   ClutterInputDevice *device = clutter_event_get_source_device (event);
   ClutterEventType event_type = event->type;
 
-  if (event_type == CLUTTER_PROXIMITY_IN)
-    {
-      MetaCursorRenderer *cursor_renderer;
-
-      if (!seat_native->tablet_cursors)
-        {
-          seat_native->tablet_cursors = g_hash_table_new_full (NULL, NULL, NULL,
-                                                               g_object_unref);
-        }
-
-      cursor_renderer = meta_cursor_renderer_new (meta_get_backend (), device);
-      g_hash_table_insert (seat_native->tablet_cursors,
-                           device, cursor_renderer);
-      return TRUE;
-    }
-  else if (event_type == CLUTTER_PROXIMITY_OUT)
+  if (event_type == CLUTTER_PROXIMITY_OUT)
     {
       if (seat_native->tablet_cursors)
         g_hash_table_remove (seat_native->tablet_cursors, device);
@@ -619,9 +604,29 @@ meta_seat_native_maybe_ensure_cursor_renderer (MetaSeatNative     *seat_native,
       return seat_native->cursor_renderer;
     }
 
-  if (seat_native->tablet_cursors &&
-      clutter_input_device_get_device_type (device) == CLUTTER_TABLET_DEVICE)
-    return g_hash_table_lookup (seat_native->tablet_cursors, device);
+  if (clutter_input_device_get_device_type (device) == CLUTTER_TABLET_DEVICE)
+    {
+      MetaCursorRenderer *cursor_renderer = NULL;
+
+      if (!seat_native->tablet_cursors)
+        {
+          seat_native->tablet_cursors = g_hash_table_new_full (NULL, NULL, NULL,
+                                                               g_object_unref);
+        }
+      else
+        {
+          cursor_renderer = g_hash_table_lookup (seat_native->tablet_cursors, device);
+        }
+
+      if (!cursor_renderer)
+        {
+          cursor_renderer = meta_cursor_renderer_new (meta_get_backend (), device);
+          g_hash_table_insert (seat_native->tablet_cursors,
+                               device, cursor_renderer);
+        }
+
+      return cursor_renderer;
+    }
 
   return NULL;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]