aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Linus Heckemann <git@sphalerite.org>2020-03-23 12:34:04 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2020-03-30 14:18:27 +0200
commitdf48c48123de88a91362844881fa20eddc30f597 (patch)
tree307ec481503f0090519565dbf2c22b14e66ab5c0
parentChange focus_on_window_activation default to urgent (diff)
downloadsway-df48c48123de88a91362844881fa20eddc30f597.tar.gz
sway-df48c48123de88a91362844881fa20eddc30f597.tar.zst
sway-df48c48123de88a91362844881fa20eddc30f597.zip
add --no-repeat option for bindings
This allows e.g. triggering one command while a key is held, then triggering another to undo the change performed by it afterwards. One use case for this is triggering push-to-talk functionality for VoIP tools without granting them full access to all input events. Fixes #3151
-rw-r--r--include/sway/config.h1
-rw-r--r--sway/commands/bind.c2
-rw-r--r--sway/input/keyboard.c3
-rw-r--r--sway/sway.5.scd6
4 files changed, 10 insertions, 2 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index 359f9604..94ce6214 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -41,6 +41,7 @@ enum binding_flags {
41 BINDING_CODE=32, // keyboard only; convert keysyms into keycodes 41 BINDING_CODE=32, // keyboard only; convert keysyms into keycodes
42 BINDING_RELOAD=64, // switch only; (re)trigger binding on reload 42 BINDING_RELOAD=64, // switch only; (re)trigger binding on reload
43 BINDING_INHIBITED=128, // keyboard only: ignore shortcut inhibitor 43 BINDING_INHIBITED=128, // keyboard only: ignore shortcut inhibitor
44 BINDING_NOREPEAT=256, // keyboard only; do not trigger when repeating a held key
44}; 45};
45 46
46/** 47/**
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index c86c39dd..4e49982a 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -373,6 +373,8 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
373 binding->input = strdup(argv[0] + strlen("--input-device=")); 373 binding->input = strdup(argv[0] + strlen("--input-device="));
374 } else if (strcmp("--no-warn", argv[0]) == 0) { 374 } else if (strcmp("--no-warn", argv[0]) == 0) {
375 warn = false; 375 warn = false;
376 } else if (strcmp("--no-repeat", argv[0]) == 0) {
377 binding->flags |= BINDING_NOREPEAT;
376 } else { 378 } else {
377 break; 379 break;
378 } 380 }
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 9c5f190e..30756acb 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -431,7 +431,8 @@ static void handle_key_event(struct sway_keyboard *keyboard,
431 431
432 // Set up (or clear) keyboard repeat for a pressed binding. Since the 432 // Set up (or clear) keyboard repeat for a pressed binding. Since the
433 // binding may remove the keyboard, the timer needs to be updated first 433 // binding may remove the keyboard, the timer needs to be updated first
434 if (binding && wlr_device->keyboard->repeat_info.delay > 0) { 434 if (binding && !(binding->flags & BINDING_NOREPEAT) &&
435 wlr_device->keyboard->repeat_info.delay > 0) {
435 keyboard->repeat_binding = binding; 436 keyboard->repeat_binding = binding;
436 if (wl_event_source_timer_update(keyboard->key_repeat_source, 437 if (wl_event_source_timer_update(keyboard->key_repeat_source,
437 wlr_device->keyboard->repeat_info.delay) < 0) { 438 wlr_device->keyboard->repeat_info.delay) < 0) {
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index c9daba5d..1c396dfb 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -356,7 +356,7 @@ runtime.
356 for_window <criteria> move container to output <output> 356 for_window <criteria> move container to output <output>
357 357
358*bindsym* [--whole-window] [--border] [--exclude-titlebar] [--release] [--locked] \ 358*bindsym* [--whole-window] [--border] [--exclude-titlebar] [--release] [--locked] \
359[--to-code] [--input-device=<device>] [--no-warn] [Group<1-4>+]<key combo> \ 359[--to-code] [--input-device=<device>] [--no-warn] [--no-repeat] [Group<1-4>+]<key combo> \
360<command> 360<command>
361 Binds _key combo_ to execute the sway command _command_ when pressed. You 361 Binds _key combo_ to execute the sway command _command_ when pressed. You
362 may use XKB key names here (*xev*(1) is a good tool for discovering these). 362 may use XKB key names here (*xev*(1) is a good tool for discovering these).
@@ -382,6 +382,10 @@ runtime.
382 define bindings which will be exempt from pass-through to such 382 define bindings which will be exempt from pass-through to such
383 software. The same preference logic as for _--locked_ applies. 383 software. The same preference logic as for _--locked_ applies.
384 384
385 Unless the flag _--no-repeat_ is set, the command will be run
386 repeatedly when the key is held, according to the repeat
387 settings specified in the input configuration.
388
385 Bindings to keysyms are layout-dependent. This can be changed with the 389 Bindings to keysyms are layout-dependent. This can be changed with the
386 _--to-code_ flag. In this case, the keysyms will be translated into the 390 _--to-code_ flag. In this case, the keysyms will be translated into the
387 corresponding keycodes in the first configured layout. 391 corresponding keycodes in the first configured layout.