pointer-lock/wayland: Get compositor from surface

This avoids trying to get it from an pointer that was never set to
anything.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2558
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2772>
This commit is contained in:
Jonas Ådahl 2022-12-18 09:56:41 +01:00
parent 439856e7aa
commit 2762a67000

View File

@ -52,17 +52,17 @@ G_DEFINE_TYPE (MetaPointerLockWayland, meta_pointer_lock_wayland,
static MetaPointerConstraint * static MetaPointerConstraint *
meta_pointer_lock_wayland_create_constraint (MetaPointerConfinementWayland *confinement) meta_pointer_lock_wayland_create_constraint (MetaPointerConfinementWayland *confinement)
{ {
MetaPointerLockWayland *lock_wayland = META_POINTER_LOCK_WAYLAND (confinement); MetaWaylandPointerConstraint *wayland_constraint =
MetaWaylandCompositor *compositor = meta_pointer_confinement_wayland_get_wayland_pointer_constraint (confinement);
meta_wayland_pointer_constraint_get_compositor (lock_wayland->constraint); MetaWaylandSurface *surface =
meta_wayland_pointer_constraint_get_surface (wayland_constraint);
MetaWaylandCompositor *compositor = surface->compositor;
MetaContext *context = meta_wayland_compositor_get_context (compositor); MetaContext *context = meta_wayland_compositor_get_context (compositor);
MetaBackend *backend = meta_context_get_backend (context); MetaBackend *backend = meta_context_get_backend (context);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend); ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
ClutterInputDevice *pointer = clutter_seat_get_pointer (seat); ClutterInputDevice *pointer = clutter_seat_get_pointer (seat);
MetaWaylandPointerConstraint *wayland_constraint;
MetaPointerConstraint *constraint; MetaPointerConstraint *constraint;
MetaWaylandSurface *surface;
graphene_point_t point; graphene_point_t point;
cairo_region_t *region; cairo_region_t *region;
float sx, sy, x, y; float sx, sy, x, y;