Repository navigation
libobs: Keep Wayland push-to-talk pressed while the key is held - #211
Merged
Merged
Conversation
On Wayland the libobs hotkey thread is never told that a key is held: obs_nix_wayland_hotkeys_platform_is_pressed() always returns false. The thread polls every 25 ms and releases every binding whose key it cannot see, so with OBS focused push-to-talk drops right after Qt injects the press (upstream #10701). Add obs_nix_hotkey_state, the key state the hotkey thread will read on Wayland, fed by keys and modifiers held while OBS has keyboard focus. It is a stub here that behaves like Wayland today. test_wayland_hotkeys runs the real hotkey thread (obs-hotkey.c on an isolated core) and plays the wl_keyboard listener and the Qt key filter. RED: 2 of 4 fail: - focused_key_holds_push_to_talk: "focused push-to-talk released while the key is held (releases 1)" - focused_modifiers_hold_combination: Ctrl+Shift+F13 released while held focus_loss_releases_keys and nothing_reported_releases pass (they pin today's release behaviour). Reported upstream by rootgordon (#10701). Refs obs-rust#210. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The libobs hotkey thread polls obs_hotkeys_platform_is_pressed() every 25 ms and releases any binding whose key is not reported as held. On Wayland that function always returned false, so with OBS focused the press that Qt injects was undone within 25 ms: push-to-talk only opened for its release delay (upstream #10701). Report what Wayland does tell us. obs_nix_hotkey_state records the keys and modifiers held while an OBS window has keyboard focus, from the wl_keyboard listener the platform already had, and is cleared when focus leaves (no release events follow then). is_pressed() answers from it, as X11 answers from the server. Out of focus nothing changes: Wayland sends no key events then. Changes take obs->hotkeys.mutex so they land between poll cycles, so the mutex is now initialised before the platform layer. The platform also releases its seat, keyboard and registry on free, as their listeners point at the freed context. Root cause identified upstream by thomasza92 in obsproject/obs-studio#13387, following the analysis on #10701; the mutex ordering follows aurelleb's obsproject/obs-studio#13661. Reported by rootgordon. test_wayland_hotkeys: 4/4 pass (RED: 2/4). Fixes obs-rust#210. Co-Authored-By: Aurelle <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Local-Gate: v1 tree=596f93ec437e6ff9f8f95f6ad714a9c172321565 secs=139 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791703567,"gate":"rust/all/fmt","host":"linux-x86_64","key":"09ca4dcde655140f9e3c5b19d913ec82ae3d6d9623dfb37cec39fa6e34367066","lane":"lint","parents":["a07f661139270888843eee9c0a3412670d2dd0e5"],"secs":54,"stamp":"1538831521bad0e9513812fed94330a6","tree":"596f93ec437e6ff9f8f95f6ad714a9c172321565","v":1,"via":"run"} Ci-Attestation: {"at":1791703567,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"09ca4dcde655140f9e3c5b19d913ec82ae3d6d9623dfb37cec39fa6e34367066","lane":"lint","parents":["a07f661139270888843eee9c0a3412670d2dd0e5"],"secs":54,"stamp":"c81aa36954f9c37fd6de3d5b42266631","tree":"596f93ec437e6ff9f8f95f6ad714a9c172321565","v":1,"via":"run"} Ci-Attestation: {"at":1791703567,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"49295e7a48240f05a4abe0a792a1081869c52a3f120bc6f37dba766236cee958","lane":"rust-test","parents":["a07f661139270888843eee9c0a3412670d2dd0e5"],"secs":30,"stamp":"674bf77d929ba69894deff377af95825","tree":"596f93ec437e6ff9f8f95f6ad714a9c172321565","v":1,"via":"run"} Ci-Attestation: {"at":1791703567,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"3461a03f5f791a6021ac0fd2e068e190904e9a062ecb655475786d193132e440","lane":"tier2-linux","parents":["a07f661139270888843eee9c0a3412670d2dd0e5"],"secs":54,"stamp":"cd39e83dad7b791fe5c79a011bdfbe09","tree":"596f93ec437e6ff9f8f95f6ad714a9c172321565","v":1,"via":"run"}
Member
|
Verified locally, rebased onto master and stamped. The new head is
Merging once CI is green. |
zackees
force-pushed
the
fix/210-wayland-held-keys
branch
from
October 11, 2026 07:26
052c2d3 to
b5f4f78
Compare
This was referenced Oct 11, 2026
bug: libobs: Wayland push-to-talk released within 25 ms while the key is held (upstream #10701)
#210
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On Wayland, push-to-talk (and every other hold-type hotkey) is released about 25 ms after it is pressed, even with OBS focused: the mic opens only for the configured release delay, whether the key is tapped or held. With this change the hotkey stays pressed for as long as the key is held while an OBS window has keyboard focus, as it does on X11.
The cause:
obs_nix_wayland_hotkeys_platform_is_pressed()(libobs/obs-nix-wayland.c:261) always returns false. The libobs hotkey thread (obs_hotkey_thread,libobs/obs-hotkey.c) pollsobs_hotkeys_platform_is_pressed()every 25 ms, andhandle_binding()releases any pressed binding whose key is not reported as held. The press itself is injected by the Qt key filter (obs_hotkey_inject_event), so it fires, but the next poll undoes it. On X11 the thread asks the X server; on Wayland nothing answered.test: Add failing test for Wayland push-to-talk released while held:test_wayland_hotkeysruns the real hotkey thread (obs-hotkey.con an isolated core, liketest_hotkey_load) and plays the parts of thewl_keyboardlistener and the Qt key filter, against a stubobs_nix_hotkey_statethat reports nothing, as Wayland does today. 2 of 4 fail:focused_key_holds_push_to_talk("focused push-to-talk released while the key is held (releases 1)") andfocused_modifiers_hold_combination.focus_loss_releases_keysandnothing_reported_releasespass and pin the release behaviour that must not change.libobs: Report keys held while focused to the Wayland hotkey thread:obs_nix_hotkey_staterecords the keys and modifiers held while OBS has keyboard focus, from thewl_keyboardlistener the Wayland platform already had (key, modifiers and enter events; cleared on leave, since no release events follow).is_pressed()answers from it. Updates takeobs->hotkeys.mutexso they land between poll cycles; that mutex is now initialised before the platform layer inobs_init_hotkeys(). The platform also releases its seat, keyboard and registry on free, since their listeners point at the context it frees. All 4 tests pass.Motivation and Context
Fixes #210 (upstream obsproject/obs-studio#10701, reported by rootgordon)
The root cause was identified upstream by thomasza92 in obsproject/obs-studio#13387, a draft that instead adds an "unknown" pressed state on every platform. This change keeps the platform interface as it is and gives Wayland a real answer. The mutex ordering follows aurelleb's obsproject/obs-studio#13661.
Why this one: push-to-talk is unusable on Wayland, which is now the default session on most Linux desktops, and the issue has been open upstream since 2024.
Out of scope: hotkeys while OBS is not focused. Wayland sends no key events then, so nothing changes there. That needs the xdg-desktop-portal GlobalShortcuts interface, and its design goes to a separate discussion first.
How Has This Been Tested?
Automated, headless (no Wayland display;
WAYLAND_DISPLAY/DISPLAYunset):test_wayland_hotkeysfails 2 of 4 at the RED commit and passes 4 of 4 at the GREEN commit, after clean rebuilds. It passed 10 of 10 repeated runs and is clean under ASan/UBSan. The full ctest suite passes (68/68). clang-format and gersemi are clean, and the full build with the frontend succeeds.Behaviour change: with OBS focused on Wayland, a hold-type hotkey now stays pressed while its key is held, and is released on key release or when OBS loses keyboard focus. That matches X11. Unfocused behaviour is unchanged. With "Disable hotkeys when in focus" set, nothing new is pressed, because the hotkey thread still honours
thread_disable_press.Not tested:
wl_keyboardevent path, its ordering against Qt's injected press, and seat/keyboard release on shutdown (pending a manual check by the submitter).Types of changes
Checklist:
🤖 Generated with Claude Code