Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state: add API for updating latched and locked mods & layout in server state #521

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wismill
Copy link
Member

@wismill wismill commented Oct 2, 2024

(Revival of #314)

Up to now, the “server state” xkb_state`` API only offered one entry point to update the server state - xkb_state_update_key`, which reflects the direct keyboard keys state. But some updates come out-of-band from keyboard input events stream, for example, a GUI layout switcher.

The X11 XKB protocol has a request which allows for such updates, XkbLatchLockState1, but xkbcommon does not have similar functionality. So server applications ended up using xkb_state_update_state for this, but that’s a function intended for client applications, not servers.

Add support for updating the latched & locked state of the mods and layout. Note that the depressed states cannot be updated in this way -- XKB does not expect them to be updated out of band.

Fixes: #310

Footnotes

  1. https://www.x.org/releases/X11R7.7/doc/kbproto/xkbproto.html#Querying_and_Changing_Keyboard_State

@wismill wismill added enhancement Indicates new feature requests state Indicates a need for improvements or additions to the xkb_state API labels Oct 2, 2024
@wismill wismill force-pushed the state/update-latched-locked branch from d7b0c3d to b1855fa Compare October 2, 2024 05:24
@wismill wismill added this to the 1.8.0 milestone Oct 2, 2024
@wismill wismill mentioned this pull request Nov 29, 2024
3 tasks
wismill and others added 2 commits December 3, 2024 10:09
Up to now, the “server state” `xkb_state` API only offered one entry
point to update the server state – `xkb_state_update_key`, which reflects
the direct keyboard keys state. But some updates come out-of-band from
keyboard input events stream, for example, a GUI layout switcher.

The X11 XKB protocol has a request which allows for such updates,
`XkbLatchLockState`[^1], but xkbcommon does not have similar
functionality. So server applications ended up using
`xkb_state_update_state` for this, but that’s a function intended for
client applications, not servers.

Add support for updating the latched & locked state of the mods and
layout. Note that the depressed states cannot be updated in this way --
XKB does not expect them to be updated out of band.

[^1]: https://www.x.org/releases/X11R7.7/doc/kbproto/xkbproto.html#Querying_and_Changing_Keyboard_State

Fixes: xkbcommon#310
Signed-off-by: Ran Benita <[email protected]>
Co-authored-by: Ran Benita <[email protected]>
Co-authored-by: Pierre Le Marre <[email protected]>
@wismill wismill force-pushed the state/update-latched-locked branch from b1855fa to 01b64bb Compare December 3, 2024 09:18
@wismill
Copy link
Member Author

wismill commented Dec 3, 2024

Rebased and fixed latch-to-lock clearance side-effects.

@wismill
Copy link
Member Author

wismill commented Dec 7, 2024

Refactored tests, added lots of new tests and fix numerous edges cases. This is much more tricky than expected, so the tests are crucial. We should probably also try some random config à la QuickCheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests state Indicates a need for improvements or additions to the xkb_state API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

suggestion: allow xkb_state_update_mask() to accept negative groups to unlock group wrapping functionality
1 participant