From 711403015921a931d5a5f2b93f53bf52ff52f0e3 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 30 Jun 2021 13:35:25 +0200 Subject: [PATCH] Add support for touch frame events Update for the breaking change in [1]. [1]: https://github.com/swaywm/wlroots/pull/3001 --- include/sway/input/cursor.h | 1 + sway/input/cursor.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 6a38190b..b053b85f 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h @@ -52,6 +52,7 @@ struct sway_cursor { struct wl_listener touch_down; struct wl_listener touch_up; struct wl_listener touch_motion; + struct wl_listener touch_frame; bool simulating_pointer_from_touch; int32_t pointer_touch_id; diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 95edf7be..96b5b935 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -495,7 +495,6 @@ static void handle_touch_down(struct wl_listener *listener, void *data) { pointer_motion(cursor, event->time_msec, event->device, dx, dy, dx, dy); dispatch_cursor_button(cursor, event->device, event->time_msec, BTN_LEFT, WLR_BUTTON_PRESSED); - wlr_seat_pointer_notify_frame(wlr_seat); } } @@ -511,7 +510,6 @@ static void handle_touch_up(struct wl_listener *listener, void *data) { cursor->simulating_pointer_from_touch = false; dispatch_cursor_button(cursor, event->device, event->time_msec, BTN_LEFT, WLR_BUTTON_RELEASED); - wlr_seat_pointer_notify_frame(wlr_seat); } } else { wlr_seat_touch_notify_up(wlr_seat, event->time_msec, event->touch_id); @@ -559,6 +557,19 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) { } } +static void handle_touch_frame(struct wl_listener *listener, void *data) { + struct sway_cursor *cursor = + wl_container_of(listener, cursor, touch_frame); + + struct wlr_seat *wlr_seat = cursor->seat->wlr_seat; + + if (cursor->simulating_pointer_from_touch) { + wlr_seat_pointer_notify_frame(wlr_seat); + } else { + wlr_seat_touch_notify_frame(wlr_seat); + } +} + static double apply_mapping_from_coord(double low, double high, double value) { if (isnan(value)) { return value; @@ -1044,6 +1055,7 @@ void sway_cursor_destroy(struct sway_cursor *cursor) { wl_list_remove(&cursor->touch_down.link); wl_list_remove(&cursor->touch_up.link); wl_list_remove(&cursor->touch_motion.link); + wl_list_remove(&cursor->touch_frame.link); wl_list_remove(&cursor->tool_axis.link); wl_list_remove(&cursor->tool_tip.link); wl_list_remove(&cursor->tool_button.link); @@ -1119,6 +1131,9 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { &cursor->touch_motion); cursor->touch_motion.notify = handle_touch_motion; + wl_signal_add(&wlr_cursor->events.touch_frame, &cursor->touch_frame); + cursor->touch_frame.notify = handle_touch_frame; + wl_signal_add(&wlr_cursor->events.tablet_tool_axis, &cursor->tool_axis); cursor->tool_axis.notify = handle_tool_axis;