Skip to content

fix(cua-driver): preserve X11 keyboard delivery and timing - #3709

Closed
steipete wants to merge 1 commit into
trycua:mainfrom
steipete:codex/fix-x11-key-press-timing
Closed

fix(cua-driver): preserve X11 keyboard delivery and timing#3709
steipete wants to merge 1 commit into
trycua:mainfrom
steipete:codex/fix-x11-key-press-timing

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

Linux X11 keyboard taps were buffered across the intended hold interval, so applications received key-down and key-up together. Background keyboard calls could also return success without delivering their final events when the short-lived input connection closed.

Flush key-down before the existing 10 ms delay in XTest key taps, targeted background key taps, and background text typing. Complete background delivery with a reply-bearing X11 request before closing the connection. Keep modifier ordering, target routing, focus, and existing delays intact.

Related work

Fixes #3708.

No RFC is required: this repairs existing Linux input behavior without changing a public SDK, CLI, MCP, protocol, or permission contract.

Compatibility and risk

The production change is limited to X11. macOS, Windows, and native Wayland input implementations are unchanged. The background completion query is read-only; tests verify another window keeps keyboard focus. A synchronization failure is returned instead of being reported as successful background delivery.

This does not add held-key support or guarantee that a 10 ms tap is observed by a game polling at 35 Hz. It restores the existing tap interval and event-delivery contract. Rollback is a revert of this commit.

Validation

Candidate: df3b3b670 (the committed source matches the tested working tree).

On a disposable Ubuntu 26.04 x86_64 host with Rust 1.97.1 and isolated Xvfb:

  • The XTest regression failed on original source with 0 ms between press/release. The patch delivers 10 ms for both Up and Ctrl+Up.
  • The background regression failed on original source with 0 of 2 keyboard events received, despite a successful call. The patch passes direct-window and child-window Up/Ctrl+Up, complete ordered modifier releases, typing, and unchanged sentinel focus.
  • xvfb-run -a cargo test -p platform-linux --test key_input_x11 --locked -- --ignored --nocapture --test-threads=1: 2 passed.
  • cargo test -p platform-linux --lib --locked: 436 passed, 5 existing environment-dependent tests ignored.
  • cargo fmt --all -- --check and git diff --check: passed.
  • Independent review: no actionable findings.

A separate concurrent native event receiver measured 9.568–10.662 ms arrival intervals across ten calls each to background key, coordinate-targeted key, and typing; all 60 events reached the target and sentinel focus stayed unchanged. These background measurements are diagnostic evidence, not timing assertions in CI, because synthetic XSendEvent timestamps are zero.

The Linux CI workflow explicitly runs the new isolated-X11 regressions. Ordinary PR CI and the repository's complete cross-platform desktop certification remain pending; this PR is submitted as a draft for maintainer review. No full-gameplay or downstream OpenClaw integration proof is claimed.

Contributor and release checks

  • The PR is focused and the description matches the final diff.
  • This change does not require an RFC.
  • Tests, changelog context, and Linux platform evidence are included; remaining certification is stated above.
  • The PR title is a Conventional Commit describing the production change.
  • No external contribution was adapted.
  • This is a user-visible fix and intentionally uses the release-producing fix(cua-driver) type.

@f-trycua

f-trycua commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks again, Peter — this has landed on main in #3761: #3761

We used the current-main replacement because the release-generated changelog conflicted here. Your original commit is referenced in the landed commit, and you are credited as co-author on ce99b969f2af23c313f9e38aed980779debfe848.

The X11 regressions, ordinary CI, and exact-candidate Linux/Windows desktop matrices passed. We also completed macOS certification and confirmed its unrelated Electron background-text failure reproduces identically on the pre-change base.

Closing this PR only because the credited replacement is merged. Thank you for the fix and the clear reproduction!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Linux X11 key taps deliver press and release with zero hold interval

2 participants