From 9e551680db007bd67392510eb3322b29d7b9230c Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:21:57 +0100 Subject: [PATCH] Try switching workspace on gesture cancel instead of reset --- include/sway/output.h | 2 -- sway/desktop/output.c | 18 +++++++----------- sway/input/seatop_default.c | 9 +-------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/include/sway/output.h b/include/sway/output.h index 04669dd0..9e2867eb 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -206,8 +206,6 @@ void update_workspace_scroll_percent(int dx, int invert); void snap_workspace_scroll_percent(int dx, int invert); -void reset_workspace_scroll_percent(); - struct sway_output_non_desktop *output_non_desktop_create(struct wlr_output *wlr_output); #endif diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 23e5b6f9..5ee7e6c9 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -1110,6 +1110,12 @@ static void workspace_scroll_mark_dirty(struct sway_output *output) { transaction_commit_dirty(); } +static void reset_workspace_scroll_percent(struct sway_output *output) { + output->workspace_scroll_percent = 0; + + workspace_scroll_mark_dirty(output); +} + void update_workspace_scroll_percent(int dx, int invert) { struct sway_seat *seat = input_manager_get_default_seat(); struct sway_workspace *focused_ws = seat_get_focused_workspace(seat); @@ -1180,15 +1186,5 @@ void snap_workspace_scroll_percent(int dx, int invert) { reset: // Reset the state - reset_workspace_scroll_percent(); -} - -void reset_workspace_scroll_percent() { - struct sway_seat *seat = input_manager_get_default_seat(); - struct sway_workspace *focused_ws = seat_get_focused_workspace(seat); - struct sway_output *output = focused_ws->output; - - output->workspace_scroll_percent = 0; - - workspace_scroll_mark_dirty(output); + reset_workspace_scroll_percent(output); } diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 4be967b9..6464bd71 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -1086,14 +1086,7 @@ static void handle_swipe_end(struct sway_seat *seat, cursor->seat->wlr_seat, event->time_msec, event->cancelled); return; } - if (event->cancelled) { - switch (seatop->gestures.type) { - case GESTURE_TYPE_WORKSPACE_SWIPE: - reset_workspace_scroll_percent(); - break; - default: - break; - } + if (event->cancelled && seatop->gestures.type != GESTURE_TYPE_WORKSPACE_SWIPE) { gesture_tracker_cancel(&seatop->gestures); return; }