wayland: defective keyboard state tracking
xkbcommon has two apis to keep a master and slave xkb_state in sync:
on the master side:
xkb_state_serialize_mods
xkb_state_serialize_layout
on the slave side:
xkb_state_update_mask
The docs for this function state: All parameters must always be passed, or the resulting state may be incoherent.
xkb_state has 3 modifier and 3 group fields (depressed, latched and locked).
Wayland uses the modifiers event to transfer the serialized state, and it carries the 3 modifier fields, but only one group field, and the wayland backend calls:
xkb_state_update_mask (xkb_state, depressed_mods, latched_mods, locked_mods, group, 0, 0);
I'm afraid our state may be incoherent :(
Fixing this will require the Wayland protocol to carry all 3 group fields in the modifiers event.
Fwiw, mutter calls xkb_state_serialize_layout with the EFFECTIVE_GROUP argument to generate the one current group value to stuff in the modifiers event - that is the one group that does not show up in the argument list of update_mask :(