diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2016-07-11 23:15:23 -0500 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2016-07-11 23:15:23 -0500 |
| commit | 444e467057133a4144c1e5dec8b8638f2f645fa8 (patch) | |
| tree | cdd0bab3f262b850bc2431d941a2841c20b65dfc /wayland | |
| parent | 7df419d0967bea115d5c9c2ad54dfed3bf5a21b3 (diff) | |
Enable windows to register to get notified when the mouse wheel is scrolled
Diffstat (limited to 'wayland')
| -rw-r--r-- | wayland/window.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/wayland/window.c b/wayland/window.c index 2a76654b..dfa6a997 100644 --- a/wayland/window.c +++ b/wayland/window.c @@ -47,7 +47,26 @@ static void pointer_handle_button(void *data, struct wl_pointer *pointer, uint32 } static void pointer_handle_axis(void *data, struct wl_pointer *pointer, - uint32_t time, uint32_t axis, wl_fixed_t value) { + uint32_t time, uint32_t axis, wl_fixed_t value) { + struct window *window = data; + enum scroll_direction direction; + + switch (axis) { + case 0: + direction = wl_fixed_to_double(value) < 0 ? SCROLL_UP : SCROLL_DOWN; + break; + case 1: + direction = wl_fixed_to_double(value) < 0 ? SCROLL_LEFT : SCROLL_RIGHT; + break; + default: + if (!sway_assert(false, "Unexpected axis value")) { + return; + } + } + + if (window->pointer_input.notify_scroll) { + window->pointer_input.notify_scroll(window, direction); + } } static const struct wl_pointer_listener pointer_listener = { |
