input: Percolate swipe gestures through seat handlers

Let swipe pointer gestures percolate through seat and default seatop
handlers so sway-internal handling can be added if desired. As a
side-effect this makes swipes count as user activity. There should be no
other functional changes.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
This commit is contained in:
Michael Weiser 2020-01-25 18:18:57 +01:00
parent 4e302fb402
commit b518870bc1
4 changed files with 68 additions and 9 deletions

View file

@ -19,6 +19,12 @@ struct sway_seatop_impl {
void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec); void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec);
void (*pointer_axis)(struct sway_seat *seat, void (*pointer_axis)(struct sway_seat *seat,
struct wlr_event_pointer_axis *event); 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 (*rebase)(struct sway_seat *seat, uint32_t time_msec);
void (*tablet_tool_motion)(struct sway_seat *seat, void (*tablet_tool_motion)(struct sway_seat *seat,
struct sway_tablet_tool *tool, uint32_t time_msec); 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, void seatop_tablet_tool_motion(struct sway_seat *seat,
struct sway_tablet_tool *tool, uint32_t time_msec); 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); void seatop_rebase(struct sway_seat *seat, uint32_t time_msec);
/** /**

View file

@ -952,27 +952,24 @@ static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data)
struct sway_cursor *cursor = wl_container_of( struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_begin); listener, cursor, swipe_begin);
struct wlr_event_pointer_swipe_begin *event = data; struct wlr_event_pointer_swipe_begin *event = data;
wlr_pointer_gestures_v1_send_swipe_begin( cursor_handle_activity_from_device(cursor, event->device);
cursor->pointer_gestures, cursor->seat->wlr_seat, seatop_swipe_begin(cursor->seat, event);
event->time_msec, event->fingers);
} }
static void handle_pointer_swipe_update(struct wl_listener *listener, void *data) { static void handle_pointer_swipe_update(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of( struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_update); listener, cursor, swipe_update);
struct wlr_event_pointer_swipe_update *event = data; struct wlr_event_pointer_swipe_update *event = data;
wlr_pointer_gestures_v1_send_swipe_update( cursor_handle_activity_from_device(cursor, event->device);
cursor->pointer_gestures, cursor->seat->wlr_seat, seatop_swipe_update(cursor->seat, event);
event->time_msec, event->dx, event->dy);
} }
static void handle_pointer_swipe_end(struct wl_listener *listener, void *data) { static void handle_pointer_swipe_end(struct wl_listener *listener, void *data) {
struct sway_cursor *cursor = wl_container_of( struct sway_cursor *cursor = wl_container_of(
listener, cursor, swipe_end); listener, cursor, swipe_end);
struct wlr_event_pointer_swipe_end *event = data; struct wlr_event_pointer_swipe_end *event = data;
wlr_pointer_gestures_v1_send_swipe_end( cursor_handle_activity_from_device(cursor, event->device);
cursor->pointer_gestures, cursor->seat->wlr_seat, seatop_swipe_end(cursor->seat, event);
event->time_msec, event->cancelled);
} }
static void handle_image_surface_destroy(struct wl_listener *listener, static void handle_image_surface_destroy(struct wl_listener *listener,

View file

@ -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) { void seatop_rebase(struct sway_seat *seat, uint32_t time_msec) {
if (seat->seatop_impl->rebase) { if (seat->seatop_impl->rebase) {
seat->seatop_impl->rebase(seat, time_msec); seat->seatop_impl->rebase(seat, time_msec);

View file

@ -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 / * Functions used by handle_rebase /
*--------------------------------*/ *--------------------------------*/
@ -776,6 +801,9 @@ static const struct sway_seatop_impl seatop_impl = {
.pointer_axis = handle_pointer_axis, .pointer_axis = handle_pointer_axis,
.tablet_tool_tip = handle_tablet_tool_tip, .tablet_tool_tip = handle_tablet_tool_tip,
.tablet_tool_motion = handle_tablet_tool_motion, .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, .rebase = handle_rebase,
.allow_set_cursor = true, .allow_set_cursor = true,
}; };