aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/switch.c
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2022-03-08 16:24:27 +0100
committerLibravatar Simon Zeni <simon@bl4ckb0ne.ca>2022-03-08 13:24:11 -0500
commit04676936e71f6fccccb098f3232d16572b140902 (patch)
treeaf19eb7696ba9c01491f307255c7f34d0a9f1aac /sway/input/switch.c
parentcommands/focus: fix segfault when no container is already focused. (diff)
downloadsway-04676936e71f6fccccb098f3232d16572b140902.tar.gz
sway-04676936e71f6fccccb098f3232d16572b140902.tar.zst
sway-04676936e71f6fccccb098f3232d16572b140902.zip
Remove WLR_SWITCH_STATE_TOGGLE usage
Ref [1]. [1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/4792446ee8f50104bd207d9ccd8558a7e4eb4514
Diffstat (limited to 'sway/input/switch.c')
-rw-r--r--sway/input/switch.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sway/input/switch.c b/sway/input/switch.c
index 9ea87a1a..fc296d18 100644
--- a/sway/input/switch.c
+++ b/sway/input/switch.c
@@ -19,6 +19,19 @@ struct sway_switch *sway_switch_create(struct sway_seat *seat,
19 return switch_device; 19 return switch_device;
20} 20}
21 21
22static bool sway_switch_trigger_test(enum sway_switch_trigger trigger,
23 enum wlr_switch_state state) {
24 switch (trigger) {
25 case SWAY_SWITCH_TRIGGER_ON:
26 return state == WLR_SWITCH_STATE_ON;
27 case SWAY_SWITCH_TRIGGER_OFF:
28 return state == WLR_SWITCH_STATE_OFF;
29 case SWAY_SWITCH_TRIGGER_TOGGLE:
30 return true;
31 }
32 abort(); // unreachable
33}
34
22static void execute_binding(struct sway_switch *sway_switch) { 35static void execute_binding(struct sway_switch *sway_switch) {
23 struct sway_seat* seat = sway_switch->seat_device->sway_seat; 36 struct sway_seat* seat = sway_switch->seat_device->sway_seat;
24 bool input_inhibited = seat->exclusive_client != NULL; 37 bool input_inhibited = seat->exclusive_client != NULL;
@@ -30,11 +43,10 @@ static void execute_binding(struct sway_switch *sway_switch) {
30 if (binding->type != sway_switch->type) { 43 if (binding->type != sway_switch->type) {
31 continue; 44 continue;
32 } 45 }
33 if (binding->state != WLR_SWITCH_STATE_TOGGLE && 46 if (!sway_switch_trigger_test(binding->trigger, sway_switch->state)) {
34 binding->state != sway_switch->state) {
35 continue; 47 continue;
36 } 48 }
37 if (config->reloading && (binding->state == WLR_SWITCH_STATE_TOGGLE 49 if (config->reloading && (binding->trigger == SWAY_SWITCH_TRIGGER_TOGGLE
38 || (binding->flags & BINDING_RELOAD) == 0)) { 50 || (binding->flags & BINDING_RELOAD) == 0)) {
39 continue; 51 continue;
40 } 52 }