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.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index be47d412..b0493f7e 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -92,11 +92,11 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
92 if (!button) { 92 if (!button) {
93 if (message) { 93 if (message) {
94 struct cmd_results *error = 94 struct cmd_results *error =
95 cmd_results_new(CMD_INVALID, "bindcode", message); 95 cmd_results_new(CMD_INVALID, message);
96 free(message); 96 free(message);
97 return error; 97 return error;
98 } else { 98 } else {
99 return cmd_results_new(CMD_INVALID, "bindcode", 99 return cmd_results_new(CMD_INVALID,
100 "Unknown button code %s", name); 100 "Unknown button code %s", name);
101 } 101 }
102 } 102 }
@@ -108,12 +108,11 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
108 if (!button) { 108 if (!button) {
109 if (message) { 109 if (message) {
110 struct cmd_results *error = 110 struct cmd_results *error =
111 cmd_results_new(CMD_INVALID, "bindsym", message); 111 cmd_results_new(CMD_INVALID, message);
112 free(message); 112 free(message);
113 return error; 113 return error;
114 } else if (!button) { 114 } else if (!button) {
115 return cmd_results_new(CMD_INVALID, "bindsym", 115 return cmd_results_new(CMD_INVALID, "Unknown button %s", name);
116 "Unknown button %s", name);
117 } 116 }
118 } 117 }
119 *key_val = button; 118 *key_val = button;
@@ -133,10 +132,10 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
133 xkb_keycode_t keycode = strtol(name, NULL, 10); 132 xkb_keycode_t keycode = strtol(name, NULL, 10);
134 if (!xkb_keycode_is_legal_ext(keycode)) { 133 if (!xkb_keycode_is_legal_ext(keycode)) {
135 if (first_key) { 134 if (first_key) {
136 return cmd_results_new(CMD_INVALID, "bindcode", 135 return cmd_results_new(CMD_INVALID,
137 "Invalid keycode or button code '%s'", name); 136 "Invalid keycode or button code '%s'", name);
138 } else { 137 } else {
139 return cmd_results_new(CMD_INVALID, "bindcode", 138 return cmd_results_new(CMD_INVALID,
140 "Invalid keycode '%s'", name); 139 "Invalid keycode '%s'", name);
141 } 140 }
142 } 141 }
@@ -148,7 +147,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
148 uint32_t button = get_mouse_bindsym(name, &message); 147 uint32_t button = get_mouse_bindsym(name, &message);
149 if (message) { 148 if (message) {
150 struct cmd_results *error = 149 struct cmd_results *error =
151 cmd_results_new(CMD_INVALID, "bindsym", message); 150 cmd_results_new(CMD_INVALID, message);
152 free(message); 151 free(message);
153 return error; 152 return error;
154 } else if (button) { 153 } else if (button) {
@@ -162,11 +161,10 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
162 XKB_KEYSYM_CASE_INSENSITIVE); 161 XKB_KEYSYM_CASE_INSENSITIVE);
163 if (!keysym) { 162 if (!keysym) {
164 if (first_key) { 163 if (first_key) {
165 return cmd_results_new(CMD_INVALID, "bindsym", 164 return cmd_results_new(CMD_INVALID,
166 "Unknown key or button '%s'", name); 165 "Unknown key or button '%s'", name);
167 } else { 166 } else {
168 return cmd_results_new(CMD_INVALID, "bindsym", 167 return cmd_results_new(CMD_INVALID, "Unknown key '%s'", name);
169 "Unknown key '%s'", name);
170 } 168 }
171 } 169 }
172 *key_val = keysym; 170 *key_val = keysym;
@@ -185,8 +183,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
185 183
186 struct sway_binding *binding = calloc(1, sizeof(struct sway_binding)); 184 struct sway_binding *binding = calloc(1, sizeof(struct sway_binding));
187 if (!binding) { 185 if (!binding) {
188 return cmd_results_new(CMD_FAILURE, bindtype, 186 return cmd_results_new(CMD_FAILURE, "Unable to allocate binding");
189 "Unable to allocate binding");
190 } 187 }
191 binding->input = strdup("*"); 188 binding->input = strdup("*");
192 binding->keys = create_list(); 189 binding->keys = create_list();
@@ -229,7 +226,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
229 226
230 if (argc < 2) { 227 if (argc < 2) {
231 free_sway_binding(binding); 228 free_sway_binding(binding);
232 return cmd_results_new(CMD_FAILURE, bindtype, 229 return cmd_results_new(CMD_FAILURE,
233 "Invalid %s command " 230 "Invalid %s command "
234 "(expected at least 2 non-option arguments, got %d)", bindtype, argc); 231 "(expected at least 2 non-option arguments, got %d)", bindtype, argc);
235 } 232 }
@@ -259,7 +256,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
259 if (!key) { 256 if (!key) {
260 free_sway_binding(binding); 257 free_sway_binding(binding);
261 list_free_items_and_destroy(split); 258 list_free_items_and_destroy(split);
262 return cmd_results_new(CMD_FAILURE, bindtype, 259 return cmd_results_new(CMD_FAILURE,
263 "Unable to allocate binding key"); 260 "Unable to allocate binding key");
264 } 261 }
265 *key = key_val; 262 *key = key_val;
@@ -315,7 +312,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
315 312
316 wlr_log(WLR_DEBUG, "%s - Bound %s to command `%s` for device '%s'", 313 wlr_log(WLR_DEBUG, "%s - Bound %s to command `%s` for device '%s'",
317 bindtype, argv[0], binding->command, binding->input); 314 bindtype, argv[0], binding->command, binding->input);
318 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 315 return cmd_results_new(CMD_SUCCESS, NULL);
319} 316}
320 317
321struct cmd_results *cmd_bindsym(int argc, char **argv) { 318struct cmd_results *cmd_bindsym(int argc, char **argv) {