bindings: allow unlocked and locked bindings

This changes the behavior of bindings to make the `BINDING_LOCKED` flag
conflicting, which will allow for both unlocked and locked bindings.

If there are two matching bindings and one has `--locked` and the other
does not, the one with `--locked` will be preferred when locked and
the one without will be preferred when unlocked.

If there are two matching bindings and one has both a matching
`--input-device=<input>` and `--locked` and the other has neither, the
former will be preferred for both unlocked and locked.

This also refactors `get_active_binding` in `sway/input/keyboard.c`
to make it easier to read.
This commit is contained in:
Brian Ashworth 2019-05-30 03:30:08 -04:00 committed by Simon Ser
parent 2c6a10c4ba
commit 6afb392823
4 changed files with 67 additions and 26 deletions

View file

@ -331,12 +331,17 @@ runtime.
Binds _key combo_ to execute the sway command _command_ when pressed. You
may use XKB key names here (*xev*(1) is a good tool for discovering these).
With the flag _--release_, the command is executed when the key combo is
released. Unless the flag _--locked_ is set, the command will not be run
when a screen locking program is active. If _input-device_ is given, the
binding will only be executed for that input device and will be executed
instead of any binding that is generic to all devices. By default, if you
overwrite a binding, swaynag will give you a warning. To silence this, use
the _--no-warn_ flag.
released. If _input-device_ is given, the binding will only be executed for
that input device and will be executed instead of any binding that is
generic to all devices. By default, if you overwrite a binding, swaynag
will give you a warning. To silence this, use the _--no-warn_ flag.
Unless the flag _--locked_ is set, the command will not be run when a
screen locking program is active. If there is a matching binding with
and without _--locked_, the one with will be preferred when locked and the
one without will be preferred when unlocked. If there are matching bindings
and one has both _--input-device_ and _--locked_ and the other has neither,
the former will be preferred even when unlocked.
Bindings to keysyms are layout-dependent. This can be changed with the
_--to-code_ flag. In this case, the keysyms will be translated into the
@ -380,10 +385,13 @@ runtime.
respectively. _toggle_ is also supported to run a command both when the
switch is toggled on or off.
Unless the flag _--locked_ is set, the command will not be run
when a screen locking program is active. By default, if you
overwrite a binding, swaynag will give you a warning. To silence this, use
the _--no-warn_ flag.
Unless the flag _--locked_ is set, the command will not be run when a
screen locking program is active. If there is a matching binding with
and without _--locked_, the one with will be preferred when locked and the
one without will be preferred when unlocked.
By default, if you overwrite a binding, swaynag will give you a warning. To
silence this, use the _--no-warn_ flag.
Example:
```