aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/bind.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-04 20:00:04 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-04 20:00:04 +1000
commit7797490e9e285589f501e46202df36b6bf8afcfd (patch)
tree9e581c403ef8b99df78bddb7e54be856ada4514e /sway/commands/bind.c
parentMerge pull request #2561 from RyanDwyer/window-role-criteria (diff)
downloadsway-7797490e9e285589f501e46202df36b6bf8afcfd.tar.gz
sway-7797490e9e285589f501e46202df36b6bf8afcfd.tar.zst
sway-7797490e9e285589f501e46202df36b6bf8afcfd.zip
Deny repeating reload by holding key
Fixes #2568 The binding that gets stored in the keyboard's `repeat_binding` would get freed on reload, leaving a dangling pointer. Rather than attempt to unset the keyboard's `repeat_binding` along with the other bindings, I opted to just not set it for the reload command because there's no point in reloading repeatedly by holding the binding. This disables repeat bindings for the reload command. As we now need to detect whether it's a reload command in two places, I've added a binding flag to track whether it's a reload or not.
Diffstat (limited to 'sway/commands/bind.c')
-rw-r--r--sway/commands/bind.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index b134c92f..5b56ba30 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -214,6 +214,9 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
214 } 214 }
215 215
216 binding->command = join_args(argv + 1, argc - 1); 216 binding->command = join_args(argv + 1, argc - 1);
217 if (strcasestr(binding->command, "reload")) {
218 binding->flags |= BINDING_RELOAD;
219 }
217 220
218 list_t *split = split_string(argv[0], "+"); 221 list_t *split = split_string(argv[0], "+");
219 for (int i = 0; i < split->length; ++i) { 222 for (int i = 0; i < split->length; ++i) {
@@ -307,11 +310,9 @@ void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding)
307 binding->command); 310 binding->command);
308 311
309 struct sway_binding *binding_copy = binding; 312 struct sway_binding *binding_copy = binding;
310 bool reload = false;
311 // if this is a reload command we need to make a duplicate of the 313 // if this is a reload command we need to make a duplicate of the
312 // binding since it will be gone after the reload has completed. 314 // binding since it will be gone after the reload has completed.
313 if (strcasestr(binding->command, "reload")) { 315 if (binding->flags & BINDING_RELOAD) {
314 reload = true;
315 binding_copy = sway_binding_dup(binding); 316 binding_copy = sway_binding_dup(binding);
316 if (!binding_copy) { 317 if (!binding_copy) {
317 wlr_log(WLR_ERROR, "Failed to duplicate binding during reload"); 318 wlr_log(WLR_ERROR, "Failed to duplicate binding during reload");
@@ -328,7 +329,7 @@ void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding)
328 binding->command, results->error); 329 binding->command, results->error);
329 } 330 }
330 331
331 if (reload) { // free the binding if we made a copy 332 if (binding->flags & BINDING_RELOAD) { // free the binding if we made a copy
332 free_sway_binding(binding_copy); 333 free_sway_binding(binding_copy);
333 } 334 }
334 free_cmd_results(results); 335 free_cmd_results(results);