From 6afb392823d27ec69bedc8fd74263c3d072cca29 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Thu, 30 May 2019 03:30:08 -0400 Subject: 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=` 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. --- sway/commands/bind.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sway/commands') 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, if (binding_a->state != binding_b->state) { return false; } + if ((binding_a->flags & BINDING_LOCKED) != + (binding_b->flags & BINDING_LOCKED)) { + return false; + } return true; } @@ -68,7 +72,7 @@ static bool binding_key_compare(struct sway_binding *binding_a, } uint32_t conflict_generating_flags = BINDING_RELEASE | BINDING_BORDER - | BINDING_CONTENTS | BINDING_TITLEBAR; + | BINDING_CONTENTS | BINDING_TITLEBAR | BINDING_LOCKED; if ((binding_a->flags & conflict_generating_flags) != (binding_b->flags & conflict_generating_flags)) { return false; -- cgit v1.2.3