mirror of
https://github.com/swaywm/sway.git
synced 2026-04-17 06:46:32 -04:00
parent
9f98c38d3e
commit
04676936e7
3 changed files with 26 additions and 8 deletions
|
|
@ -19,6 +19,19 @@ struct sway_switch *sway_switch_create(struct sway_seat *seat,
|
|||
return switch_device;
|
||||
}
|
||||
|
||||
static bool sway_switch_trigger_test(enum sway_switch_trigger trigger,
|
||||
enum wlr_switch_state state) {
|
||||
switch (trigger) {
|
||||
case SWAY_SWITCH_TRIGGER_ON:
|
||||
return state == WLR_SWITCH_STATE_ON;
|
||||
case SWAY_SWITCH_TRIGGER_OFF:
|
||||
return state == WLR_SWITCH_STATE_OFF;
|
||||
case SWAY_SWITCH_TRIGGER_TOGGLE:
|
||||
return true;
|
||||
}
|
||||
abort(); // unreachable
|
||||
}
|
||||
|
||||
static void execute_binding(struct sway_switch *sway_switch) {
|
||||
struct sway_seat* seat = sway_switch->seat_device->sway_seat;
|
||||
bool input_inhibited = seat->exclusive_client != NULL;
|
||||
|
|
@ -30,11 +43,10 @@ static void execute_binding(struct sway_switch *sway_switch) {
|
|||
if (binding->type != sway_switch->type) {
|
||||
continue;
|
||||
}
|
||||
if (binding->state != WLR_SWITCH_STATE_TOGGLE &&
|
||||
binding->state != sway_switch->state) {
|
||||
if (!sway_switch_trigger_test(binding->trigger, sway_switch->state)) {
|
||||
continue;
|
||||
}
|
||||
if (config->reloading && (binding->state == WLR_SWITCH_STATE_TOGGLE
|
||||
if (config->reloading && (binding->trigger == SWAY_SWITCH_TRIGGER_TOGGLE
|
||||
|| (binding->flags & BINDING_RELOAD) == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue