Repository navigation
Conversation
Characterization before the hotkey binding press count (press_released_binding and release_pressed_binding in obs-hotkey.c, and their wrappers obs_hotkey_binding_press and _release) moves to its own file and is ported to obs-hotkey. Each binding press or release sets the binding's pressed flag and counts presses per hotkey, and the hotkey's callback, or the router when rerouting, runs only on the first press and the last release. test_hotkey_press_state already reaches it through the poll and inject paths: two bindings pressed and released one after the other, a duplicated binding, rebinding and unregistering while pressed, and rerouting with and without a router. Six new cases pin the rest: - two bindings of one hotkey pressed and released in the same poll (one callback each way); - one injected event that presses both bindings of a hotkey, and the poll that releases both (one callback each way); - unregistering a hotkey held through two bindings (one release); - unregistering a pressed hotkey with rerouting on (the release goes to the router); - rerouting switched on or off while a hotkey is pressed (the callback or the router is chosen at each call, not at the press); - the router removed while a hotkey is pressed: its release calls nothing but still counts, so the next press reaches the router again. Characterized, not endorsed: - With rerouting on, a release while no router is set is lost: the router got the press and never gets its release. Refs obs-rust#1836
…ress.c Behavior-neutral extraction before the Rust port: the hotkey binding press count, press_released_binding() and release_pressed_binding() with their wrappers obs_hotkey_binding_press() and obs_hotkey_binding_release(), moves verbatim from libobs/obs-hotkey.c.h into libobs/obs-hotkey-binding-press.c.h. The two static functions stay static in the new file; the wrappers were already declared in obs-internal.h without EXPORT, so -fvisibility=hidden keeps them local. The only other change: remove_bindings() in obs-hotkey.c.h now calls obs_hotkey_binding_release() instead of the static release, and its forward declaration goes, because the tests that compile obs-hotkey.c.h build each file as its own translation unit. The new file joins libobs.core just before obs-hotkey.c.h, with libobs.pch.h. No group, PCH or source-sets.json change, no platform conditional moves, and the exported symbols are unchanged (1766). The tests that compile obs-hotkey.c.h on their own (test_hotkey_load, test_wayland_hotkeys, test_portal_shortcuts, test_hotkey_press_steps, test_hotkey_pair_steps, and the obs-build manifest entry for test_hotkey_load) now compile the new file next to it. The comments in obs-internal.h and obs-hotkey-press.c.h that placed the press and release in obs-hotkey.c now name the new file. New test test_hotkey_binding_press_steps compiles the C into itself like test_hotkey_pair_steps, binds a hotkey through the API, and calls the press and the release with the binding's flag and the hotkey's count set by hand. It pins what the real libobs cannot show: the flag, the count and the call after every event in all 24 cases (flag x count -2..3 x press or release), each with rerouting off, on with a router and on without one, and the arguments of each call; that the flag and the count are written before the call and nothing after it; two bindings of one hotkey; and remove_bindings() releasing only the pressed bindings it removes. Characterized, not endorsed (unreachable in libobs, which presses only a released binding and releases only a pressed one): - neither function checks the flag, so a press of a pressed binding counts again; - a release at count 0 makes the count negative. test_hotkey_press_state passes unchanged (24/24). Refs obs-rust#1836
Before the binding press count reaches its binding and hotkey through an accessor, one case in test_hotkey_binding_press_steps pins it: obs_hotkey_binding_count_fields() points at the binding's own pressed flag and its hotkey's own pressed count, and gives the binding's hotkey; a count set through it is the one the press and the release read, and their writes show through it; and obs_hotkey_dispatch() calls the hotkey's func with rerouting off, the router with rerouting on, and nothing with rerouting on and no router, with the right arguments for a press and a release, leaving the flag and the count alone. It does not build yet: neither function exists. Refs obs-rust#1836
…cessor The hotkey binding press count, libobs/obs-hotkey-binding-press.c.h, writes a binding's pressed flag and its hotkey's pressed count, both in private structs, and calls the hotkey's func or the router. The Rust port should mirror neither struct, and the callback ABI and the router (the frontend's) should stay C, so the press count now reaches the binding and the hotkey only through two hidden functions in obs-hotkey.c.h: - obs_hotkey_binding_count_fields(binding): pointers to the binding's pressed flag and its hotkey's pressed count, and the hotkey; - obs_hotkey_dispatch(hotkey, pressed): with rerouting off, calls the hotkey's func(data, id, hotkey, pressed); with rerouting on, calls the router (router_func_data, id, pressed), or nothing when no router is set. A new accessor, not a wider obs_hotkey_binding_fields(): that one gives the press state machine a const flag pointer and no hotkey, and its Rust port takes the struct by value. The press and the release fetch the fields once, write the flag and the count through them, and then call obs_hotkey_dispatch() last, as before: the same writes in the same order, nothing touched after the call, under the same lock. Both functions are declared in obs-internal.h without EXPORT, so the exported symbols are unchanged. test_hotkey_binding_press_steps passes 6/6 (count_fields_and_dispatch included) and test_hotkey_press_state 24/24. Refs obs-rust#1836
|
Coordinator check-in: this draft hasn't moved in 72 h and now conflicts with master. @rdoupe, are you still on #1836? If so, a rebase onto master is the next step. If you've moved on, say so here and I'll release the claim on #1836 so someone else can pick it up. With no reply in about 48 h, I'll release it anyway; the extraction here stays in the PR to build on. |
|
Still mine. It's parked on a maintainer decision about a related change outside this PR. I'll rebase it onto master and pick it up as soon as that's settled, so please leave the claim in place. |
|
Coordinator check on this draft. Two things are now stale, both from master moving since 2026-10-22: 1. It conflicts. The manifest half is not a stale-pointer fix: master deleted 2. The only red is old. No CI has run on this head since, and master has taken ~200 commits in the meantime, so that result says nothing about today. When you rebase onto current master I'll watch the fresh run. If it is still |
|
Status from a worker read of this branch against master The rebase is small; only the registration shape changes. What I found resolving it locally (on a scratch copy, not pushed to your branch):
|
|
Coordinator: closing this draft as superseded, with thanks to rdoupe. What it set out to do is on master. #3032 extracted the hotkey binding press count into |
Refs #1836 (PR 1 of the plan: the characterization, the extraction and the seam. The port follows.)
What and why
This is a behaviour-neutral extraction before the Rust port, as the testing policy asks for part of a large file. The hotkey binding press count moves from
libobs/obs-hotkey.c.hintolibobs/obs-hotkey-binding-press.c.h. It is what one binding press or release does to its hotkey: set the binding'spressedflag, count the presses per hotkey, and call the hotkey only on the first press and the last release, so a hotkey held through two bindings fires once. The call goes to the hotkey's func, or, with callback rerouting on, to the router (and to nothing when no router is set). The move comes with six new cases intest_hotkey_press_stateand a new steps test. There is no Rust, no behaviour change and no public header change.What moves:
press_released_binding(),release_pressed_binding()and their wrappersobs_hotkey_binding_press()andobs_hotkey_binding_release(), verbatim. The two static functions stay static in the new file; the wrappers were already hidden (declared inobs-internal.hwithoutEXPORT), and the ported press state machine calls them.The one other change:
remove_bindings()inobs-hotkey.c.hcalled the static release, so it now callsobs_hotkey_binding_release(), and the forward declaration goes. The tests that compileobs-hotkey.c.hbuild each.c.has its own translation unit.What stays:
remove_bindings(),inject_hotkey(),query_hotkeys()and the binding walk, the hotkey hash, the rerouting and router setters, and the callbacks.The seam, in its own RED and GREEN commits: the moved file now reaches the binding and the hotkey only through two new functions in
obs-hotkey.c.h:obs_hotkey_binding_count_fields(binding): pointers to the binding'spressedflag and its hotkey'spressedcount, and the hotkey, so the port mirrors neitherstruct obs_hotkey_bindingnorstruct obs_hotkey;obs_hotkey_dispatch(hotkey, pressed): the rerouting choice and the call (func(data, id, hotkey, pressed), orrouter_func(router_func_data, id, pressed), or nothing), so the callback ABI and the router (the frontend's) stay C, asobs_hotkey_pair_call_func()does for the pair latch (libobs: Move the hotkey pair press latch into obs-hotkey-pair.c #1799).The press and the release fetch the fields once, write the flag and the count through them, and call
obs_hotkey_dispatch()last: the same writes in the same order as before, nothing read or written after the call, under the same lock.A new accessor, not a wider
obs_hotkey_binding_fields()(libobs: Reach hotkey bindings through a hidden accessor #1779): that one gives the press state machine aconst bool *pressedand no hotkey, and its Rust port takes the struct by value, so adding fields would change an ABI the hybrid already uses.Hidden: both new functions are declared in
obs-internal.hwithoutEXPORT, so-fvisibility=hiddenkeeps them local (t) symbols. The exported symbols are unchanged.Build: the new file joins the existing
libobs.coregroup just beforeobs-hotkey.c.h, withlibobs.pch.h. The group, the PCH,source-sets.jsonand the CMake source lists of libobs are unchanged. The moved code has no platform conditional.Tests that compile
obs-hotkey.c.hthemselves:test_hotkey_load,test_wayland_hotkeys,test_portal_shortcuts,test_hotkey_press_stepsandtest_hotkey_pair_stepsnow compileobs-hotkey-binding-press.c.hnext to it (CMake, and the obs-build C test manifest fortest_hotkey_load). Their test files are unchanged.Comments:
obs-internal.hand the header comment ofobs-hotkey-press.c.hplaced the press and release inobs-hotkey.c; they now name the new file.test_hotkey_press_state(#1752, real libobs on X11, public API only) already reached the unit through the poll and inject paths. Six new cases, their own commit on the unchanged C, pin the rest:test_hotkey_binding_press_steps(new, with the move) compiles the C into itself liketest_hotkey_pair_steps, binds a hotkey through the API, and calls the press and the release with the flag and the count set by hand. Its 6 cases pin what the real libobs cannot show:count_fields_and_dispatch, the RED case) that the accessor points at the binding's own flag and its hotkey's own count and gives that hotkey, and that the dispatch calls the func, the router or nothing, with the right arguments, leaving the flag and the count alone.Characterized, not endorsed (a comment in the tests, and in the issue). None is changed here, and the issue proposes no fix before the port:
RED → GREEN
26cc6dba5test: Pin the hotkey binding fields the binding press count usesadds one case,count_fields_and_dispatch, totest_hotkey_binding_press_steps. It fails to build there, in both build trees, becauseobs_hotkey_binding_count_fields(), its struct andobs_hotkey_dispatch()do not exist yet (test_hotkey_binding_press_stepsis the only target that fails). Before it, the sixtest_hotkey_press_statecases are their own commit,bf23c3db1test: Characterize the hotkey binding press count, and pass 24/24 on the unchanged C against all three libraries. The move is501228655libobs: Move the hotkey binding press count into obs-hotkey-binding-press.c.2c23e5251libobs: Reach hotkey bindings for the press count through a hidden accessor.test_hotkey_binding_press_stepspasses 6/6 andtest_hotkey_press_state24/24, against libobs with the C backend, the hybrid libobs and libobs-c-reference.origin/master) and the moved, seamed ones side by side and compared the call log (func or router, its arguments, and the flag and the count the call sees), the flags and the count after every step: 560,256 cases, 414,104 calls, no difference. The cases: every single event over flag × count −3..4 × press or release × the three routing states × four callbacks (none; one that changes the flag and the count; one that toggles rerouting; one that removes the router), and every sequence of six events over three bindings of one hotkey in every routing state with each callback.obs-hotkey-binding-press.c.h, the accessor, the dispatch orremove_bindings()was built into libobs (C backend) and both tests;test_hotkey_binding_press_stepscatches all 23, andtest_hotkey_press_state18:modifiers_match;remove_bindings()not releasing a pressed binding.OBS_LIBOBS_BACKEND=C, andHYBRIDwithOBS_BUILD_C_REFERENCE=ON, both full builds. Fullctest -j4, headless (private Xvfb, private D-Bus, fresh HOME):OBS_LIBOBS_BACKEND=CHYBRID,OBS_BUILD_C_REFERENCE=ONHYBRID,OBS_BUILD_C_REFERENCE=ONNothing was skipped or failed to run. In the C-backend run, one test outside the hotkey code failed once under
-j4load (test_pipewire_screencast_shm, casepacked_rows) and passed when run again; it passes in the other two runs.test_hotkey_press_state(24/24),test_hotkey_binding_press_steps(6/6),test_hotkey_press_steps(11/11),test_hotkey_pair_steps(4/4),test_hotkey_pair_latch(11/11),test_hotkey_load(7/7),test_wayland_hotkeys(8/8),test_portal_shortcuts(32/32),test_hotkey_bindings_codec(18/18),test_hotkey_translations(16/16) andtest_x11_hotkey_layout(4/4) pass against all three. After the final rebase onto233db443a(#1826), both trees were rebuilt, and all 15 hotkey tests,ci/test_build_groups.py,ci/test_ported_sources.pyand the symbol comparison passed again on all three libraries. The branch was then rebased once more onto209d977f3(#1830, docs only, no rebuild needed).uv run ci/local_gate.py --lane lintpassed, and--lane crosspassed.ci/test_build_groups.py,ci/test_ported_sources.pyandci/platform_ifdef_ratchet.pypass. clang-format is clean on the changed files.Windows/macOS: not built there. The moved code has no host conditional, and the accessor and the dispatch are plain C.
test_hotkey_binding_press_stepsis built on every OS, liketest_hotkey_pair_steps, and is portable C (no cmocka range assertions, nofail_msg()). The newtest_hotkey_press_statecases are Linux-only with the rest of that test (XTEST).Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag change)