Skip to content

libobs: Keep Wayland push-to-talk pressed while the key is held - #211

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/210-wayland-held-keys
Oct 11, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/210-wayland-held-keys

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

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) polls obs_hotkeys_platform_is_pressed() every 25 ms, and handle_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.

  1. test: Add failing test for Wayland push-to-talk released while held: test_wayland_hotkeys runs the real hotkey thread (obs-hotkey.c on an isolated core, like test_hotkey_load) and plays the parts of the wl_keyboard listener and the Qt key filter, against a stub obs_nix_hotkey_state that 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)") and focused_modifiers_hold_combination. focus_loss_releases_keys and nothing_reported_releases pass and pin the release behaviour that must not change.
  2. libobs: Report keys held while focused to the Wayland hotkey thread: obs_nix_hotkey_state records the keys and modifiers held while OBS has keyboard focus, from the wl_keyboard listener the Wayland platform already had (key, modifiers and enter events; cleared on leave, since no release events follow). is_pressed() answers from it. Updates take obs->hotkeys.mutex so they land between poll cycles; that mutex is now initialised before the platform layer in obs_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/DISPLAY unset): test_wayland_hotkeys fails 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:

  • A real Wayland session: the wl_keyboard event path, its ordering against Qt's injected press, and seat/keyboard release on shutdown (pending a manual check by the submitter).
  • FreeBSD (the same sources are added to its build).
  • The Rust and Docker lanes of the local gate.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.
  • I have used AI tooling in the creation of this PR
  • I am an AI agent being used to assist with this pull request: Claude Code (Claude Opus 5.5) wrote the code, commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machine.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner October 11, 2026 07:12
rdoupe and others added 2 commits October 11, 2026 00:23
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"}
@zackees

zackees commented Oct 11, 2026

Copy link
Copy Markdown
Member

Verified locally, rebased onto master and stamped. The new head is b5f4f7880.

  • RED (419dd55f8): Tier 2 passed 67 of 68. The new test failed ([ FAILED ] tests: 2 test(s), listed below:).
  • GREEN (052c2d360): Tier 2 passed 68 of 68 with ENABLE_RUST_LIBOBS OFF and 68 of 68 with it ON.
  • Local gate on the rebased head: lint, rust-test and tier2-linux all passed.

Merging once CI is green.

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.

bug: libobs: Wayland push-to-talk released within 25 ms while the key is held (upstream #10701)

2 participants