diff options
author | Drew DeVault <[email protected]> | 2016-07-16 09:09:37 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2016-07-16 09:09:37 -0400 |
commit | e66f813d49e60728064fa563e01f00f7d99e0a08 (patch) | |
tree | 668520fe97250c4274c3749b7ffb870a3063e87f /swaybar/bar.c | |
parent | a11277c88fba203f69f7a6e11c345265b4697cf0 (diff) | |
parent | e38d6b94b890b473141fb0d1cd3f4b3203ea7d81 (diff) |
Merge pull request #752 from deklov/bar-scroll-02
Change workspace with mouse wheel
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r-- | swaybar/bar.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index 4f8063ac..82e136e4 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -89,6 +89,13 @@ static void mouse_button_notify(struct window *window, int x, int y, uint32_t bu } } +static void mouse_scroll_notify(struct window *window, enum scroll_direction direction) { + sway_log(L_DEBUG, "Mouse wheel scrolled %s", direction == SCROLL_UP ? "up" : "down"); + + const char *workspace_name = direction == SCROLL_UP ? "prev_on_output" : "next_on_output"; + ipc_send_workspace_command(workspace_name); +} + void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) { /* initialize bar with default values */ bar_init(bar); @@ -123,8 +130,9 @@ void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) { /* set font */ bar_output->window->font = bar->config->font; - /* set font */ - bar_output->window->pointer_input.notify = mouse_button_notify; + /* set mouse event callbacks */ + bar_output->window->pointer_input.notify_button = mouse_button_notify; + bar_output->window->pointer_input.notify_scroll = mouse_scroll_notify; /* set window height */ set_window_height(bar_output->window, bar->config->height); |