[mutter/wip/carlosg/clutter-seat: 71/81] wayland: Replace ClutterDeviceManager usage in favor of ClutterSeat



commit 7db5051f4505cd33c8549a018f904fe7fc9c411b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Oct 4 14:01:19 2019 +0200

    wayland: Replace ClutterDeviceManager usage in favor of ClutterSeat

 src/wayland/meta-wayland-pointer.c        |  6 ++---
 src/wayland/meta-wayland-seat.c           | 38 ++++++++++++++++---------------
 src/wayland/meta-wayland-tablet-manager.c |  5 ----
 src/wayland/meta-wayland-tablet-seat.c    | 24 +++++++++++--------
 src/wayland/meta-wayland-tablet-seat.h    |  2 +-
 src/wayland/meta-wayland-touch.c          |  6 -----
 src/wayland/meta-wayland-touch.h          |  1 -
 7 files changed, 38 insertions(+), 44 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 751f6b9b9..743ff7484 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -499,7 +499,7 @@ meta_wayland_pointer_enable (MetaWaylandPointer *pointer)
 {
   MetaBackend *backend = meta_get_backend ();
   MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
-  ClutterDeviceManager *manager;
+  ClutterSeat *clutter_seat;
 
   pointer->pointer_clients =
     g_hash_table_new_full (NULL, NULL, NULL,
@@ -507,8 +507,8 @@ meta_wayland_pointer_enable (MetaWaylandPointer *pointer)
 
   pointer->cursor_surface = NULL;
 
-  manager = clutter_device_manager_get_default ();
-  pointer->device = clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE);
+  clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
+  pointer->device = clutter_seat_get_pointer (clutter_seat);
 
   g_signal_connect (cursor_tracker,
                     "cursor-changed",
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index 91fe376ff..dd4711947 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -99,12 +99,12 @@ bind_seat (struct wl_client *client,
 }
 
 static uint32_t
-lookup_device_capabilities (ClutterDeviceManager *device_manager)
+lookup_device_capabilities (ClutterSeat *seat)
 {
-  const GSList *devices, *l;
+  GList *devices, *l;
   uint32_t capabilities = 0;
 
-  devices = clutter_device_manager_peek_devices (device_manager);
+  devices = clutter_seat_list_devices (seat);
 
   for (l = devices; l; l = l->next)
     {
@@ -139,6 +139,8 @@ lookup_device_capabilities (ClutterDeviceManager *device_manager)
         }
     }
 
+  g_list_free (devices);
+
   return capabilities;
 }
 
@@ -188,21 +190,21 @@ meta_wayland_seat_set_capabilities (MetaWaylandSeat *seat,
 }
 
 static void
-meta_wayland_seat_update_capabilities (MetaWaylandSeat      *seat,
-                                       ClutterDeviceManager *device_manager)
+meta_wayland_seat_update_capabilities (MetaWaylandSeat *seat,
+                                      ClutterSeat     *clutter_seat)
 {
   uint32_t capabilities;
 
-  capabilities = lookup_device_capabilities (device_manager);
+  capabilities = lookup_device_capabilities (clutter_seat);
   meta_wayland_seat_set_capabilities (seat, capabilities);
 }
 
 static void
-meta_wayland_seat_devices_updated (ClutterDeviceManager *device_manager,
-                                   ClutterInputDevice   *input_device,
-                                   MetaWaylandSeat      *seat)
+meta_wayland_seat_devices_updated (ClutterSeat        *clutter_seat,
+                                   ClutterInputDevice *input_device,
+                                   MetaWaylandSeat    *seat)
 {
-  meta_wayland_seat_update_capabilities (seat, device_manager);
+  meta_wayland_seat_update_capabilities (seat, clutter_seat);
 }
 
 static MetaWaylandSeat *
@@ -210,7 +212,7 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor,
                        struct wl_display     *display)
 {
   MetaWaylandSeat *seat = g_new0 (MetaWaylandSeat, 1);
-  ClutterDeviceManager *device_manager;
+  ClutterSeat *clutter_seat;
 
   wl_list_init (&seat->base_resource_list);
   seat->wl_display = display;
@@ -230,11 +232,11 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor,
 
   meta_wayland_data_device_init (&seat->data_device);
 
-  device_manager = clutter_device_manager_get_default ();
-  meta_wayland_seat_update_capabilities (seat, device_manager);
-  g_signal_connect (device_manager, "device-added",
+  clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
+  meta_wayland_seat_update_capabilities (seat, clutter_seat);
+  g_signal_connect (clutter_seat, "device-added",
                     G_CALLBACK (meta_wayland_seat_devices_updated), seat);
-  g_signal_connect (device_manager, "device-removed",
+  g_signal_connect (clutter_seat, "device-removed",
                     G_CALLBACK (meta_wayland_seat_devices_updated), seat);
 
   wl_global_create (display, &wl_seat_interface, META_WL_SEAT_VERSION, seat, bind_seat);
@@ -254,10 +256,10 @@ meta_wayland_seat_init (MetaWaylandCompositor *compositor)
 void
 meta_wayland_seat_free (MetaWaylandSeat *seat)
 {
-  ClutterDeviceManager *device_manager;
+  ClutterSeat *clutter_seat;
 
-  device_manager = clutter_device_manager_get_default ();
-  g_signal_handlers_disconnect_by_data (device_manager, seat);
+  clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
+  g_signal_handlers_disconnect_by_data (clutter_seat, seat);
   meta_wayland_seat_set_capabilities (seat, 0);
 
   g_object_unref (seat->pointer);
diff --git a/src/wayland/meta-wayland-tablet-manager.c b/src/wayland/meta-wayland-tablet-manager.c
index 018d81940..7810f7b59 100644
--- a/src/wayland/meta-wayland-tablet-manager.c
+++ b/src/wayland/meta-wayland-tablet-manager.c
@@ -131,11 +131,6 @@ meta_wayland_tablet_manager_init (MetaWaylandCompositor *compositor)
 void
 meta_wayland_tablet_manager_free (MetaWaylandTabletManager *tablet_manager)
 {
-  ClutterDeviceManager *device_manager;
-
-  device_manager = clutter_device_manager_get_default ();
-  g_signal_handlers_disconnect_by_data (device_manager, tablet_manager);
-
   g_hash_table_destroy (tablet_manager->seats);
   g_slice_free (MetaWaylandTabletManager, tablet_manager);
 }
diff --git a/src/wayland/meta-wayland-tablet-seat.c b/src/wayland/meta-wayland-tablet-seat.c
index b4bc4aa58..83c3f71aa 100644
--- a/src/wayland/meta-wayland-tablet-seat.c
+++ b/src/wayland/meta-wayland-tablet-seat.c
@@ -260,12 +260,12 @@ meta_wayland_tablet_seat_new (MetaWaylandTabletManager *manager,
                               MetaWaylandSeat          *seat)
 {
   MetaWaylandTabletSeat *tablet_seat;
-  const GSList *devices, *l;
+  GList *devices, *l;
 
   tablet_seat = g_slice_new0 (MetaWaylandTabletSeat);
   tablet_seat->manager = manager;
   tablet_seat->seat = seat;
-  tablet_seat->device_manager = clutter_device_manager_get_default ();
+  tablet_seat->clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
   tablet_seat->tablets = g_hash_table_new_full (NULL, NULL, NULL,
                                                 (GDestroyNotify) meta_wayland_tablet_free);
   tablet_seat->tools = g_hash_table_new_full (NULL, NULL, NULL,
@@ -274,18 +274,20 @@ meta_wayland_tablet_seat_new (MetaWaylandTabletManager *manager,
                                              (GDestroyNotify) meta_wayland_tablet_pad_free);
   wl_list_init (&tablet_seat->resource_list);
 
-  g_signal_connect_swapped (tablet_seat->device_manager, "device-added",
+  g_signal_connect_swapped (tablet_seat->clutter_seat, "device-added",
                             G_CALLBACK (meta_wayland_tablet_seat_device_added),
                             tablet_seat);
-  g_signal_connect_swapped (tablet_seat->device_manager, "device-removed",
+  g_signal_connect_swapped (tablet_seat->clutter_seat, "device-removed",
                             G_CALLBACK (meta_wayland_tablet_seat_device_removed),
                             tablet_seat);
 
-  devices = clutter_device_manager_peek_devices (tablet_seat->device_manager);
+  devices = clutter_seat_list_devices (tablet_seat->clutter_seat);
 
   for (l = devices; l; l = l->next)
     meta_wayland_tablet_seat_device_added (tablet_seat, l->data);
 
+  g_list_free (devices);
+
   return tablet_seat;
 }
 
@@ -300,7 +302,7 @@ meta_wayland_tablet_seat_free (MetaWaylandTabletSeat *tablet_seat)
       wl_list_init (wl_resource_get_link (resource));
     }
 
-  g_signal_handlers_disconnect_by_data (tablet_seat->device_manager,
+  g_signal_handlers_disconnect_by_data (tablet_seat->clutter_seat,
                                         tablet_seat);
   g_hash_table_destroy (tablet_seat->tablets);
   g_hash_table_destroy (tablet_seat->tools);
@@ -476,12 +478,12 @@ static GList *
 lookup_grouped_devices (ClutterInputDevice     *device,
                         ClutterInputDeviceType  type)
 {
-  ClutterDeviceManager *device_manager;
-  const GSList *devices, *l;
+  ClutterSeat *clutter_seat;
+  GList *devices, *l;
   GList *group = NULL;
 
-  device_manager = clutter_device_manager_get_default ();
-  devices = clutter_device_manager_peek_devices (device_manager);
+  clutter_seat = clutter_input_device_get_seat (device);
+  devices = clutter_seat_list_devices (clutter_seat);
 
   for (l = devices; l; l = l->next)
     {
@@ -496,6 +498,8 @@ lookup_grouped_devices (ClutterInputDevice     *device,
       group = g_list_prepend (group, l->data);
     }
 
+  g_list_free (devices);
+
   return group;
 }
 
diff --git a/src/wayland/meta-wayland-tablet-seat.h b/src/wayland/meta-wayland-tablet-seat.h
index c083dec5f..897cc4c5d 100644
--- a/src/wayland/meta-wayland-tablet-seat.h
+++ b/src/wayland/meta-wayland-tablet-seat.h
@@ -31,7 +31,7 @@ struct _MetaWaylandTabletSeat
 {
   MetaWaylandTabletManager *manager;
   MetaWaylandSeat *seat;
-  ClutterDeviceManager *device_manager;
+  ClutterSeat *clutter_seat;
   struct wl_list resource_list;
 
   GHashTable *tablets;
diff --git a/src/wayland/meta-wayland-touch.c b/src/wayland/meta-wayland-touch.c
index 9f7f9f7e0..9c2cfc9df 100644
--- a/src/wayland/meta-wayland-touch.c
+++ b/src/wayland/meta-wayland-touch.c
@@ -32,7 +32,6 @@
 #ifdef HAVE_NATIVE_BACKEND
 #include <libinput.h>
 #include "backends/native/meta-backend-native.h"
-#include "backends/native/meta-device-manager-native.h"
 #include "backends/native/meta-event-native.h"
 #include "backends/native/meta-seat-native.h"
 #endif
@@ -554,8 +553,6 @@ evdev_filter_func (struct libinput_event *event,
 void
 meta_wayland_touch_enable (MetaWaylandTouch *touch)
 {
-  ClutterDeviceManager *manager;
-
 #ifdef HAVE_NATIVE_BACKEND
   touch->touch_surfaces = g_hash_table_new_full (NULL, NULL, NULL,
                                                  (GDestroyNotify) touch_surface_free);
@@ -565,9 +562,6 @@ meta_wayland_touch_enable (MetaWaylandTouch *touch)
 
   wl_list_init (&touch->resource_list);
 
-  manager = clutter_device_manager_get_default ();
-  touch->device = clutter_device_manager_get_core_device (manager, CLUTTER_TOUCHSCREEN_DEVICE);
-
 #ifdef HAVE_NATIVE_BACKEND
   MetaBackend *backend = meta_get_backend ();
   if (META_IS_BACKEND_NATIVE (backend))
diff --git a/src/wayland/meta-wayland-touch.h b/src/wayland/meta-wayland-touch.h
index a7db10328..f2efcb1ba 100644
--- a/src/wayland/meta-wayland-touch.h
+++ b/src/wayland/meta-wayland-touch.h
@@ -44,7 +44,6 @@ struct _MetaWaylandTouch
   GHashTable *touch_surfaces; /* HT of MetaWaylandSurface->MetaWaylandTouchSurface */
   GHashTable *touches; /* HT of sequence->MetaWaylandTouchInfo */
 
-  ClutterInputDevice *device;
   guint64 frame_slots;
 };
 


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