diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2019-05-30 03:30:08 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-05-30 10:47:42 +0300 |
commit | 6afb392823d27ec69bedc8fd74263c3d072cca29 (patch) | |
tree | a1a72a233a2ef8e89240b7702d7c9eabb3444bf0 /sway/commands/bind.c | |
parent | Provide current DPMS state in GET_OUTPUTS (diff) | |
download | sway-6afb392823d27ec69bedc8fd74263c3d072cca29.tar.gz sway-6afb392823d27ec69bedc8fd74263c3d072cca29.tar.zst sway-6afb392823d27ec69bedc8fd74263c3d072cca29.zip |
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.
Diffstat (limited to 'sway/commands/bind.c')
-rw-r--r-- | sway/commands/bind.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c index ea8179bb..d43c87fb 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c | |||
@@ -49,6 +49,10 @@ static bool binding_switch_compare(struct sway_switch_binding *binding_a, | |||
49 | if (binding_a->state != binding_b->state) { | 49 | if (binding_a->state != binding_b->state) { |
50 | return false; | 50 | return false; |
51 | } | 51 | } |
52 | if ((binding_a->flags & BINDING_LOCKED) != | ||
53 | (binding_b->flags & BINDING_LOCKED)) { | ||
54 | return false; | ||
55 | } | ||
52 | return true; | 56 | return true; |
53 | } | 57 | } |
54 | 58 | ||
@@ -68,7 +72,7 @@ static bool binding_key_compare(struct sway_binding *binding_a, | |||
68 | } | 72 | } |
69 | 73 | ||
70 | uint32_t conflict_generating_flags = BINDING_RELEASE | BINDING_BORDER | 74 | uint32_t conflict_generating_flags = BINDING_RELEASE | BINDING_BORDER |
71 | | BINDING_CONTENTS | BINDING_TITLEBAR; | 75 | | BINDING_CONTENTS | BINDING_TITLEBAR | BINDING_LOCKED; |
72 | if ((binding_a->flags & conflict_generating_flags) != | 76 | if ((binding_a->flags & conflict_generating_flags) != |
73 | (binding_b->flags & conflict_generating_flags)) { | 77 | (binding_b->flags & conflict_generating_flags)) { |
74 | return false; | 78 | return false; |