aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-30 15:48:58 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-30 15:48:58 +0000
commit6aa14ccdfcaf2cf5b76bc645bd6ab20f59932672 (patch)
treeaf82005066f651afce878e0228b5c93e7ff718d3 /input.c
parentterm: "raw" mouse mode requires shift only to be pressed (diff)
input: mouse_scroll: cache XKB_KEY_Up and XKB_KEY_Down
Diffstat (limited to 'input.c')
-rw-r--r--input.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/input.c b/input.c
index c8320f32..73cf5a9d 100644
--- a/input.c
+++ b/input.c
@@ -633,8 +633,15 @@ mouse_scroll(struct wayland *wayl, int amount)
* "back"/"forward" to up/down keys
*/
- xkb_keycode_t key = xkb_keymap_key_by_name(
- wayl->kbd.xkb_keymap, button == BTN_BACK ? "UP" : "DOWN");
+ static xkb_keycode_t key_arrow_up = 0;
+ static xkb_keycode_t key_arrow_down = 0;
+
+ if (key_arrow_up == 0) {
+ key_arrow_up = xkb_keymap_key_by_name(wayl->kbd.xkb_keymap, "UP");
+ key_arrow_down = xkb_keymap_key_by_name(wayl->kbd.xkb_keymap, "DOWN");
+ }
+
+ xkb_keycode_t key = button == BTN_BACK ? key_arrow_up : key_arrow_down;
for (int i = 0; i < amount; i++)
keyboard_key(term, NULL, wayl->input_serial, 0, key - 8, XKB_KEY_DOWN);