aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-10-27 15:09:39 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-10-27 15:09:39 +0000
commit329ad665682df4d76ab0b6fab685878ebc733967 (patch)
treeb4deeb6048a15d72b9b70def7a7765cedec28b0e
parentMerge branch 'noop-key-binding' (diff)
parentinput: clean up mouse scroll handling (diff)
Merge branch 'scrolling-fixes'
-rw-r--r--commands.c6
-rw-r--r--input.c29
2 files changed, 21 insertions, 14 deletions
diff --git a/commands.c b/commands.c
index e7dafdfc..4b0306aa 100644
--- a/commands.c
+++ b/commands.c
@@ -18,9 +18,6 @@ cmd_scrollback_up(struct terminal *term, int rows)
if (urls_mode_is_active(term))
return;
- if (term->mouse_tracking != MOUSE_NONE)
- return;
-
rows = min(rows, term->rows);
xassert(term->grid->offset >= 0);
@@ -98,9 +95,6 @@ cmd_scrollback_down(struct terminal *term, int rows)
if (urls_mode_is_active(term))
return;
- if (term->mouse_tracking != MOUSE_NONE)
- return;
-
if (term->grid->view == term->grid->offset)
return;
diff --git a/input.c b/input.c
index 19ec2cfa..00c4dac1 100644
--- a/input.c
+++ b/input.c
@@ -2091,6 +2091,8 @@ alternate_scroll(struct seat *seat, int amount, int button)
xassert(seat->mouse_focus != NULL);
struct terminal *term = seat->mouse_focus;
+ assert(button == BTN_BACK || button == BTN_FORWARD);
+
xkb_keycode_t key = button == BTN_BACK
? seat->kbd.key_arrow_up : seat->kbd.key_arrow_down;
@@ -2110,19 +2112,30 @@ mouse_scroll(struct seat *seat, int amount, enum wl_pointer_axis axis)
: amount < 0 ? BTN_WHEEL_LEFT : BTN_WHEEL_RIGHT;
amount = abs(amount);
- if (term->mouse_tracking == MOUSE_NONE) {
+ if (term_mouse_grabbed(term, seat)) {
if (term->grid == &term->alt) {
- if (term->alt_scrolling)
- alternate_scroll(seat, amount, button);
+ if (term->alt_scrolling) {
+ switch (button) {
+ case BTN_BACK:
+ case BTN_FORWARD:
+ alternate_scroll(seat, amount, button);
+ break;
+ }
+ }
} else {
- if (button == BTN_BACK)
+ switch (button) {
+ case BTN_BACK:
cmd_scrollback_up(term, amount);
- else
+ break;
+
+ case BTN_FORWARD:
cmd_scrollback_down(term, amount);
+ break;
+ }
}
- } else if (!term_mouse_grabbed(term, seat) &&
- seat->mouse.col >= 0 && seat->mouse.row >= 0)
- {
+ }
+
+ else if (seat->mouse.col >= 0 && seat->mouse.row >= 0) {
xassert(seat->mouse.col < term->cols);
xassert(seat->mouse.row < term->rows);