x11_xkb
XKEYBOARD protocol link for the X11 XTEST keyboard.
The vendored python-xlib speaks no XKB, and the core keymap it exposes folds every layout group into one column list: columns 0-1 are group 1, 2-3 group 2, and from column 4 on the extra levels of groups 1 and 2 and whole further groups interleave by per-key type widths the core protocol never reports, so a keysym's (group, level) cannot be told from the core map alone. A handful of raw XKEYBOARD requests on the injection connection give the XTEST keyboard what it needs: XkbGetMap names the group and level every keysym sits at, XkbGetState and XkbLatchLockState read and lock the group an injection must run under, and XkbSelectEvents keeps keymap changes flowing — the server withholds core MappingNotify from an XKB-aware client, and reports a whole-keyboard replacement (setxkbmap) to it only as XkbNewKeyboardNotify.
Everything is best effort: a server without the extension simply leaves the link unopened and the keyboard falls back to the core keymap.
attributelogger= logging.getLogger('x11_xkb')attributeXKB_USE_CORE_KBD= 256attributeXKB_KEY_SYMS_MASK= 1 << 1attributeXKB_ALL_MAP_PARTS= 255attributeXKB_NEW_KEYBOARD_NOTIFY_MASK= 1 << 0attributeXKB_MAP_NOTIFY_MASK= 1 << 1attributeXKB_NEW_KEYBOARD_NOTIFY= 0attributeXKB_INJECTABLE_LEVELS= 4