mirror of
https://github.com/swaywm/sway.git
synced 2025-10-29 05:40:18 -04:00
Implement bar bindsym
This commit is contained in:
parent
e143c9613d
commit
1c969e86f5
10 changed files with 172 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue