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 #314

Closed
wants to merge 1 commit into from

Conversation

bluetech
Copy link
Member

@bluetech bluetech commented Dec 17, 2022

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, 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
Signed-off-by: Ran Benita [email protected]

@bluetech
Copy link
Member Author

Design note: libX11 takes the XkbLatchLockState request and splits it to four functions - XkbLockGroup, XkbLockModifiers, XkbLatchGroup, XkbLatchModifiers. This is cleaner than the monster function, but I didn't do it here, because it makes it impossible to do an atomic update while getting the best enum xkb_state_component return mask.

…server state

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`[0], 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.

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

Fixes: #310
Signed-off-by: Ran Benita <[email protected]>
@bluetech bluetech force-pushed the update-latched-locked branch from b8706be to 9f2bba2 Compare December 17, 2022 18:18
@bluetech
Copy link
Member Author

The latched part will need some work, might drop it if I don't find the time to implement it.

@bam80
Copy link

bam80 commented Dec 17, 2022

So server applications ended up using xkb_state_update_state for this, but that's a function intended for client applications, not servers.

Could you elaborate on what are negative consequences of this, if it already works? Won't we just add a syntactic sugar expanding the API this way?

@wismill wismill added enhancement Indicates new feature requests state Indicates a need for improvements or additions to the xkb_state API labels May 14, 2023
@wismill wismill added this to the 1.7.0 milestone Sep 20, 2023
@wismill wismill modified the milestones: 1.7.0, 1.8.0 Feb 8, 2024
@wismill
Copy link
Member

wismill commented Jul 12, 2024

I added a fix for the latch group action in #483.

@wismill
Copy link
Member

wismill commented Oct 2, 2024

Closing in favor of #521

@wismill wismill closed this Oct 2, 2024
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
3 participants