wayland: Avoid getting the ClutterStage through ClutterEvents

Fetch the ClutterStage through other means, as that field will go
away from events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
This commit is contained in:
Carlos Garnacho 2023-08-02 20:10:52 +02:00
parent af9d406610
commit 77510ca72d
4 changed files with 40 additions and 4 deletions

View File

@ -650,7 +650,10 @@ repick_for_event (MetaWaylandPointer *pointer,
} }
else else
{ {
actor = clutter_stage_get_device_actor (clutter_event_get_stage (for_event), MetaBackend *backend = backend_from_pointer (pointer);
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
actor = clutter_stage_get_device_actor (stage,
clutter_event_get_device (for_event), clutter_event_get_device (for_event),
clutter_event_get_event_sequence (for_event)); clutter_event_get_event_sequence (for_event));
} }

View File

@ -581,9 +581,11 @@ static void
repick_for_event (MetaWaylandTabletTool *tool, repick_for_event (MetaWaylandTabletTool *tool,
const ClutterEvent *for_event) const ClutterEvent *for_event)
{ {
MetaBackend *backend = backend_from_tool (tool);
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
ClutterActor *actor; ClutterActor *actor;
actor = clutter_stage_get_device_actor (clutter_event_get_stage (for_event), actor = clutter_stage_get_device_actor (stage,
clutter_event_get_device (for_event), clutter_event_get_device (for_event),
clutter_event_get_event_sequence (for_event)); clutter_event_get_event_sequence (for_event));

View File

@ -96,6 +96,16 @@ G_DECLARE_FINAL_TYPE (MetaWaylandTextInputFocus, meta_wayland_text_input_focus,
G_DEFINE_TYPE (MetaWaylandTextInputFocus, meta_wayland_text_input_focus, G_DEFINE_TYPE (MetaWaylandTextInputFocus, meta_wayland_text_input_focus,
CLUTTER_TYPE_INPUT_FOCUS) CLUTTER_TYPE_INPUT_FOCUS)
static MetaBackend *
backend_from_text_input (MetaWaylandTextInput *text_input)
{
MetaWaylandSeat *seat = text_input->seat;
MetaWaylandCompositor *compositor = meta_wayland_seat_get_compositor (seat);
MetaContext *context = meta_wayland_compositor_get_context (compositor);
return meta_context_get_backend (context);
}
static void static void
meta_wayland_text_input_focus_request_surrounding (ClutterInputFocus *focus) meta_wayland_text_input_focus_request_surrounding (ClutterInputFocus *focus)
{ {
@ -836,9 +846,14 @@ meta_wayland_text_input_handle_event (MetaWaylandTextInput *text_input,
event->type == CLUTTER_TOUCH_BEGIN) event->type == CLUTTER_TOUCH_BEGIN)
{ {
MetaWaylandSurface *surface = NULL; MetaWaylandSurface *surface = NULL;
MetaBackend *backend;
ClutterStage *stage;
ClutterActor *actor; ClutterActor *actor;
actor = clutter_stage_get_device_actor (clutter_event_get_stage (event), backend = backend_from_text_input (text_input);
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
actor = clutter_stage_get_device_actor (stage,
clutter_event_get_device (event), clutter_event_get_device (event),
clutter_event_get_event_sequence (event)); clutter_event_get_event_sequence (event));

View File

@ -54,6 +54,17 @@ struct _MetaWaylandTouchInfo
guint begin_delivered : 1; guint begin_delivered : 1;
}; };
static MetaBackend *
backend_from_touch (MetaWaylandTouch *touch)
{
MetaWaylandInputDevice *input_device = META_WAYLAND_INPUT_DEVICE (touch);
MetaWaylandSeat *seat = meta_wayland_input_device_get_seat (input_device);
MetaWaylandCompositor *compositor = meta_wayland_seat_get_compositor (seat);
MetaContext *context = meta_wayland_compositor_get_context (compositor);
return meta_context_get_backend (context);
}
static void static void
move_resources (struct wl_list *destination, struct wl_list *source) move_resources (struct wl_list *destination, struct wl_list *source)
{ {
@ -218,9 +229,14 @@ meta_wayland_touch_update (MetaWaylandTouch *touch,
if (event->type == CLUTTER_TOUCH_BEGIN) if (event->type == CLUTTER_TOUCH_BEGIN)
{ {
MetaWaylandSurface *surface = NULL; MetaWaylandSurface *surface = NULL;
MetaBackend *backend;
ClutterStage *stage;
ClutterActor *actor; ClutterActor *actor;
actor = clutter_stage_get_device_actor (clutter_event_get_stage (event), backend = backend_from_touch (touch);
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
actor = clutter_stage_get_device_actor (stage,
clutter_event_get_device (event), clutter_event_get_device (event),
clutter_event_get_event_sequence (event)); clutter_event_get_event_sequence (event));