diff --git a/include/swaybar/input.h b/include/swaybar/input.h index 8ea88a69a..35360c963 100644 --- a/include/swaybar/input.h +++ b/include/swaybar/input.h @@ -78,6 +78,9 @@ uint32_t event_to_x11_button(uint32_t event); void free_hotspots(struct wl_list *list); +bool handle_workspace_button(struct swaybar_output *output, + uint32_t button, bool released, const char *ws); + void swaybar_seat_free(struct swaybar_seat *seat); #endif diff --git a/swaybar/input.c b/swaybar/input.c index ada4bc862..d58628324 100644 --- a/swaybar/input.c +++ b/swaybar/input.c @@ -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) { diff --git a/swaybar/render.c b/swaybar/render.c index 879a4e42a..d0302eb64 100644 --- a/swaybar/render.c +++ b/swaybar/render.c @@ -599,16 +599,8 @@ static uint32_t render_binding_mode_indicator(struct render_context *ctx, static enum hotspot_event_handling workspace_hotspot_callback( struct swaybar_output *output, struct swaybar_hotspot *hotspot, double x, double y, uint32_t button, bool released, void *data) { - if (button != BTN_LEFT) { - return HOTSPOT_PROCESS; - } - 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 HOTSPOT_IGNORE; - } - ipc_send_workspace_command(output->bar, (const char *)data); - return HOTSPOT_IGNORE; + return handle_workspace_button(output, button, released, (const char *)data) + ? HOTSPOT_IGNORE : HOTSPOT_PROCESS; } static uint32_t render_workspace_button(struct render_context *ctx,