From bfcd3527dd7f14ce335ca8da7cf5f641254bd1f3 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Tue, 29 Aug 2023 14:23:19 +0200 Subject: [PATCH] scroll wheel switches layers (as opposed to crashing as it did before) --- keyboard.c | 2 +- main.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/keyboard.c b/keyboard.c index b3d8819..a1b478e 100644 --- a/keyboard.c +++ b/keyboard.c @@ -62,7 +62,7 @@ kbd_next_layer(struct kbd *kb, struct key *k, bool invert) { } layer_index = layercount - 1; } - kb->mods ^= Shift; + if (!invert) kb->mods ^= Shift; } else { // normal behaviour: switch to the next layout in the layer sequence layer_index++; diff --git a/main.c b/main.c index 04a62f5..7921541 100644 --- a/main.c +++ b/main.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,8 @@ static void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state); +static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, + uint32_t time, uint32_t axis, wl_fixed_t value); static void wl_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial, uint32_t time, @@ -113,6 +116,7 @@ static const struct wl_pointer_listener pointer_listener = { .leave = wl_pointer_leave, .motion = wl_pointer_motion, .button = wl_pointer_button, + .axis = wl_pointer_axis, }; static const struct wl_touch_listener touch_listener = { @@ -255,6 +259,13 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial, } } +void +wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, + uint32_t time, uint32_t axis, wl_fixed_t value) { + kbd_next_layer(&keyboard, NULL, (value >= 0)); + drwsurf_flip(keyboard.surf); +} + void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, enum wl_seat_capability caps) {