aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/bind.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/bind.c')
-rw-r--r--sway/commands/bind.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index c8b634b9..01a35cf2 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -23,9 +23,7 @@ void free_sway_binding(struct sway_binding *binding) {
23 return; 23 return;
24 } 24 }
25 25
26 if (binding->keys) { 26 list_free_items_and_destroy(binding->keys);
27 free_flat_list(binding->keys);
28 }
29 free(binding->input); 27 free(binding->input);
30 free(binding->command); 28 free(binding->command);
31 free(binding); 29 free(binding);
@@ -80,7 +78,6 @@ static int key_qsort_cmp(const void *keyp_a, const void *keyp_b) {
80 return (key_a < key_b) ? -1 : ((key_a > key_b) ? 1 : 0); 78 return (key_a < key_b) ? -1 : ((key_a > key_b) ? 1 : 0);
81} 79}
82 80
83
84/** 81/**
85 * From a keycode, bindcode, or bindsym name and the most likely binding type, 82 * From a keycode, bindcode, or bindsym name and the most likely binding type,
86 * identify the appropriate numeric value corresponding to the key. Return NULL 83 * identify the appropriate numeric value corresponding to the key. Return NULL
@@ -223,14 +220,14 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
223 uint32_t *key = calloc(1, sizeof(uint32_t)); 220 uint32_t *key = calloc(1, sizeof(uint32_t));
224 if (!key) { 221 if (!key) {
225 free_sway_binding(binding); 222 free_sway_binding(binding);
226 free_flat_list(split); 223 list_free_items_and_destroy(split);
227 return cmd_results_new(CMD_FAILURE, bindtype, 224 return cmd_results_new(CMD_FAILURE, bindtype,
228 "Unable to allocate binding key"); 225 "Unable to allocate binding key");
229 } 226 }
230 *key = key_val; 227 *key = key_val;
231 list_add(binding->keys, key); 228 list_add(binding->keys, key);
232 } 229 }
233 free_flat_list(split); 230 list_free_items_and_destroy(split);
234 binding->order = binding_order++; 231 binding->order = binding_order++;
235 232
236 // refine region of interest for mouse binding once we are certain 233 // refine region of interest for mouse binding once we are certain
@@ -280,7 +277,6 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
280 wlr_log(WLR_DEBUG, "%s - Bound %s to command `%s` for device '%s'", 277 wlr_log(WLR_DEBUG, "%s - Bound %s to command `%s` for device '%s'",
281 bindtype, argv[0], binding->command, binding->input); 278 bindtype, argv[0], binding->command, binding->input);
282 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 279 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
283
284} 280}
285 281
286struct cmd_results *cmd_bindsym(int argc, char **argv) { 282struct cmd_results *cmd_bindsym(int argc, char **argv) {
@@ -291,7 +287,6 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) {
291 return cmd_bindsym_or_bindcode(argc, argv, true); 287 return cmd_bindsym_or_bindcode(argc, argv, true);
292} 288}
293 289
294
295/** 290/**
296 * Execute the command associated to a binding 291 * Execute the command associated to a binding
297 */ 292 */
@@ -301,15 +296,14 @@ void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding)
301 config->handler_context.seat = seat; 296 config->handler_context.seat = seat;
302 list_t *res_list = execute_command(binding->command, NULL, NULL); 297 list_t *res_list = execute_command(binding->command, NULL, NULL);
303 bool success = true; 298 bool success = true;
304 while (res_list->length) { 299 for (int i = 0; i < res_list->length; ++i) {
305 struct cmd_results *results = res_list->items[0]; 300 struct cmd_results *results = res_list->items[i];
306 if (results->status != CMD_SUCCESS) { 301 if (results->status != CMD_SUCCESS) {
307 wlr_log(WLR_DEBUG, "could not run command for binding: %s (%s)", 302 wlr_log(WLR_DEBUG, "could not run command for binding: %s (%s)",
308 binding->command, results->error); 303 binding->command, results->error);
309 success = false; 304 success = false;
310 } 305 }
311 free_cmd_results(results); 306 free_cmd_results(results);
312 list_del(res_list, 0);
313 } 307 }
314 list_free(res_list); 308 list_free(res_list);
315 if (success) { 309 if (success) {