diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index a2b5d2a1b..326b62c6e 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -19,6 +19,12 @@ struct sway_seatop_impl { void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec); void (*pointer_axis)(struct sway_seat *seat, struct wlr_event_pointer_axis *event); + void (*swipe_begin)(struct sway_seat *seat, + struct wlr_event_pointer_swipe_begin *event); + void (*swipe_update)(struct sway_seat *seat, + struct wlr_event_pointer_swipe_update *event); + void (*swipe_end)(struct sway_seat *seat, + struct wlr_event_pointer_swipe_end *event); void (*rebase)(struct sway_seat *seat, uint32_t time_msec); void (*tablet_tool_motion)(struct sway_seat *seat, struct sway_tablet_tool *tool, uint32_t time_msec); @@ -280,6 +286,13 @@ void seatop_tablet_tool_tip(struct sway_seat *seat, void seatop_tablet_tool_motion(struct sway_seat *seat, struct sway_tablet_tool *tool, uint32_t time_msec); +void seatop_swipe_begin(struct sway_seat *seat, + struct wlr_event_pointer_swipe_begin *event); +void seatop_swipe_update(struct sway_seat *seat, + struct wlr_event_pointer_swipe_update *event); +void seatop_swipe_end(struct sway_seat *seat, + struct wlr_event_pointer_swipe_end *event); + void seatop_rebase(struct sway_seat *seat, uint32_t time_msec); /** diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 2fe5b2027..ebc67d1fc 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -952,27 +952,24 @@ static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data) struct sway_cursor *cursor = wl_container_of( listener, cursor, swipe_begin); struct wlr_event_pointer_swipe_begin *event = data; - wlr_pointer_gestures_v1_send_swipe_begin( - cursor->pointer_gestures, cursor->seat->wlr_seat, - event->time_msec, event->fingers); + cursor_handle_activity_from_device(cursor, event->device); + seatop_swipe_begin(cursor->seat, event); } static void handle_pointer_swipe_update(struct wl_listener *listener, void *data) { struct sway_cursor *cursor = wl_container_of( listener, cursor, swipe_update); struct wlr_event_pointer_swipe_update *event = data; - wlr_pointer_gestures_v1_send_swipe_update( - cursor->pointer_gestures, cursor->seat->wlr_seat, - event->time_msec, event->dx, event->dy); + cursor_handle_activity_from_device(cursor, event->device); + seatop_swipe_update(cursor->seat, event); } static void handle_pointer_swipe_end(struct wl_listener *listener, void *data) { struct sway_cursor *cursor = wl_container_of( listener, cursor, swipe_end); struct wlr_event_pointer_swipe_end *event = data; - wlr_pointer_gestures_v1_send_swipe_end( - cursor->pointer_gestures, cursor->seat->wlr_seat, - event->time_msec, event->cancelled); + cursor_handle_activity_from_device(cursor, event->device); + seatop_swipe_end(cursor->seat, event); } static void handle_image_surface_destroy(struct wl_listener *listener, diff --git a/sway/input/seat.c b/sway/input/seat.c index 2d714acd4..6f3e21cf8 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -1576,6 +1576,27 @@ void seatop_tablet_tool_motion(struct sway_seat *seat, } } +void seatop_swipe_begin(struct sway_seat *seat, + struct wlr_event_pointer_swipe_begin *event) { + if (seat->seatop_impl->swipe_begin) { + seat->seatop_impl->swipe_begin(seat, event); + } +} + +void seatop_swipe_update(struct sway_seat *seat, + struct wlr_event_pointer_swipe_update *event) { + if (seat->seatop_impl->swipe_update) { + seat->seatop_impl->swipe_update(seat, event); + } +} + +void seatop_swipe_end(struct sway_seat *seat, + struct wlr_event_pointer_swipe_end *event) { + if (seat->seatop_impl->swipe_end) { + seat->seatop_impl->swipe_end(seat, event); + } +} + void seatop_rebase(struct sway_seat *seat, uint32_t time_msec) { if (seat->seatop_impl->rebase) { seat->seatop_impl->rebase(seat, time_msec); diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index f9eb8c8ad..4a4b1be68 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -747,6 +747,31 @@ static void handle_pointer_axis(struct sway_seat *seat, } } +static void handle_swipe_begin(struct sway_seat *seat, + struct wlr_event_pointer_swipe_begin *event) { + struct sway_cursor *cursor = seat->cursor; + wlr_pointer_gestures_v1_send_swipe_begin( + cursor->pointer_gestures, cursor->seat->wlr_seat, + event->time_msec, event->fingers); +} + +static void handle_swipe_update(struct sway_seat *seat, + struct wlr_event_pointer_swipe_update *event) { + struct sway_cursor *cursor = seat->cursor; + wlr_pointer_gestures_v1_send_swipe_update( + cursor->pointer_gestures, + cursor->seat->wlr_seat, + event->time_msec, event->dx, event->dy); +} + +static void handle_swipe_end(struct sway_seat *seat, + struct wlr_event_pointer_swipe_end *event) { + struct sway_cursor *cursor = seat->cursor; + wlr_pointer_gestures_v1_send_swipe_end( + cursor->pointer_gestures, cursor->seat->wlr_seat, + event->time_msec, event->cancelled); +} + /*----------------------------------\ * Functions used by handle_rebase / *--------------------------------*/ @@ -776,6 +801,9 @@ static const struct sway_seatop_impl seatop_impl = { .pointer_axis = handle_pointer_axis, .tablet_tool_tip = handle_tablet_tool_tip, .tablet_tool_motion = handle_tablet_tool_motion, + .swipe_begin = handle_swipe_begin, + .swipe_update = handle_swipe_update, + .swipe_end = handle_swipe_end, .rebase = handle_rebase, .allow_set_cursor = true, };