diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-09-15 16:44:54 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-09-15 16:44:54 +0000 |
| commit | cb41db85965698dcf34217f8d26d9163a72a2e70 (patch) | |
| tree | 24324dacc4577ffb2f60abc12c871417729eb0c8 /input.c | |
| parent | input: don’t do alternate mode scrolling if application is grabbing mouse (diff) | |
input: don’t use stale keycodes for arrow-up/down
The keycodes will change if the seat’s keymap changes. Make sure we
only do alternate scrolling if the seat has a keyboard, and use
the *current* layout’s keycodes for arrow up/down (instead of
the *first* layout’s).
Diffstat (limited to 'input.c')
| -rw-r--r-- | input.c | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -498,6 +498,9 @@ keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, seat->kbd.mod_ctrl = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, "Control"); seat->kbd.mod_meta = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, "Mod4"); + seat->kbd.key_arrow_up = xkb_keymap_key_by_name(seat->kbd.xkb_keymap, "UP"); + seat->kbd.key_arrow_down = xkb_keymap_key_by_name(seat->kbd.xkb_keymap, "DOWN"); + /* Compose (dead keys) */ seat->kbd.xkb_compose_table = xkb_compose_table_new_from_locale( seat->kbd.xkb, setlocale(LC_CTYPE, NULL), XKB_COMPOSE_COMPILE_NO_FLAGS); @@ -1623,6 +1626,7 @@ mouse_scroll(struct seat *seat, int amount) amount = abs(amount); + if ((button == BTN_BACK || button == BTN_FORWARD) && term->grid == &term->alt && term->alt_scrolling && term->mouse_tracking == MOUSE_NONE) @@ -1632,19 +1636,14 @@ mouse_scroll(struct seat *seat, int amount) * "back"/"forward" to up/down keys */ - static xkb_keycode_t key_arrow_up = 0; - static xkb_keycode_t key_arrow_down = 0; + if (seat->wl_keyboard != NULL) { + xkb_keycode_t key = button == BTN_BACK + ? seat->kbd.key_arrow_up : seat->kbd.key_arrow_down; - if (key_arrow_up == 0) { - key_arrow_up = xkb_keymap_key_by_name(seat->kbd.xkb_keymap, "UP"); - key_arrow_down = xkb_keymap_key_by_name(seat->kbd.xkb_keymap, "DOWN"); + for (int i = 0; i < amount; i++) + keyboard_key(seat, NULL, seat->kbd.serial, 0, key - 8, XKB_KEY_DOWN); + keyboard_key(seat, NULL, seat->kbd.serial, 0, key - 8, XKB_KEY_UP); } - - xkb_keycode_t key = button == BTN_BACK ? key_arrow_up : key_arrow_down; - - for (int i = 0; i < amount; i++) - keyboard_key(seat, NULL, seat->kbd.serial, 0, key - 8, XKB_KEY_DOWN); - keyboard_key(seat, NULL, seat->kbd.serial, 0, key - 8, XKB_KEY_UP); } else { if (!term_mouse_grabbed(term, seat) && seat->mouse.col >= 0 && seat->mouse.row >= 0) |
