From ec435ea540920a58b8a396c78f8e5620dce0688d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 16 Nov 2023 13:42:15 +0100 Subject: [PATCH] wayland: Drop pointer grab interface This is now unused, with everything ported to MetaWaylandEventInterface. Part-of: --- src/wayland/meta-wayland-pointer.c | 126 +++++------------------------ src/wayland/meta-wayland-pointer.h | 26 ------ src/wayland/meta-wayland-seat.c | 4 - src/wayland/meta-wayland-types.h | 2 - 4 files changed, 18 insertions(+), 140 deletions(-) diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index c15e39fcc..b6e41810f 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -91,12 +91,6 @@ static void meta_wayland_pointer_set_current (MetaWaylandPointer *pointer, MetaWaylandSurface *surface); -static void -meta_wayland_pointer_reset_grab (MetaWaylandPointer *pointer); - -static void -meta_wayland_pointer_cancel_grab (MetaWaylandPointer *pointer); - static MetaBackend * backend_from_pointer (MetaWaylandPointer *pointer) { @@ -448,59 +442,6 @@ meta_wayland_pointer_send_button (MetaWaylandPointer *pointer, sync_focus_surface (pointer); } -static void -default_grab_focus (MetaWaylandPointerGrab *grab, - MetaWaylandSurface *surface) -{ - MetaWaylandPointer *pointer = grab->pointer; - MetaWaylandSeat *seat = meta_wayland_pointer_get_seat (pointer); - MetaBackend *backend = backend_from_pointer (pointer); - ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); - - if (!meta_wayland_seat_has_pointer (seat)) - return; - - if (clutter_stage_get_grab_actor (stage) != NULL) - return; - - if (surface) - { - MetaWindow *window = NULL; - - window = surface_get_effective_window (surface); - - /* Avoid focusing a non-alive surface */ - if (!window || !meta_window_get_alive (window)) - surface = NULL; - } - - meta_wayland_pointer_set_focus (pointer, surface); -} - -static void -default_grab_motion (MetaWaylandPointerGrab *grab, - const ClutterEvent *event) -{ - MetaWaylandPointer *pointer = grab->pointer; - - meta_wayland_pointer_send_motion (pointer, event); -} - -static void -default_grab_button (MetaWaylandPointerGrab *grab, - const ClutterEvent *event) -{ - MetaWaylandPointer *pointer = grab->pointer; - - meta_wayland_pointer_send_button (pointer, event); -} - -static const MetaWaylandPointerGrabInterface default_pointer_grab_interface = { - default_grab_focus, - default_grab_motion, - default_grab_button -}; - static void meta_wayland_pointer_on_cursor_changed (MetaCursorTracker *cursor_tracker, MetaWaylandPointer *pointer) @@ -547,8 +488,6 @@ meta_wayland_pointer_disable (MetaWaylandPointer *pointer) pointer->cursor_surface); } - meta_wayland_pointer_cancel_grab (pointer); - meta_wayland_pointer_reset_grab (pointer); meta_wayland_pointer_set_focus (pointer, NULL); meta_wayland_pointer_set_current (pointer, NULL); @@ -704,7 +643,7 @@ static void notify_motion (MetaWaylandPointer *pointer, const ClutterEvent *event) { - pointer->grab->interface->motion (pointer->grab, event); + meta_wayland_pointer_send_motion (pointer, event); } static void @@ -728,7 +667,7 @@ handle_button_event (MetaWaylandPointer *pointer, clutter_event_get_coords (event, &pointer->grab_x, &pointer->grab_y); } - pointer->grab->interface->button (pointer->grab, event); + meta_wayland_pointer_send_button (pointer, event); if (implicit_grab) { @@ -1095,48 +1034,28 @@ void meta_wayland_pointer_focus_surface (MetaWaylandPointer *pointer, MetaWaylandSurface *surface) { - const MetaWaylandPointerGrabInterface *interface = pointer->grab->interface; - interface->focus (pointer->grab, surface); -} + MetaWaylandSeat *seat = meta_wayland_pointer_get_seat (pointer); + MetaBackend *backend = backend_from_pointer (pointer); + ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); -void -meta_wayland_pointer_start_grab (MetaWaylandPointer *pointer, - MetaWaylandPointerGrab *grab) -{ - const MetaWaylandPointerGrabInterface *interface; + if (!meta_wayland_seat_has_pointer (seat)) + return; - meta_wayland_pointer_cancel_grab (pointer); + if (clutter_stage_get_grab_actor (stage) != NULL) + return; - pointer->grab = grab; - interface = pointer->grab->interface; - grab->pointer = pointer; + if (surface) + { + MetaWindow *window = NULL; - interface->focus (pointer->grab, pointer->current); -} + window = surface_get_effective_window (surface); -static void -meta_wayland_pointer_reset_grab (MetaWaylandPointer *pointer) -{ - pointer->grab = &pointer->default_grab; -} + /* Avoid focusing a non-alive surface */ + if (!window || !meta_window_get_alive (window)) + surface = NULL; + } -void -meta_wayland_pointer_end_grab (MetaWaylandPointer *pointer) -{ - const MetaWaylandPointerGrabInterface *interface; - - pointer->grab = &pointer->default_grab; - interface = pointer->grab->interface; - interface->focus (pointer->grab, pointer->current); - - meta_wayland_pointer_update_cursor_surface (pointer); -} - -static void -meta_wayland_pointer_cancel_grab (MetaWaylandPointer *pointer) -{ - if (pointer->grab->interface->cancel) - pointer->grab->interface->cancel (pointer->grab); + meta_wayland_pointer_set_focus (pointer, surface); } void @@ -1468,9 +1387,6 @@ meta_wayland_pointer_get_seat (MetaWaylandPointer *pointer) static void meta_wayland_pointer_init (MetaWaylandPointer *pointer) { - pointer->default_grab.interface = &default_pointer_grab_interface; - pointer->default_grab.pointer = pointer; - pointer->grab = &pointer->default_grab; pointer->pointer_clients = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) meta_wayland_pointer_client_free); @@ -1501,12 +1417,6 @@ meta_wayland_pointer_class_init (MetaWaylandPointerClass *klass) G_TYPE_NONE, 0); } -gboolean -meta_wayland_pointer_is_grabbed (MetaWaylandPointer *pointer) -{ - return pointer->grab != &pointer->default_grab; -} - MetaWaylandSurface * meta_wayland_pointer_get_current_surface (MetaWaylandPointer *pointer) { diff --git a/src/wayland/meta-wayland-pointer.h b/src/wayland/meta-wayland-pointer.h index b25fccbca..40ab7eb22 100644 --- a/src/wayland/meta-wayland-pointer.h +++ b/src/wayland/meta-wayland-pointer.h @@ -36,23 +36,6 @@ G_DECLARE_FINAL_TYPE (MetaWaylandPointer, meta_wayland_pointer, META, WAYLAND_POINTER, MetaWaylandInputDevice) -struct _MetaWaylandPointerGrabInterface -{ - void (*focus) (MetaWaylandPointerGrab *grab, - MetaWaylandSurface *surface); - void (*motion) (MetaWaylandPointerGrab *grab, - const ClutterEvent *event); - void (*button) (MetaWaylandPointerGrab *grab, - const ClutterEvent *event); - void (*cancel) (MetaWaylandPointerGrab *grab); -}; - -struct _MetaWaylandPointerGrab -{ - const MetaWaylandPointerGrabInterface *interface; - MetaWaylandPointer *pointer; -}; - struct _MetaWaylandPointerClient { struct wl_list pointer_resources; @@ -79,8 +62,6 @@ struct _MetaWaylandPointer MetaWaylandSurface *cursor_surface; gulong cursor_surface_destroy_id; - MetaWaylandPointerGrab *grab; - MetaWaylandPointerGrab default_grab; guint32 grab_button; guint32 grab_serial; guint32 grab_time; @@ -117,11 +98,6 @@ void meta_wayland_pointer_broadcast_frame (MetaWaylandPointer *pointer); void meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer, MetaWaylandSurface *surface); -void meta_wayland_pointer_start_grab (MetaWaylandPointer *pointer, - MetaWaylandPointerGrab *grab); - -void meta_wayland_pointer_end_grab (MetaWaylandPointer *pointer); - void meta_wayland_pointer_get_relative_coordinates (MetaWaylandPointer *pointer, MetaWaylandSurface *surface, wl_fixed_t *x, @@ -151,8 +127,6 @@ void meta_wayland_surface_cursor_update (MetaWaylandSurface *cursor_surface); void meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer); -gboolean meta_wayland_pointer_is_grabbed (MetaWaylandPointer *pointer); - MetaWaylandSurface * meta_wayland_pointer_get_current_surface (MetaWaylandPointer *pointer); void meta_wayland_pointer_focus_surface (MetaWaylandPointer *pointer, diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c index 0f4c2712b..a99eae99b 100644 --- a/src/wayland/meta-wayland-seat.c +++ b/src/wayland/meta-wayland-seat.c @@ -665,10 +665,6 @@ meta_wayland_seat_get_compositor (MetaWaylandSeat *seat) gboolean meta_wayland_seat_is_grabbed (MetaWaylandSeat *seat) { - if (meta_wayland_seat_has_pointer (seat) && - meta_wayland_pointer_is_grabbed (seat->pointer)) - return TRUE; - if (!meta_wayland_input_is_current_handler (seat->input_handler, seat->default_handler)) return TRUE; diff --git a/src/wayland/meta-wayland-types.h b/src/wayland/meta-wayland-types.h index 478cfe1d2..40c3bb733 100644 --- a/src/wayland/meta-wayland-types.h +++ b/src/wayland/meta-wayland-types.h @@ -22,8 +22,6 @@ typedef struct _MetaWaylandCompositor MetaWaylandCompositor; typedef struct _MetaWaylandSeat MetaWaylandSeat; typedef struct _MetaWaylandInputDevice MetaWaylandInputDevice; typedef struct _MetaWaylandPointer MetaWaylandPointer; -typedef struct _MetaWaylandPointerGrab MetaWaylandPointerGrab; -typedef struct _MetaWaylandPointerGrabInterface MetaWaylandPointerGrabInterface; typedef struct _MetaWaylandPopupGrab MetaWaylandPopupGrab; typedef struct _MetaWaylandPopup MetaWaylandPopup; typedef struct _MetaWaylandPopupSurface MetaWaylandPopupSurface;