Fixed tracker value being updated even if percent isn't

Fixes long swipes still updating the tracker value even if the percent wasn't changed
This commit is contained in:
Erik Reider 2024-01-25 19:46:58 +01:00
parent b491ac42b0
commit 4f9ac2dfbb
3 changed files with 27 additions and 18 deletions

View file

@ -223,8 +223,8 @@ bool workspace_scroll_equal(struct workspace_scroll *a, struct workspace_scroll
void workspace_scroll_begin(struct sway_seat *seat,
enum swipe_gesture_direction direction);
void workspace_scroll_update(struct sway_seat *seat, double delta_sum,
enum swipe_gesture_direction direction);
void workspace_scroll_update(struct sway_seat *seat, struct gesture_tracker *tracker,
struct wlr_pointer_swipe_update_event *event, int invert);
void workspace_scroll_end(struct sway_seat *seat);

View file

@ -1149,8 +1149,23 @@ void workspace_scroll_begin(struct sway_seat *seat,
seat_set_focus_workspace(seat, NULL);
}
void workspace_scroll_update(struct sway_seat *seat, double delta_sum,
enum swipe_gesture_direction direction) {
void workspace_scroll_update(struct sway_seat *seat, struct gesture_tracker *tracker,
struct wlr_pointer_swipe_update_event *event, int invert) {
double delta_sum;
enum swipe_gesture_direction direction;
switch (tracker->type) {
case GESTURE_TYPE_WORKSPACE_SWIPE_HORIZONTAL:
direction = SWIPE_GESTURE_DIRECTION_HORIZONTAL;
delta_sum = tracker->dx + event->dx * invert;
break;
case GESTURE_TYPE_WORKSPACE_SWIPE_VERTICAL:
direction = SWIPE_GESTURE_DIRECTION_VERTICAL;
delta_sum = tracker->dy + event->dy * invert;
break;
default:
return;
}
struct sway_workspace *focused_ws = seat_get_focused_workspace(seat);
struct sway_output *output = focused_ws->output;
struct workspace_scroll *ws_scroll = &output->workspace_scroll;
@ -1197,6 +1212,13 @@ void workspace_scroll_update(struct sway_seat *seat, double delta_sum,
}
}
}
// Update the tracker data if we aren't exceeding the max swipe limit
if (percent < max && percent > min) {
tracker->dx += event->dx * invert;
tracker->dy += event->dy * invert;
}
ws_scroll->percent = CLAMP(percent, min, max);
ws_scroll->direction = direction;

View file

@ -1057,20 +1057,7 @@ static void handle_swipe_update(struct sway_seat *seat,
if (binding) {
int invert = binding->flags & BINDING_INVERTED ? 1 : -1;
tracker->dx += event->dx * invert;
tracker->dy += event->dy * invert;
switch (binding->gesture.type) {
case GESTURE_TYPE_WORKSPACE_SWIPE_HORIZONTAL:
workspace_scroll_update(seat, tracker->dx,
SWIPE_GESTURE_DIRECTION_HORIZONTAL);
break;
case GESTURE_TYPE_WORKSPACE_SWIPE_VERTICAL:
workspace_scroll_update(seat, tracker->dy,
SWIPE_GESTURE_DIRECTION_VERTICAL);
break;
default:
break;
}
workspace_scroll_update(seat, tracker, event, invert);
}
} else {
// ... otherwise forward to client