diff options
author | emersion <contact@emersion.fr> | 2018-05-27 20:11:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-27 20:11:04 +0100 |
commit | c3b8c7cfb4f07f058a2c67b19e35baffbde929ad (patch) | |
tree | 8870a8acc8d92d10d64e9d3d9bfdd28dedb6eea7 /sway/commands/bind.c | |
parent | 0743b21cc89141c6783210a1f20b6b372b24ae59 (diff) | |
parent | a78a5684ea8a19e54d797ab6cddd2f81f88360a5 (diff) |
Merge pull request #2056 from frsfnrrg/add-binding-locked
Implement bindsym/bindcode --locked
Diffstat (limited to 'sway/commands/bind.c')
-rw-r--r-- | sway/commands/bind.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c index cbabb07b..c6b3368a 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -83,20 +83,26 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) { binding->keys = create_list(); binding->modifiers = 0; binding->release = false; + binding->locked = false; binding->bindcode = false; - // Handle --release - if (strcmp("--release", argv[0]) == 0) { - if (argc >= 3) { + // Handle --release and --locked + while (argc > 0) { + if (strcmp("--release", argv[0]) == 0) { binding->release = true; - argv++; - argc--; + } else if (strcmp("--locked", argv[0]) == 0) { + binding->locked = true; } else { - free_sway_binding(binding); - return cmd_results_new(CMD_FAILURE, "bindsym", - "Invalid bindsym command " - "(expected more than 2 arguments, got %d)", argc); + break; } + argv++; + argc--; + } + if (argc < 2) { + free_sway_binding(binding); + return cmd_results_new(CMD_FAILURE, "bindsym", + "Invalid bindsym command " + "(expected at least 2 non-option arguments, got %d)", argc); } binding->command = join_args(argv + 1, argc - 1); @@ -176,20 +182,26 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) { binding->keys = create_list(); binding->modifiers = 0; binding->release = false; + binding->locked = false; binding->bindcode = true; - // Handle --release - if (strcmp("--release", argv[0]) == 0) { - if (argc >= 3) { + // Handle --release and --locked + while (argc > 0) { + if (strcmp("--release", argv[0]) == 0) { binding->release = true; - argv++; - argc--; + } else if (strcmp("--locked", argv[0]) == 0) { + binding->locked = true; } else { - free_sway_binding(binding); - return cmd_results_new(CMD_FAILURE, "bindcode", - "Invalid bindcode command " - "(expected more than 2 arguments, got %d)", argc); + break; } + argv++; + argc--; + } + if (argc < 2) { + free_sway_binding(binding); + return cmd_results_new(CMD_FAILURE, "bindcode", + "Invalid bindcode command " + "(expected at least 2 non-option arguments, got %d)", argc); } binding->command = join_args(argv + 1, argc - 1); |