summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-09-04 11:00:12 -0400
committerLibravatar GitHub <noreply@github.com>2018-09-04 11:00:12 -0400
commit309fcf23007a7c1b5c1c6da6b5ff7101312488cc (patch)
tree9e581c403ef8b99df78bddb7e54be856ada4514e
parentMerge pull request #2561 from RyanDwyer/window-role-criteria (diff)
parentDeny repeating reload by holding key (diff)
downloadsway-309fcf23007a7c1b5c1c6da6b5ff7101312488cc.tar.gz
sway-309fcf23007a7c1b5c1c6da6b5ff7101312488cc.tar.zst
sway-309fcf23007a7c1b5c1c6da6b5ff7101312488cc.zip
Merge pull request #2569 from RyanDwyer/deny-reload-repeat
Deny repeating reload by holding key
-rw-r--r--include/sway/config.h9
-rw-r--r--sway/commands/bind.c9
-rw-r--r--sway/input/keyboard.c5
3 files changed, 14 insertions, 9 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index 4ee8c3c2..6024f0f6 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -31,10 +31,11 @@ enum binding_input_type {
31 31
32enum binding_flags { 32enum binding_flags {
33 BINDING_RELEASE=1, 33 BINDING_RELEASE=1,
34 BINDING_LOCKED=2, // keyboard only 34 BINDING_LOCKED=2, // keyboard only
35 BINDING_BORDER=4, // mouse only; trigger on container border 35 BINDING_BORDER=4, // mouse only; trigger on container border
36 BINDING_CONTENTS=8, // mouse only; trigger on container contents 36 BINDING_CONTENTS=8, // mouse only; trigger on container contents
37 BINDING_TITLEBAR=16 // mouse only; trigger on container titlebar 37 BINDING_TITLEBAR=16, // mouse only; trigger on container titlebar
38 BINDING_RELOAD=32, // the binding runs the reload command
38}; 39};
39 40
40/** 41/**
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);
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 160ef10b..0d2a62b5 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -280,7 +280,10 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
280 if (binding_pressed) { 280 if (binding_pressed) {
281 seat_execute_command(seat, binding_pressed); 281 seat_execute_command(seat, binding_pressed);
282 handled = true; 282 handled = true;
283 next_repeat_binding = binding_pressed; 283
284 if ((binding_pressed->flags & BINDING_RELOAD) == 0) {
285 next_repeat_binding = binding_pressed;
286 }
284 } 287 }
285 } 288 }
286 289