mirror of
https://github.com/swaywm/sway.git
synced 2025-11-19 06:59:52 -05:00
bar-bindsym: address ianyfan's comments
This commit is contained in:
parent
1c969e86f5
commit
d3f0e52784
5 changed files with 28 additions and 18 deletions
|
|
@ -149,9 +149,6 @@ static bool check_bindings(struct swaybar *bar, uint32_t x11_button,
|
|||
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;
|
||||
|
|
@ -201,8 +198,12 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
|
|||
return;
|
||||
}
|
||||
|
||||
// If there is a button press binding, execute it, skip default behavior,
|
||||
// and check button release bindings
|
||||
if (check_bindings(bar, wl_axis_to_x11_button(axis, value),
|
||||
WL_POINTER_BUTTON_STATE_PRESSED)) {
|
||||
WL_POINTER_BUTTON_STATE_PRESSED)) {
|
||||
check_bindings(bar, wl_axis_to_x11_button(axis, value),
|
||||
WL_POINTER_BUTTON_STATE_RELEASED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -273,6 +274,10 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
|
|||
}
|
||||
|
||||
ipc_send_workspace_command(bar, new->name);
|
||||
|
||||
// Check button release bindings
|
||||
check_bindings(bar, wl_axis_to_x11_button(axis, value),
|
||||
WL_POINTER_BUTTON_STATE_RELEASED);
|
||||
}
|
||||
|
||||
static void wl_pointer_frame(void *data, struct wl_pointer *wl_pointer) {
|
||||
|
|
|
|||
|
|
@ -72,16 +72,22 @@ struct swaybar_config *init_config(void) {
|
|||
return config;
|
||||
}
|
||||
|
||||
static void free_binding(struct swaybar_binding *binding) {
|
||||
if (!binding) {
|
||||
return;
|
||||
}
|
||||
free(binding->command);
|
||||
free(binding);
|
||||
}
|
||||
|
||||
void free_config(struct swaybar_config *config) {
|
||||
free(config->status_command);
|
||||
free(config->font);
|
||||
free(config->mode);
|
||||
free(config->sep_symbol);
|
||||
while (config->bindings->length) {
|
||||
struct swaybar_binding *binding = config->bindings->items[0];
|
||||
list_del(config->bindings, 0);
|
||||
free(binding->command);
|
||||
free(binding);
|
||||
for (int i = 0; i < config->bindings->length; i++) {
|
||||
struct swaybar_binding *binding = config->bindings->items[i];
|
||||
free_binding(binding);
|
||||
}
|
||||
list_free(config->bindings);
|
||||
struct config_output *coutput, *tmp;
|
||||
|
|
|
|||
|
|
@ -338,6 +338,8 @@ static void ipc_get_outputs(struct swaybar *bar) {
|
|||
}
|
||||
|
||||
void ipc_execute_binding(struct swaybar *bar, struct swaybar_binding *bind) {
|
||||
wlr_log(WLR_DEBUG, "Executing binding for button %u (release=%d): `%s`",
|
||||
bind->button, bind->release, bind->command);
|
||||
uint32_t len = strlen(bind->command);
|
||||
free(ipc_single_command(bar->ipc_socketfd,
|
||||
IPC_COMMAND, bind->command, &len));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue