From 9e96b523ea0b8007a5d19c7063e7ed75fdc81246 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Dec 2021 00:06:11 +0100 Subject: [PATCH] wayland: Change MetaWaylandDragDest::motion vmethod signature Stop taking a ClutterEvent and pass the essentials here (x/y/evtime), we don't have a ClutterEvent handy in all places that we call this API, and it feels awkward to create one just for calling this vmethod. Part-of: --- src/wayland/meta-wayland-data-device.c | 15 ++++++++++++--- src/wayland/meta-wayland-surface.c | 6 ++++-- src/wayland/meta-wayland-surface.h | 8 ++++++-- src/wayland/meta-xwayland-dnd.c | 20 ++++++-------------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c index 7d808c65e..f0457c7f3 100644 --- a/src/wayland/meta-wayland-data-device.c +++ b/src/wayland/meta-wayland-data-device.c @@ -357,9 +357,16 @@ drag_grab_motion (MetaWaylandPointerGrab *grab, const ClutterEvent *event) { MetaWaylandDragGrab *drag_grab = (MetaWaylandDragGrab*) grab; + graphene_point_t point; + uint32_t time_ms; if (drag_grab->drag_focus) - meta_wayland_surface_drag_dest_motion (drag_grab->drag_focus, event); + { + clutter_event_get_coords (event, &point.x, &point.y); + time_ms = clutter_event_get_time (event); + meta_wayland_surface_drag_dest_motion (drag_grab->drag_focus, + point.x, point.y, time_ms); + } if (drag_grab->drag_surface) meta_feedback_actor_update (META_FEEDBACK_ACTOR (drag_grab->feedback_actor), @@ -826,7 +833,9 @@ meta_wayland_drag_dest_focus_out (MetaWaylandDataDevice *data_device, static void meta_wayland_drag_dest_motion (MetaWaylandDataDevice *data_device, MetaWaylandSurface *surface, - const ClutterEvent *event) + float x, + float y, + uint32_t time_ms) { MetaWaylandDragGrab *grab = data_device->current_grab; wl_fixed_t sx, sy; @@ -838,7 +847,7 @@ meta_wayland_drag_dest_motion (MetaWaylandDataDevice *data_device, grab->drag_focus, &sx, &sy); wl_data_device_send_motion (grab->drag_focus_data_device, - clutter_event_get_time (event), + time_ms, sx, sy); } diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 5d16ec13a..021ee7916 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -1656,12 +1656,14 @@ meta_wayland_surface_drag_dest_focus_in (MetaWaylandSurface *surface, void meta_wayland_surface_drag_dest_motion (MetaWaylandSurface *surface, - const ClutterEvent *event) + float x, + float y, + uint32_t time_ms) { MetaWaylandCompositor *compositor = surface->compositor; MetaWaylandDataDevice *data_device = &compositor->seat->data_device; - surface->dnd.funcs->motion (data_device, surface, event); + surface->dnd.funcs->motion (data_device, surface, x, y, time_ms); } void diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index 9a3656c56..3beeca7aa 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -147,7 +147,9 @@ struct _MetaWaylandDragDestFuncs MetaWaylandSurface *surface); void (* motion) (MetaWaylandDataDevice *data_device, MetaWaylandSurface *surface, - const ClutterEvent *event); + float x, + float y, + uint32_t time_ms); void (* drop) (MetaWaylandDataDevice *data_device, MetaWaylandSurface *surface); void (* update) (MetaWaylandDataDevice *data_device, @@ -315,7 +317,9 @@ void meta_wayland_surface_delete (MetaWaylandSurface *surface); void meta_wayland_surface_drag_dest_focus_in (MetaWaylandSurface *surface, MetaWaylandDataOffer *offer); void meta_wayland_surface_drag_dest_motion (MetaWaylandSurface *surface, - const ClutterEvent *event); + float x, + float y, + uint32_t time_ms); void meta_wayland_surface_drag_dest_focus_out (MetaWaylandSurface *surface); void meta_wayland_surface_drag_dest_drop (MetaWaylandSurface *surface); void meta_wayland_surface_drag_dest_update (MetaWaylandSurface *surface); diff --git a/src/wayland/meta-xwayland-dnd.c b/src/wayland/meta-xwayland-dnd.c index b4a679162..376d9549a 100644 --- a/src/wayland/meta-xwayland-dnd.c +++ b/src/wayland/meta-xwayland-dnd.c @@ -636,17 +636,15 @@ meta_x11_drag_dest_focus_out (MetaWaylandDataDevice *data_device, static void meta_x11_drag_dest_motion (MetaWaylandDataDevice *data_device, MetaWaylandSurface *surface, - const ClutterEvent *event) + float x, + float y, + uint32_t time_ms) { MetaWaylandSeat *seat = meta_wayland_data_device_get_seat (data_device); MetaWaylandCompositor *compositor = meta_wayland_seat_get_compositor (seat); MetaXWaylandDnd *dnd = compositor->xwayland_manager.dnd; - guint32 time; - gfloat x, y; - time = clutter_event_get_time (event); - clutter_event_get_coords (event, &x, &y); - xdnd_send_position (dnd, dnd->dnd_dest, time, x, y); + xdnd_send_position (dnd, dnd->dnd_dest, time_ms, x, y); } static void @@ -975,28 +973,22 @@ meta_xwayland_dnd_handle_client_message (MetaWaylandCompositor *compositor, } else if (event->message_type == xdnd_atoms[ATOM_DND_POSITION]) { - ClutterEvent *motion; graphene_point_t pos; uint32_t action = 0; dnd->client_message_timestamp = event->data.l[3]; - motion = clutter_event_new (CLUTTER_MOTION); clutter_seat_query_state (clutter_input_device_get_seat (seat->pointer->device), seat->pointer->device, NULL, &pos, NULL); - clutter_event_set_coords (motion, pos.x, pos.y); - clutter_event_set_device (motion, seat->pointer->device); - clutter_event_set_source_device (motion, seat->pointer->device); - clutter_event_set_time (motion, dnd->last_motion_time); action = atom_to_action ((Atom) event->data.l[4]); meta_wayland_data_source_set_user_action (dnd->source, action); - meta_wayland_surface_drag_dest_motion (drag_focus, motion); + meta_wayland_surface_drag_dest_motion (drag_focus, pos.x, pos.y, + dnd->last_motion_time); xdnd_send_status (dnd, (Window) event->data.l[0], meta_wayland_data_source_get_current_action (dnd->source)); - clutter_event_free (motion); return TRUE; } else if (event->message_type == xdnd_atoms[ATOM_DND_LEAVE])