mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-15 05:33:58 -04:00
input: clean up mouse scroll handling
* Allow scrolling on the normal (non-alt) screen, when application is
grabbing the mouse (when user presses Shift).
* Use term_mouse_grabbed() instead of explicitly checking for
MOUSE_NONE tracking.
* Remove mouse tracking check from cmd_scrollback_{up,down}. Caller is
expected to have done the check.
* Don’t scroll down on mouse wheel tilt events.
This commit is contained in:
parent
3413901678
commit
0900d01ec9
2 changed files with 21 additions and 14 deletions
|
|
@ -18,9 +18,6 @@ cmd_scrollback_up(struct terminal *term, int rows)
|
||||||
if (urls_mode_is_active(term))
|
if (urls_mode_is_active(term))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (term->mouse_tracking != MOUSE_NONE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
rows = min(rows, term->rows);
|
rows = min(rows, term->rows);
|
||||||
xassert(term->grid->offset >= 0);
|
xassert(term->grid->offset >= 0);
|
||||||
|
|
||||||
|
|
@ -98,9 +95,6 @@ cmd_scrollback_down(struct terminal *term, int rows)
|
||||||
if (urls_mode_is_active(term))
|
if (urls_mode_is_active(term))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (term->mouse_tracking != MOUSE_NONE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (term->grid->view == term->grid->offset)
|
if (term->grid->view == term->grid->offset)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
29
input.c
29
input.c
|
|
@ -2091,6 +2091,8 @@ alternate_scroll(struct seat *seat, int amount, int button)
|
||||||
xassert(seat->mouse_focus != NULL);
|
xassert(seat->mouse_focus != NULL);
|
||||||
struct terminal *term = seat->mouse_focus;
|
struct terminal *term = seat->mouse_focus;
|
||||||
|
|
||||||
|
assert(button == BTN_BACK || button == BTN_FORWARD);
|
||||||
|
|
||||||
xkb_keycode_t key = button == BTN_BACK
|
xkb_keycode_t key = button == BTN_BACK
|
||||||
? seat->kbd.key_arrow_up : seat->kbd.key_arrow_down;
|
? 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 < 0 ? BTN_WHEEL_LEFT : BTN_WHEEL_RIGHT;
|
||||||
amount = abs(amount);
|
amount = abs(amount);
|
||||||
|
|
||||||
if (term->mouse_tracking == MOUSE_NONE) {
|
if (term_mouse_grabbed(term, seat)) {
|
||||||
if (term->grid == &term->alt) {
|
if (term->grid == &term->alt) {
|
||||||
if (term->alt_scrolling)
|
if (term->alt_scrolling) {
|
||||||
alternate_scroll(seat, amount, button);
|
switch (button) {
|
||||||
|
case BTN_BACK:
|
||||||
|
case BTN_FORWARD:
|
||||||
|
alternate_scroll(seat, amount, button);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (button == BTN_BACK)
|
switch (button) {
|
||||||
|
case BTN_BACK:
|
||||||
cmd_scrollback_up(term, amount);
|
cmd_scrollback_up(term, amount);
|
||||||
else
|
break;
|
||||||
|
|
||||||
|
case BTN_FORWARD:
|
||||||
cmd_scrollback_down(term, amount);
|
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.col < term->cols);
|
||||||
xassert(seat->mouse.row < term->rows);
|
xassert(seat->mouse.row < term->rows);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue