aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/bar.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2016-07-17 11:26:38 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2016-07-17 11:26:38 -0400
commit3bb880bf207b40bc0cddcb9c449a738861e6791b (patch)
tree66ed13164fef27ebf3c8a6106590f1b7ec432483 /swaybar/bar.c
parentAllow users to customize the cursor on clients (diff)
downloadsway-3bb880bf207b40bc0cddcb9c449a738861e6791b.tar.gz
sway-3bb880bf207b40bc0cddcb9c449a738861e6791b.tar.zst
sway-3bb880bf207b40bc0cddcb9c449a738861e6791b.zip
Implement configurable wrapping on bar ws scroll
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r--swaybar/bar.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index 9009e1ff..41538052 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -96,6 +96,37 @@ static void mouse_button_notify(struct window *window, int x, int y,
96static void mouse_scroll_notify(struct window *window, enum scroll_direction direction) { 96static void mouse_scroll_notify(struct window *window, enum scroll_direction direction) {
97 sway_log(L_DEBUG, "Mouse wheel scrolled %s", direction == SCROLL_UP ? "up" : "down"); 97 sway_log(L_DEBUG, "Mouse wheel scrolled %s", direction == SCROLL_UP ? "up" : "down");
98 98
99 if (!swaybar.config->wrap_scroll) {
100 // Find output this window lives on
101 int i;
102 struct output *output;
103 for (i = 0; i < swaybar.outputs->length; ++i) {
104 output = swaybar.outputs->items[i];
105 if (output->window == window) {
106 break;
107 }
108 }
109 if (!sway_assert(i != swaybar.outputs->length, "Unknown window in scroll event")) {
110 return;
111 }
112 int focused = -1;
113 for (i = 0; i < output->workspaces->length; ++i) {
114 struct workspace *ws = output->workspaces->items[i];
115 if (ws->focused) {
116 focused = i;
117 break;
118 }
119 }
120 if (!sway_assert(focused != -1, "Scroll wheel event received on inactive output")) {
121 return;
122 }
123 if ((focused == 0 && direction == SCROLL_UP) ||
124 (focused == output->workspaces->length - 1 && direction == SCROLL_DOWN)) {
125 // Do not wrap
126 return;
127 }
128 }
129
99 const char *workspace_name = direction == SCROLL_UP ? "prev_on_output" : "next_on_output"; 130 const char *workspace_name = direction == SCROLL_UP ? "prev_on_output" : "next_on_output";
100 ipc_send_workspace_command(workspace_name); 131 ipc_send_workspace_command(workspace_name);
101} 132}