aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar
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 /swaybar
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 'swaybar')
-rw-r--r--swaybar/bar.c12
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
89 } 89 }
90} 90}
91 91
92static void mouse_scroll_notify(struct window *window, enum scroll_direction direction) {
93 sway_log(L_DEBUG, "Mouse wheel scrolled %s", direction == SCROLL_UP ? "up" : "down");
94
95 const char *workspace_name = direction == SCROLL_UP ? "prev_on_output" : "next_on_output";
96 ipc_send_workspace_command(workspace_name);
97}
98
92void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) { 99void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) {
93 /* initialize bar with default values */ 100 /* initialize bar with default values */
94 bar_init(bar); 101 bar_init(bar);
@@ -123,8 +130,9 @@ void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) {
123 /* set font */ 130 /* set font */
124 bar_output->window->font = bar->config->font; 131 bar_output->window->font = bar->config->font;
125 132
126 /* set font */ 133 /* set mouse event callbacks */
127 bar_output->window->pointer_input.notify = mouse_button_notify; 134 bar_output->window->pointer_input.notify_button = mouse_button_notify;
135 bar_output->window->pointer_input.notify_scroll = mouse_scroll_notify;
128 136
129 /* set window height */ 137 /* set window height */
130 set_window_height(bar_output->window, bar->config->height); 138 set_window_height(bar_output->window, bar->config->height);