Skip to content

rust: Port the X11 keysym table and mouse button answers #3054

Closed

Description

@rdoupe

Unit

Port the X11 keysym table and the mouse button answers of libobs/obs-nix-x11.c.h to rust/obs-hotkey, as a new module nix_x11_input, next to nix_x11_keys (#2901) and nix_hotkey_state. On X11 (Linux and FreeBSD), libobs uses them to fill the base keysym table at hotkey init (which nix_x11_keys then searches) and to answer the hotkey thread's "is this mouse button down" poll. These decisions move:

  • get_keysym(): the X keysym of each obs key (XK_*, XF86XK_*, SunXK_*, and n << 16 for Mouse 1 to 5); 0 for a key it doesn't name. fill_base_keysyms() keeps its loop and asks for each key.
  • The XInput answer of mouse_button_pressed(): each obs mouse key's slot in the three per-button arrays (Mouse 1 is slot 0, Mouse 2 slot 2, Mouse 3 slot 1, Mouse 4 to 29 slots 7 to 32), pressed in this drain or held from before.
  • The commit loop after it: each updated slot's held state takes this drain's pressed state.
  • The answer without XInput: the pointer mask's button bit for Mouse 1 to 3.

These stay in C: the raw event drain (xcb_poll_for_event, the event reads and their stores, each free), the two memsets, xcb_query_pointer with its reply, error and frees, every blog, key_pressed(), fill_keycodes(), the key names and the vtable.

Phase and position

Phase 6, Linux host code; the X11 hotkey logic left in C after the key map lookups (#2901). Tracking: #4.

Dependencies and existing tests

  • No dependency to land first; nothing open in the nix+ unity group.
  • Real libobs: test_x11_hotkey_layout, test_x11_volume_keys, test_x11_keymap (the base keysym table through obs_key_to_virtual_key and the key map), test_hotkey_volume_keys.
  • No characterization of the moved functions on their own: test_nix_x11_input_steps lands first in the same PR, builds the moved C file on its own (no X header) and runs on every OS.

Notes

One PR, separate commits: the behaviour-neutral move into libobs/obs-nix-x11-input.c.h (hidden functions on plain values, no xcb or Xlib header; the keysyms as their values, checked against the X headers by the move check), characterization, RED, GREEN (group libobs.ported-nix-x11-input in the Linux ported sources), Tier 3 (exhaustive over every key for the keysym and the answer, every pressed, update and held state of the arrays, every 16-bit pointer mask), docs.

Parity note, pinned and kept: Mouse 29 reads slot 32, which no raw event fills, so it never reads as pressed with XInput.

Activity

  1. added
    enhancement
    port
    on Oct 30, 2026
  2. rdoupe commented on Oct 30, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #3054

    Plan, one PR with separate commits:

    1. libobs: Move the keysym table, the XInput mouse answer, its commit loop and the pointer-mask answer into libobs/obs-nix-x11-input.c.h, hidden functions on plain values with no X header, behaviour-neutral (checked by building master's and the moved functions side by side on the same inputs, every key and array state).
    2. Characterization: test_nix_x11_input_steps, building the moved file on its own, on every OS.
    3. RED: Tier 1 obs_hotkey::nix_x11_input against todo!() stubs.
    4. GREEN: the safe core and src/ffi/nix_x11_input.rs, group libobs.ported-nix-x11-input.
    5. Tier 3 parity against the C, with the mutation check.
    6. Docs: rust/README.md, naming.md, the crate description and lib.rs.

    Draft PR once the RED commit exists, today.

  3. added
    ready
    on Oct 30, 2026
  4. rdoupe commented on Oct 30, 2026

    @rdoupe
    CollaboratorAuthor

    Fixed by #3060 (merged through the merge queue as 3edcda4). The X11 keysym table (get_keysym), the XInput mouse slot map with its answer and commit, and the QueryPointer mask answer now live in rust/obs-hotkey as nix_x11_input; libobs calls them through hidden functions in libobs/obs-nix-x11-input.c.h. Tier 1 (21 cases), the unchanged C tests under Xvfb, and Tier 3 parity against the C (7 cases, 18 mutants all killed) pass. No intentional difference in behaviour; two keysym collisions and Mouse 29 reading slot 32 are characterized and kept.

    Left, by design: the raw event drain, the memsets, the QueryPointer request with its reply and frees, every log, key_pressed(), fill_keycodes(), the key names and the vtable stay in C. There is no follow-up issue for them. The unit has no checkbox on the tracking issue (#4), so none was ticked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementportready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions