From 75ecba444aac38e422f7b7b87a94a0e513045cb2 Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Wed, 17 Apr 2024 08:30:27 +0200 Subject: [PATCH] seat: add serials to touch up events --- include/wlr/types/wlr_seat.h | 6 +++--- types/data_device/wlr_drag.c | 5 +++-- types/seat/wlr_seat_touch.c | 15 ++++++++------- types/xdg_shell/wlr_xdg_popup.c | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 4d3aa574..06d8224e 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -126,7 +126,7 @@ struct wlr_seat_touch_grab; struct wlr_touch_grab_interface { uint32_t (*down)(struct wlr_seat_touch_grab *grab, uint32_t time_msec, struct wlr_touch_point *point); - void (*up)(struct wlr_seat_touch_grab *grab, uint32_t time_msec, + uint32_t (*up)(struct wlr_seat_touch_grab *grab, uint32_t time_msec, struct wlr_touch_point *point); void (*motion)(struct wlr_seat_touch_grab *grab, uint32_t time_msec, struct wlr_touch_point *point); @@ -618,7 +618,7 @@ uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat, * event. This will remove the touch point. This function does not respect touch * grabs: you probably want wlr_seat_touch_notify_up() instead. */ -void wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time_msec, +uint32_t wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time_msec, int32_t touch_id); /** @@ -653,7 +653,7 @@ uint32_t wlr_seat_touch_notify_down(struct wlr_seat *seat, * Notify the seat that the touch point given by `touch_id` is up. Defers to any * grab of the touch device. */ -void wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time_msec, +uint32_t wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time_msec, int32_t touch_id); /** diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c index 7161d91e..9ccd53c9 100644 --- a/types/data_device/wlr_drag.c +++ b/types/data_device/wlr_drag.c @@ -261,11 +261,11 @@ static uint32_t drag_handle_touch_down(struct wlr_seat_touch_grab *grab, return 0; } -static void drag_handle_touch_up(struct wlr_seat_touch_grab *grab, +static uint32_t drag_handle_touch_up(struct wlr_seat_touch_grab *grab, uint32_t time, struct wlr_touch_point *point) { struct wlr_drag *drag = grab->data; if (drag->grab_touch_id != point->touch_id) { - return; + return 0; } if (drag->focus_client) { @@ -273,6 +273,7 @@ static void drag_handle_touch_up(struct wlr_seat_touch_grab *grab, } drag_destroy(drag); + return 0; } static void drag_handle_touch_motion(struct wlr_seat_touch_grab *grab, diff --git a/types/seat/wlr_seat_touch.c b/types/seat/wlr_seat_touch.c index bffc5809..09f33d66 100644 --- a/types/seat/wlr_seat_touch.c +++ b/types/seat/wlr_seat_touch.c @@ -13,9 +13,9 @@ static uint32_t default_touch_down(struct wlr_seat_touch_grab *grab, point->touch_id, point->sx, point->sy); } -static void default_touch_up(struct wlr_seat_touch_grab *grab, uint32_t time, +static uint32_t default_touch_up(struct wlr_seat_touch_grab *grab, uint32_t time, struct wlr_touch_point *point) { - wlr_seat_touch_send_up(grab->seat, time, point->touch_id); + return wlr_seat_touch_send_up(grab->seat, time, point->touch_id); } static void default_touch_motion(struct wlr_seat_touch_grab *grab, @@ -205,16 +205,16 @@ uint32_t wlr_seat_touch_notify_down(struct wlr_seat *seat, return serial; } -void wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time, +uint32_t wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time, int32_t touch_id) { clock_gettime(CLOCK_MONOTONIC, &seat->last_event); struct wlr_seat_touch_grab *grab = seat->touch_state.grab; struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id); if (!point) { - return; + return 0; } - grab->interface->up(grab, time, point); + return grab->interface->up(grab, time, point); touch_point_destroy(point); } @@ -340,11 +340,11 @@ uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat, return serial; } -void wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time, int32_t touch_id) { +uint32_t wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time, int32_t touch_id) { struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id); if (!point) { wlr_log(WLR_ERROR, "got touch up for unknown touch point"); - return; + return 0; } uint32_t serial = wlr_seat_client_next_serial(point->client); @@ -357,6 +357,7 @@ void wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time, int32_t touch_ } point->client->needs_touch_frame = true; + return serial; } void wlr_seat_touch_send_motion(struct wlr_seat *seat, uint32_t time, int32_t touch_id, diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c index e2038c8d..dbc54262 100644 --- a/types/xdg_shell/wlr_xdg_popup.c +++ b/types/xdg_shell/wlr_xdg_popup.c @@ -151,9 +151,9 @@ static uint32_t xdg_touch_grab_down(struct wlr_seat_touch_grab *grab, point->touch_id, point->sx, point->sy); } -static void xdg_touch_grab_up(struct wlr_seat_touch_grab *grab, +static uint32_t xdg_touch_grab_up(struct wlr_seat_touch_grab *grab, uint32_t time, struct wlr_touch_point *point) { - wlr_seat_touch_send_up(grab->seat, time, point->touch_id); + return wlr_seat_touch_send_up(grab->seat, time, point->touch_id); } static void xdg_touch_grab_motion(struct wlr_seat_touch_grab *grab,