[mutter/wip/carlosg/grabs-pt3: 1/4] tests: Rewrite interactive Clutter grabs tests




commit 0dcbb4d45c883f9604f0c170ec832fceddbdfafc
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Nov 19 17:35:44 2021 +0100

    tests: Rewrite interactive Clutter grabs tests
    
    So it uses ClutterGrab, instead of an API that is soon to disappear.

 src/tests/clutter/interactive/test-grab.c | 43 ++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/src/tests/clutter/interactive/test-grab.c b/src/tests/clutter/interactive/test-grab.c
index 4c421b3e97..da208eba44 100644
--- a/src/tests/clutter/interactive/test-grab.c
+++ b/src/tests/clutter/interactive/test-grab.c
@@ -103,9 +103,12 @@ grab_pointer_cb (ClutterActor    *actor,
                  ClutterEvent    *event,
                  gpointer         data)
 {
-  ClutterInputDevice *device = clutter_event_get_device (event);
+  ClutterStage *stage = CLUTTER_STAGE (clutter_actor_get_stage (actor));
+  ClutterGrab *grab;
+
+  grab = clutter_grab (stage, actor);
+  g_object_set_data (G_OBJECT (actor), "grab-data", grab);
 
-  clutter_input_device_grab (device, actor);
   return FALSE;
 }
 
@@ -114,9 +117,11 @@ red_release_cb (ClutterActor    *actor,
                 ClutterEvent    *event,
                 gpointer         data)
 {
-  ClutterInputDevice *device = clutter_event_get_device (event);
+  ClutterGrab *grab;
+
+  grab = g_object_steal_data (G_OBJECT (actor), "grab-data");
+  clutter_ungrab (grab);
 
-  clutter_input_device_ungrab (device);
   return FALSE;
 }
 
@@ -134,15 +139,20 @@ toggle_grab_pointer_cb (ClutterActor    *actor,
                         ClutterEvent    *event,
                         gpointer         data)
 {
-  ClutterInputDevice *device = clutter_event_get_device (event);
-
   /* we only deal with the event if the source is ourself */
   if (event->button.source == actor)
     {
-      if (clutter_input_device_get_grabbed_actor (device) != NULL)
-        clutter_input_device_ungrab (device);
+      ClutterStage *stage = CLUTTER_STAGE (clutter_actor_get_stage (actor));
+      ClutterGrab *grab;
+
+      grab = g_object_get_data (G_OBJECT (actor), "grab-data");
+
+      if (grab)
+        g_clear_pointer (&grab, clutter_ungrab);
       else
-        clutter_input_device_grab (device, actor);
+        grab = clutter_grab (stage, actor);
+
+      g_object_set_data (G_OBJECT (actor), "grab-data", grab);
     }
 
   return FALSE;
@@ -153,14 +163,17 @@ cyan_press_cb (ClutterActor    *actor,
                ClutterEvent    *event,
                gpointer         data)
 {
-  ClutterBackend *backend = clutter_get_default_backend ();
-  ClutterSeat *seat = clutter_backend_get_default_seat (backend);
-  ClutterInputDevice *device = clutter_seat_get_pointer (seat);
+  ClutterStage *stage = CLUTTER_STAGE (clutter_actor_get_stage (actor));
+  ClutterGrab *grab;
 
-  if (clutter_input_device_get_grabbed_actor (device) != NULL)
-    clutter_input_device_ungrab (device);
+  grab = g_object_get_data (G_OBJECT (actor), "grab-data");
+
+  if (grab)
+    g_clear_pointer (&grab, clutter_ungrab);
   else
-    clutter_input_device_grab (device, actor);
+    grab = clutter_grab (stage, actor);
+
+  g_object_set_data (G_OBJECT (actor), "grab-data", grab);
 
   return FALSE;
 }


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