summaryrefslogtreecommitdiffstats
path: root/wayland
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2016-07-16 09:09:37 -0400
committerLibravatar GitHub <noreply@github.com>2016-07-16 09:09:37 -0400
commite66f813d49e60728064fa563e01f00f7d99e0a08 (patch)
tree668520fe97250c4274c3749b7ffb870a3063e87f /wayland
parentFix warning from unused daemon return value (diff)
parentChange workspace when mouse wheel is scrolled while hovering over the bar (diff)
downloadsway-e66f813d49e60728064fa563e01f00f7d99e0a08.tar.gz
sway-e66f813d49e60728064fa563e01f00f7d99e0a08.tar.zst
sway-e66f813d49e60728064fa563e01f00f7d99e0a08.zip
Merge pull request #752 from deklov/bar-scroll-02
Change workspace with mouse wheel
Diffstat (limited to 'wayland')
-rw-r--r--wayland/window.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/wayland/window.c b/wayland/window.c
index 9b6e5b00..dfa6a997 100644
--- a/wayland/window.c
+++ b/wayland/window.c
@@ -41,13 +41,32 @@ static void pointer_handle_button(void *data, struct wl_pointer *pointer, uint32
41 struct window *window = data; 41 struct window *window = data;
42 struct pointer_input *input = &window->pointer_input; 42 struct pointer_input *input = &window->pointer_input;
43 43
44 if (window->pointer_input.notify) { 44 if (window->pointer_input.notify_button) {
45 window->pointer_input.notify(window, input->last_x, input->last_y, button); 45 window->pointer_input.notify_button(window, input->last_x, input->last_y, button);
46 } 46 }
47} 47}
48 48
49static void pointer_handle_axis(void *data, struct wl_pointer *pointer, 49static void pointer_handle_axis(void *data, struct wl_pointer *pointer,
50 uint32_t time, uint32_t axis, wl_fixed_t value) { 50 uint32_t time, uint32_t axis, wl_fixed_t value) {
51 struct window *window = data;
52 enum scroll_direction direction;
53
54 switch (axis) {
55 case 0:
56 direction = wl_fixed_to_double(value) < 0 ? SCROLL_UP : SCROLL_DOWN;
57 break;
58 case 1:
59 direction = wl_fixed_to_double(value) < 0 ? SCROLL_LEFT : SCROLL_RIGHT;
60 break;
61 default:
62 if (!sway_assert(false, "Unexpected axis value")) {
63 return;
64 }
65 }
66
67 if (window->pointer_input.notify_scroll) {
68 window->pointer_input.notify_scroll(window, direction);
69 }
51} 70}
52 71
53static const struct wl_pointer_listener pointer_listener = { 72static const struct wl_pointer_listener pointer_listener = {