[mutter/wip/carlosg/grabs-pt3: 19/23] tests: Rewrite interactive Clutter grabs tests
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/grabs-pt3: 19/23] tests: Rewrite interactive Clutter grabs tests
- Date: Thu, 6 Jan 2022 01:06:53 +0000 (UTC)
commit 09c1f7db9f5efff368e52c3e55f8e8aad4043415
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 6dcf6ceb28..0fb2989cd0 100644
--- a/src/tests/clutter/interactive/test-grab.c
+++ b/src/tests/clutter/interactive/test-grab.c
@@ -106,9 +106,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_stage_grab (stage, actor);
+ g_object_set_data (G_OBJECT (actor), "grab-data", grab);
- clutter_input_device_grab (device, actor);
return FALSE;
}
@@ -117,9 +120,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_grab_dismiss (grab);
- clutter_input_device_ungrab (device);
return FALSE;
}
@@ -137,15 +142,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_grab_dismiss);
else
- clutter_input_device_grab (device, actor);
+ grab = clutter_stage_grab (stage, actor);
+
+ g_object_set_data (G_OBJECT (actor), "grab-data", grab);
}
return FALSE;
@@ -156,14 +166,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_grab_dismiss);
else
- clutter_input_device_grab (device, actor);
+ grab = clutter_stage_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]