Skip to content

Commit

Permalink
Make setting or releasing a lock break an active latch
Browse files Browse the repository at this point in the history
For example, if `Caps_Lock` is on the second level of some key,
and `Shift` is latched, pressing the key will lock `Caps`
while also breaking the `Shift` latch, ensuring that the next character
is properly uppercase. (Prior to this commit, both `Shift` and
`Caps` would be active, so the next character would be lowercase.)

Signed-off-by: Jules Bertholet <[email protected]>
  • Loading branch information
Jules-Bertholet committed Dec 21, 2024
1 parent 09ae46d commit 1600066
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changes/api/+locks-break-latches.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Changed modifier and group latches so that setting or releasing a lock now breaks them.
This enables implementing a key that, for example, latches `Shift`
when pressed once, but locks `Caps` when pressed twice in succession.
10 changes: 7 additions & 3 deletions src/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,20 @@ xkb_filter_group_lock_func(struct xkb_state *state,
}

static bool
xkb_action_breaks_latch(const union xkb_action *action)
xkb_action_breaks_latch(const union xkb_action *action, bool is_group_latch)
{
switch (action->type) {
case ACTION_TYPE_NONE:
case ACTION_TYPE_MOD_LOCK:
case ACTION_TYPE_GROUP_LOCK:
case ACTION_TYPE_PTR_MOVE:
case ACTION_TYPE_PTR_BUTTON:
case ACTION_TYPE_PTR_LOCK:
case ACTION_TYPE_PTR_DEFAULT:
case ACTION_TYPE_TERMINATE:
case ACTION_TYPE_SWITCH_VT:
case ACTION_TYPE_CTRL_SET:
case ACTION_TYPE_CTRL_LOCK:
case ACTION_TYPE_SWITCH_VT:
case ACTION_TYPE_TERMINATE:
return true;
default:
return false;
Expand Down

0 comments on commit 1600066

Please sign in to comment.