aboutsummaryrefslogtreecommitdiff
path: root/swaybar/bar.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r--swaybar/bar.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index 3990f1ca..3eeec5d4 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -144,6 +144,22 @@ static void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
bar->pointer.y = wl_fixed_to_int(surface_y);
}
+static bool check_bindings(struct swaybar *bar, uint32_t x11_button,
+ uint32_t state) {
+ bool released = state == WL_POINTER_BUTTON_STATE_RELEASED;
+ for (int i = 0; i < bar->config->bindings->length; i++) {
+ struct swaybar_binding *binding = bar->config->bindings->items[i];
+ wlr_log(WLR_DEBUG, "Checking [%u, %d] against [%u, %d, %s]",
+ x11_button, released,
+ binding->button, binding->release, binding->command);
+ if (binding->button == x11_button && binding->release == released) {
+ ipc_execute_binding(bar, binding);
+ return true;
+ }
+ }
+ return false;
+}
+
static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, uint32_t time, uint32_t button, uint32_t state) {
struct swaybar *bar = data;
@@ -152,6 +168,11 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
if (!sway_assert(output, "button with no active output")) {
return;
}
+
+ if (check_bindings(bar, wl_button_to_x11_button(button), state)) {
+ return;
+ }
+
if (state != WL_POINTER_BUTTON_STATE_PRESSED) {
return;
}
@@ -180,6 +201,11 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
return;
}
+ if (check_bindings(bar, wl_axis_to_x11_button(axis, value),
+ WL_POINTER_BUTTON_STATE_PRESSED)) {
+ return;
+ }
+
struct swaybar_hotspot *hotspot;
wl_list_for_each(hotspot, &output->hotspots, link) {
double x = pointer->x * output->scale;