Skip to content

Commit

Permalink
Break group latches also upon latchToLock/clearLock
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-Bertholet committed Jan 6, 2025
1 parent eac392e commit f6923f9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ xkb_filter_group_set_func(struct xkb_state *state,

if (filter->action.group.flags & ACTION_LOCK_CLEAR && state->components.locked_group) {
state->components.locked_group = 0;
// break all mod latches
// break all latches
state->components.latched_mods = 0;
state->components.latched_group = 0;
}

filter->func = NULL;
Expand Down Expand Up @@ -408,7 +409,7 @@ xkb_filter_group_latch_func(struct xkb_state *state,
filter->action.type = ACTION_TYPE_GROUP_LOCK;
filter->func = xkb_filter_group_lock_func;
xkb_filter_group_lock_new(state, filter);
// break all mod latches
// break mod latches
state->components.latched_mods = 0;
}
else {
Expand Down Expand Up @@ -446,7 +447,7 @@ xkb_filter_group_latch_func(struct xkb_state *state,
}
else if (direction == XKB_KEY_UP && key == filter->key) {
/* Our key got released. If we've set it to clear locks, and we
* currently have a group locked, then release it, break all mod latches,
* currently have a group locked, then release it, break all latches,
* and don't actually latch. Else we've actually hit the latching
* stage, so set PENDING and move our group from base to
* latched. */
Expand All @@ -457,10 +458,11 @@ xkb_filter_group_latch_func(struct xkb_state *state,
state->components.latched_group -= priv.group_delta;
else
state->components.base_group -= priv.group_delta;
if (filter->action.group.flags & ACTION_LOCK_CLEAR) {
if (filter->action.group.flags & ACTION_LOCK_CLEAR && state->components.locked_group) {
state->components.locked_group = 0;
// break all mod latches
// break all latches
state->components.latched_mods = 0;
state->components.latched_group = 0;
}
filter->func = NULL;
}
Expand Down Expand Up @@ -507,8 +509,9 @@ xkb_filter_mod_set_func(struct xkb_state *state,
state->clear_mods = filter->action.mods.mods.mask;
if (filter->action.mods.flags & ACTION_LOCK_CLEAR && state->components.locked_mods & filter->action.mods.mods.mask) {
state->components.locked_mods &= ~filter->action.mods.mods.mask;
// break all mod latches
// break all latches
state->components.latched_mods = 0;
state->components.latched_group = 0;
}

filter->func = NULL;
Expand Down Expand Up @@ -581,8 +584,9 @@ xkb_filter_mod_latch_func(struct xkb_state *state,
filter->action.type = ACTION_TYPE_MOD_LOCK;
filter->func = xkb_filter_mod_lock_func;
state->components.locked_mods |= filter->action.mods.mods.mask;
// break all mod latches
// break all latches
state->components.latched_mods = 0;
state->components.latched_group = 0;
}
else {
filter->action.type = ACTION_TYPE_MOD_SET;
Expand Down Expand Up @@ -656,7 +660,7 @@ xkb_filter_mod_latch_func(struct xkb_state *state,
else if (direction == XKB_KEY_UP && key == filter->key) {
/* Our key got released. If we've set it to clear locks, and we
* currently have the same modifiers locked, then release them,
* break all mod latches, and don't actually latch.
* break all latches, and don't actually latch.
* Else we've actually hit the latching stage,
* so set PENDING and move our modifier from base to
* latched. */
Expand All @@ -674,8 +678,9 @@ xkb_filter_mod_latch_func(struct xkb_state *state,
if (filter->action.mods.flags & ACTION_LOCK_CLEAR &&
state->components.locked_mods & filter->action.mods.mods.mask) {
state->components.locked_mods &= ~filter->action.mods.mods.mask;
// break all mod latches
// break all latches
state->components.latched_mods = 0;
state->components.latched_group = 0;
}
filter->func = NULL;
}
Expand Down

0 comments on commit f6923f9

Please sign in to comment.