From f53adae27827199d54e04a216721a485e6db746d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 27 Feb 2024 13:16:49 +0100 Subject: [PATCH] wayland: Avoid MetaWaylandPointer struct peeking in touchpad gestures Use getters for the MetaWaylandPointerClient and MetaWaylandSurface for the logical focus. Part-of: --- src/wayland/meta-wayland-pointer-gesture-hold.c | 10 ++++++---- src/wayland/meta-wayland-pointer-gesture-pinch.c | 12 +++++++----- src/wayland/meta-wayland-pointer-gesture-swipe.c | 12 +++++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/wayland/meta-wayland-pointer-gesture-hold.c b/src/wayland/meta-wayland-pointer-gesture-hold.c index 50d08ec02..e9eba45bf 100644 --- a/src/wayland/meta-wayland-pointer-gesture-hold.c +++ b/src/wayland/meta-wayland-pointer-gesture-hold.c @@ -35,10 +35,12 @@ handle_hold_begin (MetaWaylandPointer *pointer, { MetaWaylandPointerClient *pointer_client; MetaWaylandSeat *seat; + MetaWaylandSurface *focus_surface; struct wl_resource *resource; uint32_t serial, fingers; - pointer_client = pointer->focus_client; + pointer_client = meta_wayland_pointer_get_focus_client (pointer); + focus_surface = meta_wayland_pointer_get_focus_surface (pointer); seat = meta_wayland_pointer_get_seat (pointer); serial = wl_display_next_serial (seat->wl_display); fingers = clutter_event_get_touchpad_gesture_finger_count (event); @@ -49,7 +51,7 @@ handle_hold_begin (MetaWaylandPointer *pointer, { zwp_pointer_gesture_hold_v1_send_begin (resource, serial, clutter_event_get_time (event), - pointer->focus_surface->resource, + focus_surface->resource, fingers); } } @@ -63,7 +65,7 @@ broadcast_end (MetaWaylandPointer *pointer, MetaWaylandPointerClient *pointer_client; struct wl_resource *resource; - pointer_client = pointer->focus_client; + pointer_client = meta_wayland_pointer_get_focus_client (pointer); wl_resource_for_each (resource, &pointer_client->hold_gesture_resources) { @@ -101,7 +103,7 @@ meta_wayland_pointer_gesture_hold_handle_event (MetaWaylandPointer *pointer, if (clutter_event_type (event) != CLUTTER_TOUCHPAD_HOLD) return FALSE; - if (!pointer->focus_client) + if (!meta_wayland_pointer_get_focus_client (pointer)) return FALSE; switch (clutter_event_get_gesture_phase (event)) diff --git a/src/wayland/meta-wayland-pointer-gesture-pinch.c b/src/wayland/meta-wayland-pointer-gesture-pinch.c index 07a2d125e..b9f4b9aba 100644 --- a/src/wayland/meta-wayland-pointer-gesture-pinch.c +++ b/src/wayland/meta-wayland-pointer-gesture-pinch.c @@ -37,10 +37,12 @@ handle_pinch_begin (MetaWaylandPointer *pointer, { MetaWaylandPointerClient *pointer_client; MetaWaylandSeat *seat; + MetaWaylandSurface *focus_surface; struct wl_resource *resource; uint32_t serial, fingers; - pointer_client = pointer->focus_client; + pointer_client = meta_wayland_pointer_get_focus_client (pointer); + focus_surface = meta_wayland_pointer_get_focus_surface (pointer); seat = meta_wayland_pointer_get_seat (pointer); serial = wl_display_next_serial (seat->wl_display); fingers = clutter_event_get_touchpad_gesture_finger_count (event); @@ -51,7 +53,7 @@ handle_pinch_begin (MetaWaylandPointer *pointer, { zwp_pointer_gesture_pinch_v1_send_begin (resource, serial, clutter_event_get_time (event), - pointer->focus_surface->resource, + focus_surface->resource, fingers); } } @@ -64,7 +66,7 @@ handle_pinch_update (MetaWaylandPointer *pointer, struct wl_resource *resource; gdouble dx, dy, scale, rotation; - pointer_client = pointer->focus_client; + pointer_client = meta_wayland_pointer_get_focus_client (pointer); clutter_event_get_gesture_motion_delta (event, &dx, &dy); rotation = clutter_event_get_gesture_pinch_angle_delta (event); scale = clutter_event_get_gesture_pinch_scale (event); @@ -89,7 +91,7 @@ broadcast_end (MetaWaylandPointer *pointer, MetaWaylandPointerClient *pointer_client; struct wl_resource *resource; - pointer_client = pointer->focus_client; + pointer_client = meta_wayland_pointer_get_focus_client (pointer); wl_resource_for_each (resource, &pointer_client->pinch_gesture_resources) { @@ -127,7 +129,7 @@ meta_wayland_pointer_gesture_pinch_handle_event (MetaWaylandPointer *pointer, if (clutter_event_type (event) != CLUTTER_TOUCHPAD_PINCH) return FALSE; - if (!pointer->focus_client) + if (!meta_wayland_pointer_get_focus_client (pointer)) return FALSE; switch (clutter_event_get_gesture_phase (event)) diff --git a/src/wayland/meta-wayland-pointer-gesture-swipe.c b/src/wayland/meta-wayland-pointer-gesture-swipe.c index 22f357860..6d7917f1b 100644 --- a/src/wayland/meta-wayland-pointer-gesture-swipe.c +++ b/src/wayland/meta-wayland-pointer-gesture-swipe.c @@ -37,10 +37,12 @@ handle_swipe_begin (MetaWaylandPointer *pointer, { MetaWaylandPointerClient *pointer_client; MetaWaylandSeat *seat; + MetaWaylandSurface *focus_surface; struct wl_resource *resource; uint32_t serial, fingers; - pointer_client = pointer->focus_client; + pointer_client = meta_wayland_pointer_get_focus_client (pointer); + focus_surface = meta_wayland_pointer_get_focus_surface (pointer); seat = meta_wayland_pointer_get_seat (pointer); serial = wl_display_next_serial (seat->wl_display); fingers = clutter_event_get_touchpad_gesture_finger_count (event); @@ -51,7 +53,7 @@ handle_swipe_begin (MetaWaylandPointer *pointer, { zwp_pointer_gesture_swipe_v1_send_begin (resource, serial, clutter_event_get_time (event), - pointer->focus_surface->resource, + focus_surface->resource, fingers); } } @@ -64,7 +66,7 @@ handle_swipe_update (MetaWaylandPointer *pointer, struct wl_resource *resource; gdouble dx, dy; - pointer_client = pointer->focus_client; + pointer_client = meta_wayland_pointer_get_focus_client (pointer); clutter_event_get_gesture_motion_delta (event, &dx, &dy); wl_resource_for_each (resource, &pointer_client->swipe_gesture_resources) @@ -85,7 +87,7 @@ broadcast_end (MetaWaylandPointer *pointer, MetaWaylandPointerClient *pointer_client; struct wl_resource *resource; - pointer_client = pointer->focus_client; + pointer_client = meta_wayland_pointer_get_focus_client (pointer); wl_resource_for_each (resource, &pointer_client->swipe_gesture_resources) { @@ -123,7 +125,7 @@ meta_wayland_pointer_gesture_swipe_handle_event (MetaWaylandPointer *pointer, if (clutter_event_type (event) != CLUTTER_TOUCHPAD_SWIPE) return FALSE; - if (!pointer->focus_client) + if (!meta_wayland_pointer_get_focus_client (pointer)) return FALSE; switch (clutter_event_get_gesture_phase (event))