swaybar: refactor workspace button handling logic

Move the workspace pointer/touch button handling logic from render.c
to input.c, and reorganize it so handling more buttons is more natural.
No functional change intended.

Signed-off-by: Joan Bruguera Micó <joanbrugueram@gmail.com>
This commit is contained in:
Joan Bruguera Micó 2024-08-15 11:17:16 +00:00
parent c30c451907
commit 39dc37c243
3 changed files with 20 additions and 10 deletions

View file

@ -236,6 +236,21 @@ static void workspace_next(struct swaybar *bar, struct swaybar_output *output,
}
}
bool handle_workspace_button(struct swaybar_output *output,
uint32_t button, bool released, const char *ws) {
if (button == BTN_LEFT) {
if (released) {
// Since we handle the pressed event, also handle the released event
// to block it from falling through to a binding in the bar
return true;
}
ipc_send_workspace_command(output->bar, ws);
return true;
}
return false;
}
static void process_discrete_scroll(struct swaybar_seat *seat,
struct swaybar_output *output, struct swaybar_pointer *pointer,
uint32_t axis, wl_fixed_t value) {