Skip to content

obs-hotkey: Port the X11 key names and raw buttons - #3101

Merged
zackees merged 8 commits into
masterfrom
fix/rust-port-x11-key-names-and-raw-308
Oct 31, 2026
Merged

zackees merged 8 commits into
masterfrom
fix/rust-port-x11-key-names-and-raw-308

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #3098

What and why

Ports the X11 key names and the raw mouse button decode of the X11 hotkey platform (libobs/obs-nix-x11.c.h, Linux and FreeBSD) to a new module, nix_x11_hotkeys, of rust/obs-hotkey, next to the key map lookups (#2903) and the keysym table with the mouse answers (#3060). No upstream issue.

  • The name route of obs_key_to_str(): Mouse 1 to 29 and Numpad 0 to 9 by number (their translation when one is set), the 30 fixed keys with their default names (Insert … Escape, Meta as Super), F1 to F35 by number, every other key through its keycodes.
  • The raw button decode of the hotkey poll with XInput: whether a drained event is a raw button press or release, and the button's slot.

C keeps the translation reads, obs_get_hotkey_translation(), the keycode loop with XLookupString(), obs_key_to_name(), every dstr call, xcb_poll_for_event() with each free, the two memsets, the pressed and update stores, every log and the one-line mouse range test.

Commits:

  1. libobs: Move X11 key names and raw button decode: behaviour-neutral move into libobs/obs-nix-x11-hotkeys.c.h (hidden functions on plain values, no X header; the event type and the detail cross by pointer and are read only where the C read them; the event codes, field sizes and the detail's offset _Static_asserted against xcb). Checked with a harness: master's and the moved functions over logging stand-ins for the translations, obs_get_hotkey_translation(), XLookupString(), obs_key_to_name(), the dstr calls, the event queue, free() and blog(), gcc and clang at -O0, -O2 and ASan/UBSan, every key named 40 times plus 20,000 random polls on 3 seeds: identical logs in all 12 builds (about 318,000 lines a run); 18 planted mutants all caught. Button 0 and keys outside the table were left out of the harness: both index past the arrays in either version.
  2. test: Characterize X11 key names and raw buttons: test_nix_x11_hotkeys_steps (12 cases), builds the moved file on its own, every OS.
  3. RED obs-hotkey: Add Tier 1 tests for X11 key names: Tier 1 obs_hotkey::nix_x11_hotkeys against todo!().
  4. GREEN obs-hotkey: Port the X11 key names and raw buttons: the safe core (route(), one match in the C's order with the default names as static CStrs; raw_button(), which asks for the event type and the detail through closures only where the C read them; no state, no allocation, clippy's arithmetic, indexing, as-conversion and panic lints denied) and src/ffi/nix_x11_hotkeys.rs; the file moves to its own ported group, libobs.ported-nix-x11-hotkeys (Linux and FreeBSD), and the two shims are hidden (rust-hidden.txt, rust-exports.map's local:, rust-unexports-macos.txt). ci/test_ported_sources.py checks the group is ported on Linux only.
  5. Tier 3 obs-hotkey: Check the X11 key name port against C: oracle oracle/nix_x11_hotkeys.c and 3 parity tests (below), with the mutation check.
  6. obs-c-oracle: Let the bench unit list grow: build.rs writes run_units() with one call per bench file; at 99 units it sat at clippy's 100-line limit, so this port's bench tipped it over. The generated function now allows too_many_lines with its reason, so later benches don't hit it.
  7. Docs docs: Record the X11 key name port: the rust/README.md rows (and the X11 keysym and key map rows, which said C kept the key names and the event decode), naming.md, the crate description and lib.rs, and a port_comparison bench (Linux x86_64: Rust 6.0 µs, C 4.7 µs to route every key and decode 1024 events; no bmalloc).
  8. docs: Add the X11 raw button fixes to features: the docs/features.md line.

Intentional differences from C, fixed in the port (listed in the parity test, the module docs and rust/README.md):

  • The generic event test masks the response type with ~80, decimal (0x50), where the send-event bit is 0x80. So a raw button event that carries the send-event bit was ignored, and an event whose response type is 51, 99 or 115 was read as a generic one. The port clears 0x80.
  • A raw button with detail 0 passes the detail < XINPUT_MOUSE_LEN check and was stored at slot detail - 1, which wraps. The port treats it as an unsupported button (logged, nothing stored).
  • obs_key_to_str() with a value outside 0 .. OBS_KEY_LAST_VALUE - 1 indexed the keycode table with it. The port gives it no route, so the name is left as it is.
  • Shim only, where C would dereference: a null out-parameter is not written, and a null event type or detail reads as 0.

Characterized, not endorsed (kept): F1 to F35 never look up a translation, unlike every other named key.

Tier 3 (tests/hotkey/nix_x11_hotkeys_parity.rs): the values (OBS_KEY_LAST_VALUE, XINPUT_MOUSE_LEN, the three event codes); the route, number and default name (as strings) of every key from -2 to OBS_KEY_LAST_VALUE + 2 and the int extremes, and which outputs each side left alone; the decode of every response type, event types 0 to 31 and 0xffff, and buttons 0 to 255 plus two large ones, with null pointers on both sides wherever the C reads nothing more. The three differences are excluded, exactly those inputs, and each is checked on its own; the test counts what it compared.

Mutation check (done once, not committed): 19 mutants (14 in the core, 5 in the shim) all killed; the shim mutants only by Tier 3. The table is in the Tier 3 commit message.

Test cost: new tests (Tier 1 and Tier 3 together, 20): the whole module runs in 0.02 s in the debug build with OBS_PARITY_CASES=reduced, peak RSS 11 MB over 25 runs, no threads of their own.

docs/features.md gets a line (Scenes and UI) for the three fixes: a raw button event with the send-event mark now counts for a mouse-button hotkey and three unrelated event codes no longer do, button 0 is logged as unsupported, and a value that isn't a key gets no name.

Upstream authors of the moved and ported code (Lain, Shaolin, Palana, Georges Basile Stavracas Neto, Kasin Sparks, Kurt Kartaltepe) are credited on the move and port commits.

RED → GREEN

  • RED commit: 28b3a6e (obs-hotkey: Add Tier 1 tests for X11 key names): soldr cargo test -p obs-data --test obs-tests-core hotkey::nix_x11_hotkeys fails 16 of 17 with "not yet implemented" (event_codes checks only the constants); the local test-diff gate on it shows exactly those 16 failing (5409 passed, 6 skipped) and the lint lane passes.
  • GREEN: Tier 1 17/17 and Tier 3 3/3. Tier 2 on Linux under Xvfb: the 23 hotkey and X11 tests (test_x11_hotkey_layout, test_hotkey_translations, test_x11_volume_keys, test_x11_keymap, test_nix_x11_hotkeys_steps, test_nix_x11_input_steps, test_nix_x11_keys_steps among them) pass on the C, hybrid and C reference libobs, none skipped. Exported symbols identical on the three builds (1767 each), the two functions local in all three. Local gates: ./unittest's Rust lanes (5476 and 857 tests, 6 skipped), ./lint, --lane lint, --lane cross, soldr cargo clippy --workspace --target x86_64-pc-windows-msvc --all-targets, the port_comparison bench test and the quick ci/ checks pass. Runs were on 57f39be (on f2e76ff), including the libobs rebuilds, the export comparison and the Tier 2 hotkey and X11 tests above. After the rebase onto 3df7c10 (head 18c64fa): the quick ci/ checks, ./lint, the 417 hotkey:: Rust tests, the Windows clippy, the bench test, the export comparison (1767 each, identical) and the 23 hotkey and X11 Tier 2 tests on the hybrid and C reference libobs pass again. Tier 2 in Docker and the local-gate stamp could not run on this host (no access to the Docker socket), so the head is not stamped and PR CI runs the full suite.
  • Real app (UI, protocol output or logging changes): not applicable, a port.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (N/A for docs-only; a focused CI fix may push RED and GREEN together)
  • User-visible change: its line in docs/features.md is added or updated
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): not applicable
  • Intentional differences from C listed in the parity test header and rust/README.md (ports)

@rdoupe
rdoupe force-pushed the fix/rust-port-x11-key-names-and-raw-308 branch from c0020cd to 57f39be Compare October 30, 2026 21:46
rdoupe added a commit that referenced this pull request Oct 30, 2026
build.rs writes run_units() with one call per file in
benches/port_comparison. With master's units it is 100 lines, at
clippy's too_many_lines limit (RUST-018, #2846), so the next bench
unit, the portal shortcut status one in the following commit, fails
the lint lane: "this function has too many lines (101/100)".

The generated function is long by design, so it carries an allow
with the reason, as the X11 key names port does (PR #3101); the two
make the same change.

Refs #3081.
rdoupe and others added 8 commits October 30, 2026 19:23
Behaviour-neutral extraction before the Rust port. The key name route
and the raw button decode of the X11 hotkey platform move from
libobs/obs-nix-x11.c.h into libobs/obs-nix-x11-hotkeys.c.h, as hidden
functions on plain values declared without EXPORT in the new
libobs/obs-nix-x11-hotkeys.h:

- obs_nix_x11_hotkeys_route(): obs_nix_x11_key_to_str()'s tests, in
  its order: Mouse 1 to 29 and Numpad 0 to 9 with their number, the
  30 fixed keys with their default names (the table moves with it),
  F1 to F35 with their number, else the keycodes;
- obs_nix_x11_hotkeys_raw_button(): mouse_button_pressed()'s decode of
  one polled event: the generic event test on the response type, the
  XInput event type, the button bound, and the slot (detail - 1).

obs-nix-x11.c keeps the translation reads, obs_get_hotkey_translation(),
the dstr calls, the keycode loop with XLookupString(),
obs_key_to_name(), xcb_poll_for_event() with each free, the two
memsets, the pressed and update stores, every log and the mouse range
test in obs_nix_x11_hotkeys_platform_is_pressed(). The event type and
the detail cross by pointer and are read only where the C read them:
the type for a generic event, the detail for a raw press or release.
The slot stays a uint32_t, as detail - 1 was.

The new file includes no X header, so the C tests and the C oracle
compile it on their own: the three event codes are defined in the
header, and obs-nix-x11.c _Static_asserts them, the field sizes and
the detail's offset against xcb/xproto.h and xcb/xinput.h. It gets its
own unity group, libobs.nix-x11-hotkeys, in the Linux sources (Linux
and FreeBSD).

Checked with a harness: master's obs_nix_x11_key_to_str() and raw
event loop and the moved ones with obs-nix-x11-hotkeys.c, extracted
over logging stand-ins for the translations,
obs_get_hotkey_translation(), XLookupString(), obs_key_to_name(), the
dstr calls, the event queue, free() and blog(), built with gcc and
clang at -O0, -O2 and under ASan and UBSan. Each run names every key
40 times over random translations, keycode lists and starting
strings, then drains 20,000 polls of 0 to 8 random events (generic
and other response types, with and without the send-event bit, raw
presses, releases and other event types, buttons 1 to 40 and beyond),
logging the arrays after each: identical logs on 3 seeds in all 12
builds (about 318,000 lines a run). Button 0 and keys outside the
table are left out: both index past the arrays in either version.
18 planted mutants (13 in the moved file, 5 in the callers) all change
the log.

Refs #3098.

Co-authored-by: Lain <[email protected]>
Co-authored-by: Shaolin <[email protected]>
Co-authored-by: Palana <[email protected]>
Co-authored-by: Georges Basile Stavracas Neto <[email protected]>
Co-authored-by: Kasin Sparks <[email protected]>
Co-authored-by: Kurt Kartaltepe <[email protected]>
test_nix_x11_hotkeys_steps builds the moved
libobs/obs-nix-x11-hotkeys.c.h into itself and calls its two hidden
functions with values set by hand, so it needs no X server and runs on
every platform (12 cases):

- the route of each mouse button (numbered from 1), each numpad digit
  (from 0), each of the 30 fixed keys with its default name (Meta as
  "Super"), F1, F12, F24 and F35, and the keycodes for every other
  key, OBS_KEY_NONE too; the outputs a route doesn't set stay as they
  were;
- F1 to F35 never look up a translation (characterized, not endorsed);
- -1, OBS_KEY_LAST_VALUE and one past it routed to the keycodes,
  which obs_nix_x11_key_to_str() indexes with them (characterized, not
  endorsed);
- a raw press and release of buttons 1 to 32 at slots 0 to 31, 33 and
  up unsupported with the slot untouched, other XInput event types
  ignored without reading the detail;
- button 0 at slot UINT32_MAX (characterized, not endorsed);
- response types 35, 51, 99 and 115 taken as generic, and 35 with the
  send-event bit (0xa3) not, without reading the event type
  (characterized, not endorsed: the C masks with decimal 80);
- the event codes as X's.

Refs #3098.
RED for the port of libobs/obs-nix-x11-hotkeys.c.h to a new module,
nix_x11_hotkeys, of rust/obs-hotkey. The safe core is a stub
(todo!()): route(), how obs_key_to_str() names a key (Mouse(n),
Numpad(n), Fixed with its default name as a static CStr, Function(n),
Keycodes, or None for a value outside the key table); and
raw_button(), the decode of one drained event (Ignore, Press(slot),
Release(slot), Unsupported), which asks for the event type and the
detail through closures, so each is read only where the C read it.

tests/hotkey/nix_x11_hotkeys.rs ports test_nix_x11_hotkeys_steps 1:1,
its 12 cases under the same names, in the same order, with the same
inputs, and the same expectations except the three fixes the port
makes on purpose, each named in its test:

- a value outside the key table has no route (the C indexes the
  keycode table with it);
- button 0 is unsupported (the C stores it at slot 0 - 1, wrapped);
- the generic event test clears the send-event bit, 0x80, so a raw
  button event sent with it is decoded and 51, 99 and 115 are not
  generic (the C clears decimal 80, 0x50).

Kept as characterized, not endorsed: F1 to F35 never look up a
translation.

Edge cases: every key has a route, with 29 mouse buttons, 10 numpad
digits, 30 fixed keys and 35 function keys; the keys beside each range;
i32::MIN and i32::MAX; each closure called at most once and only when
the C read the field. Proptests check route() and raw_button() against
models written from the C with the three fixes.

The tests are a module of the existing core category binary,
obs-tests-core; no new test binary.

soldr cargo test -p obs-data --test obs-tests-core
hotkey::nix_x11_hotkeys fails 16 of 17 with "not yet implemented"
(event_codes checks only the constants).

Refs #3098.
GREEN for #3098. Ports libobs/obs-nix-x11-hotkeys.c.h, the key names
and raw button decode of the X11 hotkey platform, to the
nix_x11_hotkeys module of rust/obs-hotkey. The hybrid libobs drops the
C file and links the Rust shims in its place.

Safe core (src/nix_x11_hotkeys.rs):
- route(): one match in the C's order: Mouse 1 to 29 and Numpad 0 to 9
  by number, one arm per fixed key with its default name as a static
  CStr (byte-identical to the C's), F1 to F35 by number, else the
  keycodes; None for a value outside the key table;
- raw_button(): the generic event test on the response type, then the
  event type (asked for only for a generic event), then the button
  (asked for only for a raw press or release): buttons 1 to 32 at
  slots 0 to 31, any other button unsupported.
It keeps no state, takes no lock, allocates nothing and denies clippy's
arithmetic, indexing, as-conversion, unwrap, expect, panic and
unreachable lints.

Intentional differences from C, each in the module docs:
- the generic event test clears the send-event bit, 0x80; the C
  cleared decimal 80 (0x50), so it ignored a raw button event sent
  with the bit and took response types 51, 99 and 115 for generic
  events;
- button 0 is unsupported; the C stored it at slot 0 - 1, wrapped;
- a value outside 0 .. OBS_KEY_LAST_VALUE - 1 has no route, so
  obs_key_to_str() leaves the name as it is; the C indexed the keycode
  table with it.

Shim (src/ffi/nix_x11_hotkeys.rs): the two functions with the C
signatures, returning the C enums as int and writing each
out-parameter only where the C did. The event type and the detail are
read through their pointers only when the core asks. A null
out-parameter is not written, and a null event type or detail reads as
0, where C would dereference it.

C side: the file leaves libobs.nix-x11-hotkeys for its own ported
group, libobs.ported-nix-x11-hotkeys, registered in
libobs/build/ported-source-sets/nix-x11-hotkeys.json for Linux and
FreeBSD. obs_nix_x11_key_to_str() already handles the none route by
leaving the name alone. The functions are not EXPORT, so the shims are
hidden: rust-hidden.txt, the local: list of rust-exports.map and
rust-unexports-macos.txt. ci/test_ported_sources.py checks the group
is ported on Linux only.

test_nix_x11_hotkeys_steps still compiles the C file into itself,
unchanged. There is no _rust variant, as for test_nix_x11_input_steps:
the archive member does not link on its own, so the Tier 3 tests
compare the shims with the C. The real-libobs X11 tests see the swap
through the hybrid.

soldr cargo test -p obs-data --test obs-tests-core
hotkey::nix_x11_hotkeys passes 17/17.

Refs #3098.

Co-authored-by: Lain <[email protected]>
Co-authored-by: Shaolin <[email protected]>
Co-authored-by: Palana <[email protected]>
Co-authored-by: Kasin Sparks <[email protected]>
Co-authored-by: Kurt Kartaltepe <[email protected]>
Tier 3 for #3098. oracle/nix_x11_hotkeys.c builds the original
libobs/obs-nix-x11-hotkeys.c.h unmodified under oracle_* names, with a
getter for the values it uses; tests/hotkey/nix_x11_hotkeys_parity.rs
compares the shims with it:

- the values: OBS_KEY_LAST_VALUE, XINPUT_MOUSE_LEN and the three event
  codes;
- the route of every key, -2 .. OBS_KEY_LAST_VALUE + 2 and the int
  extremes: the result, the number and the default name as strings,
  and which outputs each side left alone;
- the decode of every response type, event types 0 to 31 and 0xffff,
  and buttons 0 to 255, 0x7fffffff and 0xffffffff: the result and the
  slot, or that it was left alone. Where the C reads nothing more,
  both sides get null pointers for the event type and the detail.

The three intentional differences are excluded, exactly those inputs,
and each is checked on its own: a value outside the key table (the C
routes it to the keycodes, the port to none), response types 51, 99,
115 and 0xa3 (one side takes each for a generic event; the port
decodes 0xa3 as the C decodes 35), and button 0 in a raw press or
release (the C gives slot UINT32_MAX, the port calls it unsupported).
The test counts what it compared, so a change in the excluded set
fails it.

Mutation check (done once, not committed): 19 mutants, all killed,
the shim mutants only by Tier 3. Failing tests per tier:

| Mutant | Tier 1 | Tier 3 |
|---|---|---|
| decode: clears 0x50 (the C's mask) | 2 | 1 |
| decode: button 33 has a slot | 1 | 1 |
| decode: slot is the button | 4 | 1 |
| decode: button 0 at slot 0 | 1 | 1 |
| decode: release as press | 2 | 1 |
| decode: press and release swapped | 3 | 1 |
| decode: other types as release | 3 | 1 |
| route: mouse from 0 | 2 | 1 |
| route: numpad up to 8 | 2 | 1 |
| route: Page Up name | 1 | 1 |
| route: Meta as Meta | 1 | 1 |
| route: no Numpad comma | 2 | 1 |
| route: F35 excluded | 2 | 1 |
| route: outside to keycodes | 3 | 1 |
| shim: fixed as function | 0 | 1 |
| shim: numpad number not stored | 0 | 1 |
| shim: slot off by one | 0 | 1 |
| shim: release as press | 0 | 1 |
| shim: slot written for unsupported | 0 | 1 |

Test cost: the whole module (Tier 1 and Tier 3, 20 tests) runs in
0.02 s in the debug build with OBS_PARITY_CASES=reduced, peak RSS
11 MB over 25 runs, no threads of its own.

Refs #3098.
build.rs writes run_units() with one call per file in
benches/port_comparison. With 99 units it was at clippy's 100-line
limit, so the next bench unit (the X11 key name port's, #3098) fails
the lint lane with too_many_lines on generated code. The function is
long by design and grows with every port, so the generated code
allows the lint with its reason, instead of each new bench having to
work around it.

Refs #3098.
Docs for #3098: the rust/README.md row for
libobs/obs-nix-x11-hotkeys.c.h (what moved, what C keeps, the three
intentional differences, what Tier 3 compares) and the obs-hotkey crate
row; the X11 keysym and key map rows now say the event decode and the
key name route moved out. naming.md's obs-hotkey row, the crate's
Cargo.toml description and its lib.rs module docs name the new file
and module.

A port_comparison bench (benches/port_comparison/nix_x11_hotkeys.rs)
routes every key and decodes 1024 events on both sides, over inputs
outside the intentional differences, with matching checksums; it
allocates nothing with bmalloc.

Refs #3098.
The X11 key name port (#3098) changes what a user can see in two
places: a raw button event sent with the send-event bit now counts for
a mouse-button hotkey (and three unrelated event codes no longer do),
and a button numbered 0 is now logged as unsupported. Record them,
with the key name lookup of a value that isn't a key, in the features
ledger.

Fixes #3098.
@rdoupe
rdoupe force-pushed the fix/rust-port-x11-key-names-and-raw-308 branch from 57f39be to 18c64fa Compare October 30, 2026 23:41
rdoupe added a commit that referenced this pull request Oct 31, 2026
build.rs writes run_units() with one call per file in
benches/port_comparison. With master's units it is 100 lines, at
clippy's too_many_lines limit (RUST-018, #2846), so the next bench
unit, the portal shortcut status one in the following commit, fails
the lint lane: "this function has too many lines (101/100)".

The generated function is long by design, so it carries an allow
with the reason, as the X11 key names port does (PR #3101); the two
make the same change.

Refs #3081.
@rdoupe
rdoupe marked this pull request as ready for review October 31, 2026 00:38
@rdoupe
rdoupe requested a review from zackees as a code owner October 31, 2026 00:38

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator review: approved. The shims follow the moved obs-nix-x11-hotkeys.c.h, and each of the three intended departures from C has its own test. RED (28b3a6e) then GREEN (ff0e77c) is in order, with a new Tier 2 cmocka test and Tier 3 parity against the oracle. No C tests or public headers were edited, and the new internal header is hidden in all three export lists. No platform cfg, and the tests are in the existing hotkey binary. The proptest is scaled through parity::cases(). The new shims add no references that break windows-keys-rust-stubs.c or the bench stand-ins. Test cost and ledger lines are present.

@zackees
zackees added this pull request to the merge queue Oct 31, 2026
Merged via the queue into master with commit 6b85331 Oct 31, 2026
41 checks passed
@zackees
zackees deleted the fix/rust-port-x11-key-names-and-raw-308 branch October 31, 2026 00:58
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Done in obs-rust Multiview Oct 31, 2026
rdoupe added a commit that referenced this pull request Nov 12, 2026
Give a value outside 0 .. OBS_KEY_LAST_VALUE - 1 no route, as the X11
route already does (#3101). The shim returns
OBS_NIX_WAYLAND_KEY_NAMES_ROUTE_NONE for it, and
obs_nix_wayland_key_to_str() returns on NONE, so it no longer indexes
its per-key keycode table with such a value.

This is an intentional difference from the C, listed in the module
docs, the parity test header and rust/README.md; the parity test pins
both sides outside the table (values_outside_the_table). Mutation
check: a bound of <= instead of < fails route_outside,
route_matches_x11 and values_outside_the_table.

Refs #4738.
Fixes #4738.

Local-Gate: v1 tree=81bce38c5158ab2b8002a49fc7bc38fe0b495f84 secs=2408 lanes=lint:run,dylint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a
Ci-Attestation: {"at":1794453024,"gate":"rust/all/fmt","host":"linux-x86_64","key":"1aabafd4ca04f51aa0ef8d8c3adc107450426272c4d5a909638e262c91060658","lane":"lint","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":60,"stamp":"9077bfa3c165da52d62c6c1d876696b1","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"1aabafd4ca04f51aa0ef8d8c3adc107450426272c4d5a909638e262c91060658","lane":"lint","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":60,"stamp":"c611e0fd939834b69183c1a0bd3e823d","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/x86_64-unknown-linux-gnu/dylint","host":"linux-x86_64","key":"e436235be75730d68a5589e4fdb22a46f8a676ec2e30c41e4489e42af3241b06","lane":"dylint","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":0,"stamp":"8867b8a9fa8d1e8bc070b8a729d00a97","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"0656af8200dd9b4a1ec8ef709c995e0227d20ce1f7e0617aba428a1b7e1ba21e","lane":"rust-test","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":137,"stamp":"56e10c49ab4558e9e3b6dde5f46a0f8c","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"f761e660b5254073216ad8e15c722d0cfe0e39f3c2db0dffb0b1091c573675f8","lane":"cross","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":105,"stamp":"fe18f69b6329e27e0fdf7104edd70a38","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"f761e660b5254073216ad8e15c722d0cfe0e39f3c2db0dffb0b1091c573675f8","lane":"cross","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":105,"stamp":"558735ad20f433c4da9db6b4b6feb320","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"f761e660b5254073216ad8e15c722d0cfe0e39f3c2db0dffb0b1091c573675f8","lane":"cross","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":105,"stamp":"1edc0a74953beae2c4c5bc220e313b30","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"f761e660b5254073216ad8e15c722d0cfe0e39f3c2db0dffb0b1091c573675f8","lane":"cross","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":105,"stamp":"10bfc1df94644d582f1b27511876be63","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"9c59230f2f5dc7b3b92d87d7c089fc16c7181b8e13cee76b8ca6681895bb3bad","lane":"tier2-linux","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":2408,"stamp":"f439d09c609b76b15e0e46b141937139","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
alerque pushed a commit to alerque/obs-studio that referenced this pull request Nov 13, 2026
* obs-hotkey: Add owned translation tests

Tier 1 tests for obs_hotkeys_set_audio_hotkeys_translations and
obs_hotkeys_set_sceneitem_hotkeys_translations over a model string
store, mirroring the C characterization: copies, replacement, NULL
and empty values, group isolation and the release, copy, write order
per slot. The core is todo!(), so they fail.

Refs obs-rust#4378.

* obs-hotkey: Port the owned hotkey translations

Swap obs_hotkeys_set_audio_hotkeys_translations and
obs_hotkeys_set_sceneitem_hotkeys_translations to Rust in hybrid
libobs. The safe core frees, copies and stores each slot in the C's
order; the shim reaches the eight fields through a new live adapter,
obs-hotkey-owned-translations-fields.c.h, and copies with bmalloc as
bstrdup does, so the C that frees them at shutdown is unchanged.

The C moves into its own ported group,
libobs.ported-hotkey-owned-translations+, exported through
rust-exports.d. Tier 3 compares the original bodies over a test-owned
core. No intentional differences.

Refs obs-rust#4378.

* test: Compare owned translation allocations

The owned translations parity test compared the eight strings after
each call, so a port that kept the old copy instead of freeing it
passed. Count the live bmem allocations after each call too, in a
child process of its own, as bnum_allocs counts process-wide.

Mutation check: dropping the release before the copy now fails
allocations_match_c; a wrong scene item slot, an empty string stored
as NULL and a skipped audio slot fail the string comparisons.

Refs obs-rust#4378.

* docs: List the owned hotkey translations port

Add libobs/obs-hotkey-owned-translations.c.h to the obs-hotkey rows
of rust/README.md and naming.md, the crate description and the lib.rs
module docs, and note the allocation comparison in its README row.

Refs obs-rust#4378.

* obs-hotkey: Test Wayland key names outside table

The Wayland key name route answers "name it through the keymap" for a
value outside 0 .. OBS_KEY_LAST_VALUE - 1, so obs_key_to_str() goes on
to look it up in the per-key keycode table. The X11 route gives such a
value no route. Add the route's None variant and its shim mapping to
OBS_NIX_WAYLAND_KEY_NAMES_ROUTE_NONE, and Tier 1 tests that expect it
outside the table (route_outside, and route_matches_x11 widened to the
values around it). The route still returns Keysym, so they fail.

Refs obs-rust#4738.

* obs-hotkey: Bound the Wayland key name route

Give a value outside 0 .. OBS_KEY_LAST_VALUE - 1 no route, as the X11
route already does (obs-rust#3101). The shim returns
OBS_NIX_WAYLAND_KEY_NAMES_ROUTE_NONE for it, and
obs_nix_wayland_key_to_str() returns on NONE, so it no longer indexes
its per-key keycode table with such a value.

This is an intentional difference from the C, listed in the module
docs, the parity test header and rust/README.md; the parity test pins
both sides outside the table (values_outside_the_table). Mutation
check: a bound of <= instead of < fails route_outside,
route_matches_x11 and values_outside_the_table.

Refs obs-rust#4738.
Fixes obs-rust#4738.

Local-Gate: v1 tree=81bce38c5158ab2b8002a49fc7bc38fe0b495f84 secs=2408 lanes=lint:run,dylint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a
Ci-Attestation: {"at":1794453024,"gate":"rust/all/fmt","host":"linux-x86_64","key":"1aabafd4ca04f51aa0ef8d8c3adc107450426272c4d5a909638e262c91060658","lane":"lint","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":60,"stamp":"9077bfa3c165da52d62c6c1d876696b1","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"1aabafd4ca04f51aa0ef8d8c3adc107450426272c4d5a909638e262c91060658","lane":"lint","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":60,"stamp":"c611e0fd939834b69183c1a0bd3e823d","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/x86_64-unknown-linux-gnu/dylint","host":"linux-x86_64","key":"e436235be75730d68a5589e4fdb22a46f8a676ec2e30c41e4489e42af3241b06","lane":"dylint","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":0,"stamp":"8867b8a9fa8d1e8bc070b8a729d00a97","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"0656af8200dd9b4a1ec8ef709c995e0227d20ce1f7e0617aba428a1b7e1ba21e","lane":"rust-test","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":137,"stamp":"56e10c49ab4558e9e3b6dde5f46a0f8c","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"f761e660b5254073216ad8e15c722d0cfe0e39f3c2db0dffb0b1091c573675f8","lane":"cross","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":105,"stamp":"fe18f69b6329e27e0fdf7104edd70a38","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"f761e660b5254073216ad8e15c722d0cfe0e39f3c2db0dffb0b1091c573675f8","lane":"cross","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":105,"stamp":"558735ad20f433c4da9db6b4b6feb320","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"f761e660b5254073216ad8e15c722d0cfe0e39f3c2db0dffb0b1091c573675f8","lane":"cross","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":105,"stamp":"1edc0a74953beae2c4c5bc220e313b30","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"f761e660b5254073216ad8e15c722d0cfe0e39f3c2db0dffb0b1091c573675f8","lane":"cross","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":105,"stamp":"10bfc1df94644d582f1b27511876be63","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}
Ci-Attestation: {"at":1794453024,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"9c59230f2f5dc7b3b92d87d7c089fc16c7181b8e13cee76b8ca6681895bb3bad","lane":"tier2-linux","parents":["1f2cb7de008aa8988e836b087eeef3fc2394ccd9"],"secs":2408,"stamp":"f439d09c609b76b15e0e46b141937139","tree":"81bce38c5158ab2b8002a49fc7bc38fe0b495f84","v":1,"via":"run"}

---------

Co-authored-by: Zach Vorhies <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

rust: Port the X11 key names and raw button events

2 participants