scroll wheel switches layers (as opposed to crashing as it did before)

This commit is contained in:
Maarten van Gompel 2023-08-29 14:23:19 +02:00
parent 0ca0409400
commit bfcd3527dd
2 changed files with 12 additions and 1 deletions

View File

@ -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++;

11
main.c
View File

@ -8,6 +8,7 @@
#include <sys/signalfd.h>
#include <poll.h>
#include <unistd.h>
#include <wayland-client-protocol.h>
#include <wayland-client.h>
#include <wchar.h>
@ -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) {