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.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index 4c67b3ce..268f2855 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -1,4 +1,3 @@
1#define _POSIX_C_SOURCE 200809L
2#include <libevdev/libevdev.h> 1#include <libevdev/libevdev.h>
3#include <linux/input-event-codes.h> 2#include <linux/input-event-codes.h>
4#include <string.h> 3#include <string.h>
@@ -47,7 +46,7 @@ static bool binding_switch_compare(struct sway_switch_binding *binding_a,
47 if (binding_a->type != binding_b->type) { 46 if (binding_a->type != binding_b->type) {
48 return false; 47 return false;
49 } 48 }
50 if (binding_a->state != binding_b->state) { 49 if (binding_a->trigger != binding_b->trigger) {
51 return false; 50 return false;
52 } 51 }
53 if ((binding_a->flags & BINDING_LOCKED) != 52 if ((binding_a->flags & BINDING_LOCKED) !=
@@ -127,7 +126,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
127 if (!button) { 126 if (!button) {
128 if (message) { 127 if (message) {
129 struct cmd_results *error = 128 struct cmd_results *error =
130 cmd_results_new(CMD_INVALID, message); 129 cmd_results_new(CMD_INVALID, "%s", message);
131 free(message); 130 free(message);
132 return error; 131 return error;
133 } else { 132 } else {
@@ -143,7 +142,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
143 if (!button) { 142 if (!button) {
144 if (message) { 143 if (message) {
145 struct cmd_results *error = 144 struct cmd_results *error =
146 cmd_results_new(CMD_INVALID, message); 145 cmd_results_new(CMD_INVALID, "%s", message);
147 free(message); 146 free(message);
148 return error; 147 return error;
149 } else { 148 } else {
@@ -182,7 +181,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
182 uint32_t button = get_mouse_bindsym(name, &message); 181 uint32_t button = get_mouse_bindsym(name, &message);
183 if (message) { 182 if (message) {
184 struct cmd_results *error = 183 struct cmd_results *error =
185 cmd_results_new(CMD_INVALID, message); 184 cmd_results_new(CMD_INVALID, "%s", message);
186 free(message); 185 free(message);
187 return error; 186 return error;
188 } else if (button) { 187 } else if (button) {
@@ -372,6 +371,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
372 strlen("--input-device=")) == 0) { 371 strlen("--input-device=")) == 0) {
373 free(binding->input); 372 free(binding->input);
374 binding->input = strdup(argv[0] + strlen("--input-device=")); 373 binding->input = strdup(argv[0] + strlen("--input-device="));
374 strip_quotes(binding->input);
375 } else if (strcmp("--no-warn", argv[0]) == 0) { 375 } else if (strcmp("--no-warn", argv[0]) == 0) {
376 warn = false; 376 warn = false;
377 } else if (strcmp("--no-repeat", argv[0]) == 0) { 377 } else if (strcmp("--no-repeat", argv[0]) == 0) {
@@ -538,7 +538,7 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
538 free_switch_binding(binding); 538 free_switch_binding(binding);
539 return cmd_results_new(CMD_FAILURE, 539 return cmd_results_new(CMD_FAILURE,
540 "Invalid %s command (expected binding with the form " 540 "Invalid %s command (expected binding with the form "
541 "<switch>:<state>)", bindtype, argc); 541 "<switch>:<state>)", bindtype);
542 } 542 }
543 if (strcmp(split->items[0], "tablet") == 0) { 543 if (strcmp(split->items[0], "tablet") == 0) {
544 binding->type = WLR_SWITCH_TYPE_TABLET_MODE; 544 binding->type = WLR_SWITCH_TYPE_TABLET_MODE;
@@ -548,20 +548,21 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
548 free_switch_binding(binding); 548 free_switch_binding(binding);
549 return cmd_results_new(CMD_FAILURE, 549 return cmd_results_new(CMD_FAILURE,
550 "Invalid %s command (expected switch binding: " 550 "Invalid %s command (expected switch binding: "
551 "unknown switch %s)", bindtype, split->items[0]); 551 "unknown switch %s)", bindtype,
552 (const char *)split->items[0]);
552 } 553 }
553 if (strcmp(split->items[1], "on") == 0) { 554 if (strcmp(split->items[1], "on") == 0) {
554 binding->state = WLR_SWITCH_STATE_ON; 555 binding->trigger = SWAY_SWITCH_TRIGGER_ON;
555 } else if (strcmp(split->items[1], "off") == 0) { 556 } else if (strcmp(split->items[1], "off") == 0) {
556 binding->state = WLR_SWITCH_STATE_OFF; 557 binding->trigger = SWAY_SWITCH_TRIGGER_OFF;
557 } else if (strcmp(split->items[1], "toggle") == 0) { 558 } else if (strcmp(split->items[1], "toggle") == 0) {
558 binding->state = WLR_SWITCH_STATE_TOGGLE; 559 binding->trigger = SWAY_SWITCH_TRIGGER_TOGGLE;
559 } else { 560 } else {
560 free_switch_binding(binding); 561 free_switch_binding(binding);
561 return cmd_results_new(CMD_FAILURE, 562 return cmd_results_new(CMD_FAILURE,
562 "Invalid %s command " 563 "Invalid %s command "
563 "(expected switch state: unknown state %d)", 564 "(expected switch state: unknown state %s)",
564 bindtype, split->items[0]); 565 bindtype, (const char *)split->items[1]);
565 } 566 }
566 list_free_items_and_destroy(split); 567 list_free_items_and_destroy(split);
567 568