Repository navigation
Description
Unit
Port the X11 key map lookups of libobs/obs-nix-x11.c.h to rust/obs-hotkey, as a new module nix_x11_keys, next to nix_hotkey_state (#1516) and the portal shortcut modules (#1800). On X11 (Linux and FreeBSD), libobs uses them to build the keycode lists at hotkey init, to answer the hotkey thread's "is this key down" poll, and in obs_key_from_virtual_key / obs_key_to_virtual_key. These decisions move:
key_from_base_keysym(): the first key whose base keysym is the symbol; else Shift_R, Control_R and Alt_R give Shift, Control and Alt; else none.- The per-row rule of
fill_keycodes(): the first non-zero symbol of a keycode's row that is Super_L, Super_R or maps to a key, stopping at the first zero. key_pressed()'s decision: Meta checks the two super keycodes, any other key each of its keycodes.key_from_keycode(): the first key whose keycode list holds the code.obs_nix_x11_key_from_virtual_key(): the 0 and empty-map gate, then the column-major search (each group and level across all keycodes, so the unshifted first-group key wins), thenkey_from_keycode().obs_nix_x11_key_to_virtual_key(): Meta givesXK_Super_L, any other key its base keysym.
These stay in C: the keysym table (get_keysym), fill_base_keysyms, add_key (its list push and log), every xcb_*/X* call, the keymap copy, the mouse path, obs_nix_x11_key_to_str and the log info.
Phase and position
Phase 6, Linux host code; the last X11 hotkey logic in C after the Wayland key state (#1516). Tracking: #4.
Dependencies and existing tests
- No dependency to land first.
- Real libobs:
test_x11_hotkey_layout(the AltGr column order),test_x11_volume_keys,test_x11_keymap. - No characterization of the moved functions on their own:
test_nix_x11_keys_stepslands first in the same PR, builds the moved C file on its own and runs on every OS.
Notes
One PR, separate commits: the behaviour-neutral move into libobs/obs-nix-x11-keys.c.h (hidden functions on plain values, no xcb or Xlib header), characterization, RED, GREEN (group libobs.ported-nix-x11-keys in the Linux ported sources), Tier 3 (proptests over random key maps, 1 to 7 symbols per keycode, keycodes 8 to 255, and every int key), docs.
Intentional difference: obs_key_to_virtual_key on X11 returns 0 for a key outside 0 .. OBS_KEY_LAST_VALUE - 1, which has no keysym; C indexes the table with it.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 29, 2026
Claiming: #2901
Plan, one PR with separate commits:
libobs: Movethe six lookups intolibobs/obs-nix-x11-keys.c.h, hidden functions on plain values, behaviour-neutral (checked by building master's and the moved functions side by side on the same inputs).test_nix_x11_keys_steps, building the moved file on its own, on every OS.obs_hotkey::nix_x11_keysagainsttodo!()stubs.src/ffi/nix_x11_keys.rs, grouplibobs.ported-nix-x11-keys, with theobs_key_to_virtual_keyrange check.I expect the draft PR today, within a few hours.
libobs: Move the X11 key map lookups
test: Characterize the X11 key map lookups
obs-hotkey: Add Tier 1 tests for the X11 key port
obs-hotkey: Port the X11 key map lookups
obs-hotkey: Check the X11 key port against the C
docs: Record the X11 key map port
rdoupe commentedon Oct 29, 2026
Fixed by #2903 (merged through the merge queue as aad5a22). The six X11 key map lookups now live in
rust/obs-hotkeyasnix_x11_keys; libobs calls them through hidden functions inlibobs/obs-nix-x11-keys.c.h. Tier 1 (21 cases), the unchanged C tests, and Tier 3 parity against the C (6 cases, 18 mutants all killed) pass. The one intentional difference is listed indocs/features.md:obs_key_to_virtual_keyon X11 returns 0 for a key OBS does not have.Left, by design: the keysym table (
get_keysym), the base keysym fill,add_key, every xcb/Xlib call, the keymap copy, the mouse path and the key names stay in C. There is no follow-up issue for them. The macOS counterpart of this key map work is #2914.obs-hotkey: Port the X11 key map lookups (obs-rust#2903)