1
0
Fork 0

wayland/seat: Keep a back pointer to the ClutterSeat

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3989>
This commit is contained in:
Bilal Elmoussaoui 2024-08-24 09:52:24 +02:00 committed by Jonas Ådahl
parent ea902ac928
commit 6a694d64f4
3 changed files with 15 additions and 23 deletions

View file

@ -961,12 +961,7 @@ locked_pointer_destroy (struct wl_client *client,
wl_resource_destroy (resource); wl_resource_destroy (resource);
if (warp_pointer) if (warp_pointer)
{ clutter_seat_warp_pointer (constraint->seat->clutter_seat, warp_x, warp_y);
ClutterSeat *seat;
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
clutter_seat_warp_pointer (seat, warp_x, warp_y);
}
} }
static void static void

View file

@ -274,14 +274,18 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor,
struct wl_display *display) struct wl_display *display)
{ {
MetaWaylandSeat *seat; MetaWaylandSeat *seat;
ClutterSeat *clutter_seat; MetaContext *context =
meta_wayland_compositor_get_context (compositor);
MetaBackend *backend = meta_context_get_backend (context);
ClutterBackend *clutter_backend =
meta_backend_get_clutter_backend (backend);
seat = g_new0 (MetaWaylandSeat, 1); seat = g_new0 (MetaWaylandSeat, 1);
seat->compositor = compositor; seat->compositor = compositor;
wl_list_init (&seat->base_resource_list); wl_list_init (&seat->base_resource_list);
seat->wl_display = display; seat->wl_display = display;
seat->clutter_seat = clutter_backend_get_default_seat (clutter_backend);
seat->pointer = g_object_new (META_TYPE_WAYLAND_POINTER, seat->pointer = g_object_new (META_TYPE_WAYLAND_POINTER,
"seat", seat, "seat", seat,
NULL); NULL);
@ -297,11 +301,10 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor,
meta_wayland_data_device_init (&seat->data_device, seat); meta_wayland_data_device_init (&seat->data_device, seat);
meta_wayland_data_device_primary_init (&seat->primary_data_device, seat); meta_wayland_data_device_primary_init (&seat->primary_data_device, seat);
clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); meta_wayland_seat_update_capabilities (seat, seat->clutter_seat);
meta_wayland_seat_update_capabilities (seat, clutter_seat); g_signal_connect (seat->clutter_seat, "device-added",
g_signal_connect (clutter_seat, "device-added",
G_CALLBACK (meta_wayland_seat_devices_updated), seat); G_CALLBACK (meta_wayland_seat_devices_updated), seat);
g_signal_connect (clutter_seat, "device-removed", g_signal_connect (seat->clutter_seat, "device-removed",
G_CALLBACK (meta_wayland_seat_devices_updated), seat); G_CALLBACK (meta_wayland_seat_devices_updated), seat);
wl_global_create (display, &wl_seat_interface, META_WL_SEAT_VERSION, seat, bind_seat); wl_global_create (display, &wl_seat_interface, META_WL_SEAT_VERSION, seat, bind_seat);
@ -328,12 +331,10 @@ meta_wayland_seat_init (MetaWaylandCompositor *compositor)
void void
meta_wayland_seat_free (MetaWaylandSeat *seat) meta_wayland_seat_free (MetaWaylandSeat *seat)
{ {
ClutterSeat *clutter_seat;
g_clear_object (&seat->input_handler); g_clear_object (&seat->input_handler);
clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); g_signal_handlers_disconnect_by_data (seat->clutter_seat, seat);
g_signal_handlers_disconnect_by_data (clutter_seat, seat);
meta_wayland_seat_set_capabilities (seat, 0); meta_wayland_seat_set_capabilities (seat, 0);
g_object_unref (seat->pointer); g_object_unref (seat->pointer);
@ -547,8 +548,6 @@ void
meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat, meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat,
MetaWaylandSurface *surface) MetaWaylandSurface *surface)
{ {
ClutterSeat *clutter_seat;
if (seat->input_focus == surface) if (seat->input_focus == surface)
return; return;
@ -569,9 +568,8 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat,
seat); seat);
} }
clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
meta_wayland_input_invalidate_focus (seat->input_handler, meta_wayland_input_invalidate_focus (seat->input_handler,
clutter_seat_get_keyboard (clutter_seat), clutter_seat_get_keyboard (seat->clutter_seat),
NULL); NULL);
} }
@ -600,11 +598,8 @@ meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat,
serial); serial);
if (sequence) if (sequence)
{ {
ClutterSeat *clutter_seat =
clutter_backend_get_default_seat (clutter_get_default_backend ());
if (device_out) if (device_out)
*device_out = clutter_seat_get_pointer (clutter_seat); *device_out = clutter_seat_get_pointer (seat->clutter_seat);
if (sequence_out) if (sequence_out)
*sequence_out = sequence; *sequence_out = sequence;

View file

@ -37,6 +37,8 @@ struct _MetaWaylandSeat
{ {
MetaWaylandCompositor *compositor; MetaWaylandCompositor *compositor;
ClutterSeat *clutter_seat;
struct wl_list base_resource_list; struct wl_list base_resource_list;
struct wl_display *wl_display; struct wl_display *wl_display;