mirror of
https://github.com/swaywm/sway.git
synced 2025-10-08 21:25:58 +00:00
Merge 9431d0603e
into bc96d0acdf
This commit is contained in:
commit
2055194e58
3 changed files with 30 additions and 10 deletions
|
@ -78,6 +78,9 @@ uint32_t event_to_x11_button(uint32_t event);
|
||||||
|
|
||||||
void free_hotspots(struct wl_list *list);
|
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);
|
void swaybar_seat_free(struct swaybar_seat *seat);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -236,6 +236,30 @@ 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;
|
||||||
|
} 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;
|
||||||
|
}
|
||||||
|
|
||||||
static void process_discrete_scroll(struct swaybar_seat *seat,
|
static void process_discrete_scroll(struct swaybar_seat *seat,
|
||||||
struct swaybar_output *output, struct swaybar_pointer *pointer,
|
struct swaybar_output *output, struct swaybar_pointer *pointer,
|
||||||
uint32_t axis, wl_fixed_t value) {
|
uint32_t axis, wl_fixed_t value) {
|
||||||
|
@ -251,6 +275,7 @@ static void process_discrete_scroll(struct swaybar_seat *seat,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no hotspot nor binding handles the event, scroll through workspaces
|
||||||
struct swaybar_config *config = seat->bar->config;
|
struct swaybar_config *config = seat->bar->config;
|
||||||
double amt = wl_fixed_to_double(value);
|
double amt = wl_fixed_to_double(value);
|
||||||
if (amt == 0.0 || !config->workspace_buttons) {
|
if (amt == 0.0 || !config->workspace_buttons) {
|
||||||
|
|
|
@ -613,16 +613,8 @@ static uint32_t render_binding_mode_indicator(struct render_context *ctx,
|
||||||
static enum hotspot_event_handling workspace_hotspot_callback(
|
static enum hotspot_event_handling workspace_hotspot_callback(
|
||||||
struct swaybar_output *output, struct swaybar_hotspot *hotspot,
|
struct swaybar_output *output, struct swaybar_hotspot *hotspot,
|
||||||
double x, double y, uint32_t button, bool released, void *data) {
|
double x, double y, uint32_t button, bool released, void *data) {
|
||||||
if (button != BTN_LEFT) {
|
return handle_workspace_button(output, button, released, (const char *)data)
|
||||||
return HOTSPOT_PROCESS;
|
? HOTSPOT_IGNORE : 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t render_workspace_button(struct render_context *ctx,
|
static uint32_t render_workspace_button(struct render_context *ctx,
|
||||||
|
|
Loading…
Add table
Reference in a new issue