diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-01-08 09:48:24 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-01-08 09:48:24 -0500 |
commit | e2d49afb4a9cf1c333cbb1e18360026508b79a60 (patch) | |
tree | 37391772505203dd0ac0b533e89359b0d5d6e040 /sway/handlers.c | |
parent | 320c2915b0aeb4bbecb753bf00091e24905c5652 (diff) | |
parent | 15cbc53a771f35e5510b643193c4ba99e9f820a2 (diff) |
Merge pull request #438 from mikkeloscar/binding-event
Implement IPC binding event (keyboard)
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index e0acebea..76778450 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -336,6 +336,29 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s return; } +static void handle_binding_command(struct sway_binding *binding) { + struct sway_binding *binding_copy = binding; + bool reload = false; + // if this is a reload command we need to make a duplicate of the + // binding since it will be gone after the reload has completed. + if (strcasecmp(binding->command, "reload") == 0) { + binding_copy = sway_binding_dup(binding); + reload = true; + } + + struct cmd_results *res = handle_command(binding->command); + if (res->status != CMD_SUCCESS) { + sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error); + } + ipc_event_binding_keyboard(binding_copy); + + if (reload) { // free the binding if we made a copy + free_sway_binding(binding_copy); + } + + free_cmd_results(res); +} + static bool handle_bindsym(struct sway_binding *binding) { bool match = false; int i; @@ -347,11 +370,7 @@ static bool handle_bindsym(struct sway_binding *binding) { } if (match) { - struct cmd_results *res = handle_command(binding->command); - if (res->status != CMD_SUCCESS) { - sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error); - } - free_cmd_results(res); + handle_binding_command(binding); return true; } @@ -362,11 +381,7 @@ static bool handle_bindsym_release(struct sway_binding *binding) { if (binding->keys->length == 1) { xkb_keysym_t *key = binding->keys->items[0]; if (check_released_key(*key)) { - struct cmd_results *res = handle_command(binding->command); - if (res->status != CMD_SUCCESS) { - sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error); - } - free_cmd_results(res); + handle_binding_command(binding); return true; } } |