tests: Rewrite interactive Clutter grabs tests

So it uses ClutterGrab, instead of an API that is soon to disappear.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2100>
This commit is contained in:
Carlos Garnacho 2021-11-19 17:35:44 +01:00
parent d51469ea2a
commit b8853b07a5

View File

@ -106,9 +106,12 @@ grab_pointer_cb (ClutterActor *actor,
ClutterEvent *event, ClutterEvent *event,
gpointer data) 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; return FALSE;
} }
@ -117,9 +120,11 @@ red_release_cb (ClutterActor *actor,
ClutterEvent *event, ClutterEvent *event,
gpointer data) 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; return FALSE;
} }
@ -137,15 +142,20 @@ toggle_grab_pointer_cb (ClutterActor *actor,
ClutterEvent *event, ClutterEvent *event,
gpointer data) gpointer data)
{ {
ClutterInputDevice *device = clutter_event_get_device (event);
/* we only deal with the event if the source is ourself */ /* we only deal with the event if the source is ourself */
if (event->button.source == actor) if (event->button.source == actor)
{ {
if (clutter_input_device_get_grabbed_actor (device) != NULL) ClutterStage *stage = CLUTTER_STAGE (clutter_actor_get_stage (actor));
clutter_input_device_ungrab (device); ClutterGrab *grab;
grab = g_object_get_data (G_OBJECT (actor), "grab-data");
if (grab)
g_clear_pointer (&grab, clutter_grab_dismiss);
else 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; return FALSE;
@ -156,14 +166,17 @@ cyan_press_cb (ClutterActor *actor,
ClutterEvent *event, ClutterEvent *event,
gpointer data) gpointer data)
{ {
ClutterBackend *backend = clutter_get_default_backend (); ClutterStage *stage = CLUTTER_STAGE (clutter_actor_get_stage (actor));
ClutterSeat *seat = clutter_backend_get_default_seat (backend); ClutterGrab *grab;
ClutterInputDevice *device = clutter_seat_get_pointer (seat);
if (clutter_input_device_get_grabbed_actor (device) != NULL) grab = g_object_get_data (G_OBJECT (actor), "grab-data");
clutter_input_device_ungrab (device);
if (grab)
g_clear_pointer (&grab, clutter_grab_dismiss);
else 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; return FALSE;
} }