summaryrefslogtreecommitdiff
path: root/wayland/window.c
diff options
context:
space:
mode:
authorDrew DeVault <[email protected]>2016-07-16 09:09:37 -0400
committerGitHub <[email protected]>2016-07-16 09:09:37 -0400
commite66f813d49e60728064fa563e01f00f7d99e0a08 (patch)
tree668520fe97250c4274c3749b7ffb870a3063e87f /wayland/window.c
parenta11277c88fba203f69f7a6e11c345265b4697cf0 (diff)
parente38d6b94b890b473141fb0d1cd3f4b3203ea7d81 (diff)
Merge pull request #752 from deklov/bar-scroll-02
Change workspace with mouse wheel
Diffstat (limited to 'wayland/window.c')
-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
struct window *window = data;
struct pointer_input *input = &window->pointer_input;
- if (window->pointer_input.notify) {
- window->pointer_input.notify(window, input->last_x, input->last_y, button);
+ if (window->pointer_input.notify_button) {
+ window->pointer_input.notify_button(window, input->last_x, input->last_y, button);
}
}
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 = {