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.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index f6e58d99..979e178f 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -8,6 +8,7 @@
8#include <wlr/types/wlr_cursor.h> 8#include <wlr/types/wlr_cursor.h>
9#include "sway/commands.h" 9#include "sway/commands.h"
10#include "sway/config.h" 10#include "sway/config.h"
11#include "sway/desktop/transaction.h"
11#include "sway/input/cursor.h" 12#include "sway/input/cursor.h"
12#include "sway/input/keyboard.h" 13#include "sway/input/keyboard.h"
13#include "sway/ipc-server.h" 14#include "sway/ipc-server.h"
@@ -46,7 +47,7 @@ static bool binding_switch_compare(struct sway_switch_binding *binding_a,
46 if (binding_a->type != binding_b->type) { 47 if (binding_a->type != binding_b->type) {
47 return false; 48 return false;
48 } 49 }
49 if (binding_a->state != binding_b->state) { 50 if (binding_a->trigger != binding_b->trigger) {
50 return false; 51 return false;
51 } 52 }
52 if ((binding_a->flags & BINDING_LOCKED) != 53 if ((binding_a->flags & BINDING_LOCKED) !=
@@ -126,7 +127,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
126 if (!button) { 127 if (!button) {
127 if (message) { 128 if (message) {
128 struct cmd_results *error = 129 struct cmd_results *error =
129 cmd_results_new(CMD_INVALID, message); 130 cmd_results_new(CMD_INVALID, "%s", message);
130 free(message); 131 free(message);
131 return error; 132 return error;
132 } else { 133 } else {
@@ -142,7 +143,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
142 if (!button) { 143 if (!button) {
143 if (message) { 144 if (message) {
144 struct cmd_results *error = 145 struct cmd_results *error =
145 cmd_results_new(CMD_INVALID, message); 146 cmd_results_new(CMD_INVALID, "%s", message);
146 free(message); 147 free(message);
147 return error; 148 return error;
148 } else { 149 } else {
@@ -181,7 +182,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
181 uint32_t button = get_mouse_bindsym(name, &message); 182 uint32_t button = get_mouse_bindsym(name, &message);
182 if (message) { 183 if (message) {
183 struct cmd_results *error = 184 struct cmd_results *error =
184 cmd_results_new(CMD_INVALID, message); 185 cmd_results_new(CMD_INVALID, "%s", message);
185 free(message); 186 free(message);
186 return error; 187 return error;
187 } else if (button) { 188 } else if (button) {
@@ -371,6 +372,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
371 strlen("--input-device=")) == 0) { 372 strlen("--input-device=")) == 0) {
372 free(binding->input); 373 free(binding->input);
373 binding->input = strdup(argv[0] + strlen("--input-device=")); 374 binding->input = strdup(argv[0] + strlen("--input-device="));
375 strip_quotes(binding->input);
374 } else if (strcmp("--no-warn", argv[0]) == 0) { 376 } else if (strcmp("--no-warn", argv[0]) == 0) {
375 warn = false; 377 warn = false;
376 } else if (strcmp("--no-repeat", argv[0]) == 0) { 378 } else if (strcmp("--no-repeat", argv[0]) == 0) {
@@ -537,7 +539,7 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
537 free_switch_binding(binding); 539 free_switch_binding(binding);
538 return cmd_results_new(CMD_FAILURE, 540 return cmd_results_new(CMD_FAILURE,
539 "Invalid %s command (expected binding with the form " 541 "Invalid %s command (expected binding with the form "
540 "<switch>:<state>)", bindtype, argc); 542 "<switch>:<state>)", bindtype);
541 } 543 }
542 if (strcmp(split->items[0], "tablet") == 0) { 544 if (strcmp(split->items[0], "tablet") == 0) {
543 binding->type = WLR_SWITCH_TYPE_TABLET_MODE; 545 binding->type = WLR_SWITCH_TYPE_TABLET_MODE;
@@ -547,20 +549,21 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
547 free_switch_binding(binding); 549 free_switch_binding(binding);
548 return cmd_results_new(CMD_FAILURE, 550 return cmd_results_new(CMD_FAILURE,
549 "Invalid %s command (expected switch binding: " 551 "Invalid %s command (expected switch binding: "
550 "unknown switch %s)", bindtype, split->items[0]); 552 "unknown switch %s)", bindtype,
553 (const char *)split->items[0]);
551 } 554 }
552 if (strcmp(split->items[1], "on") == 0) { 555 if (strcmp(split->items[1], "on") == 0) {
553 binding->state = WLR_SWITCH_STATE_ON; 556 binding->trigger = SWAY_SWITCH_TRIGGER_ON;
554 } else if (strcmp(split->items[1], "off") == 0) { 557 } else if (strcmp(split->items[1], "off") == 0) {
555 binding->state = WLR_SWITCH_STATE_OFF; 558 binding->trigger = SWAY_SWITCH_TRIGGER_OFF;
556 } else if (strcmp(split->items[1], "toggle") == 0) { 559 } else if (strcmp(split->items[1], "toggle") == 0) {
557 binding->state = WLR_SWITCH_STATE_TOGGLE; 560 binding->trigger = SWAY_SWITCH_TRIGGER_TOGGLE;
558 } else { 561 } else {
559 free_switch_binding(binding); 562 free_switch_binding(binding);
560 return cmd_results_new(CMD_FAILURE, 563 return cmd_results_new(CMD_FAILURE,
561 "Invalid %s command " 564 "Invalid %s command "
562 "(expected switch state: unknown state %d)", 565 "(expected switch state: unknown state %s)",
563 bindtype, split->items[0]); 566 bindtype, (const char *)split->items[1]);
564 } 567 }
565 list_free_items_and_destroy(split); 568 list_free_items_and_destroy(split);
566 569
@@ -642,6 +645,8 @@ void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding)
642 if (success) { 645 if (success) {
643 ipc_event_binding(binding); 646 ipc_event_binding(binding);
644 } 647 }
648
649 transaction_commit_dirty();
645} 650}
646 651
647/** 652/**