aboutsummaryrefslogtreecommitdiff
path: root/sway/handlers.c
diff options
context:
space:
mode:
authorMikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-01-08 14:41:09 +0100
committerMikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-01-08 15:03:25 +0100
commit15cbc53a771f35e5510b643193c4ba99e9f820a2 (patch)
tree37391772505203dd0ac0b533e89359b0d5d6e040 /sway/handlers.c
parent14147ac05676a4f914960311e3b49e4451c0576a (diff)
Make IPC binding event support a compile time opt.
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index a298ff3e..76778450 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -337,14 +337,26 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s
}
static void handle_binding_command(struct sway_binding *binding) {
- struct sway_binding *binding_copy = sway_binding_dup(binding);
- 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);
- free_cmd_results(res);
+ 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) {