xkbcommon / libxkbcommon

keymap handling library for toolkits and window systems
https://xkbcommon.org
Other
286 stars 125 forks source link

question: how to map from xcb key press/release event state field to xkb_mod_mask_t #437

Closed wez closed 8 months ago

wez commented 10 months ago

To deal with some timing issues in certain keyboard automation or high speed keyboard input scenarios when mixing an IME with xkb, my application is following the suggestion in https://github.com/ibus/ibus/issues/2600#issuecomment-1904396417 to compute and call update_mask with the state supplied in the incoming X event.

At the moment I am literally passing these u32 value straight from the X event and having those take precedence over the the parameters values last provided in an UpdateState X event.

This seems to be working well for the most part: automated key events (either via xdotool, or programmable mechanical keyboards) now appear to be handled correctly.

Is this actually valid? Are the key/button mask bits in the key press/release event state field actually directly compatible with the xkb_mod_mask_t in this context, or should I be taking additional steps to decode and map the values? Or just mask off some bits?

Some background/context:

wismill commented 9 months ago

@wez check the interactive-x11 tool for a complete example of using xcb with xkbcommon: it passes xcb_xkb_state_notify_event_t masks to xkb_state_update_mask.

bluetech commented 9 months ago

Is this actually valid? Are the key/button mask bits in the key press/release event state field actually directly compatible with the xkb_mod_mask_t in this context, or should I be taking additional steps to decode and map the values? Or just mask off some bits?

Yes, this is documented and if we break it, it will be considered a breaking change.