Skip to content

Commit

Permalink
swaybar: prioritize workspace scroll over bindsyms
Browse files Browse the repository at this point in the history
This adds handling for scroll events (e.g. mouse wheel) to the hotspot
callback equivalent to the fallback in `process_discrete_scroll`.

While this may seem redundant (and in many cases, it is), it changes
the priority when the user has Button4/Button5 bindsyms on the bar.

Before this commit:
* Scrolling on unused bar space calls the user's bindsyms.
* Scrolling over the workspaces *still* calls the user's bindsyms.

After this commit:
* Scrolling on unused bar space calls the user's bindsyms.
* Scrolling over the workspaces moves to the previous/next workspace.

If the user has no bindsyms for Button4/Button5, there is no change.

This is consistent with the idea that workspaces are hotspots, and
hotspot event handlers take priority over the user's bindsyms, see
53f9dbd ("swaybar: Prioritize hotspot events to bar bindings").

However, note that this strays further away from i3's behaviour.
On i3, user bindsyms take precedence over workspaces, even for Button1.
In fact, it's explicitly documented as such:
https://web.archive.org/web/20240725173949/https://i3wm.org/docs/userguide.html#_mouse_button_commands

Signed-off-by: Joan Bruguera Micó <[email protected]>
  • Loading branch information
joanbm committed Aug 15, 2024
1 parent cb34a0e commit 16004e5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions swaybar/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ bool handle_workspace_button(struct swaybar_output *output,
}
ipc_send_workspace_command(output->bar, ws);
return true;
} else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN ||
button == SWAY_SCROLL_LEFT || button == SWAY_SCROLL_RIGHT) {
if (released) {
return true;
}

workspace_next(output->bar, output,
button == SWAY_SCROLL_UP || button == SWAY_SCROLL_LEFT);
return true;
}

return false;
Expand All @@ -266,6 +275,7 @@ static void process_discrete_scroll(struct swaybar_seat *seat,
return;
}

// If no hotspot nor binding handles the event, scroll through workspaces
struct swaybar_config *config = seat->bar->config;
double amt = wl_fixed_to_double(value);
if (amt == 0.0 || !config->workspace_buttons) {
Expand Down

0 comments on commit 16004e5

Please sign in to comment.