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