kbm: the click that focuses the window is not a press #1172

Open
github-bot wants to merge 1 commit from github-bot/gh-1172 into main AGit
Owner

@⁠emirduran707 on GitHub · 2026-11-24 12:50 UTC · original
emirduran707:kbm-focus-click → main · +50 −6 · 1 files · 1 commits · open

Keyboard and mouse as a gamepad: clicking the XCL window to bring it back to the front also pulled the right trigger. apply reads the buttons with GetAsyncKeyState, and starts doing so as soon as the window has the focus again, while the focusing click's button is still held. In a title where the right trigger fires, every click into the window fired once.

A small Buttons state now ignores a left, right or middle button that is already down when the window gets the focus, until that button is let go. The state is cleared where the mouse state is already reset: on focus loss and when a window drag or resize starts. The middle button (right stick click) moved out of VK_KEYS so it goes through the same check.

What is in it

  • crates/xcl/src/hle/kbm.rs: Buttons, kept in the mouse state and used by apply; test the_click_that_focuses_the_window_is_no_press.

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on b385b89: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests
  • the new test fails with the old behaviour (a held button is a press at once: left: 1, right: 0); with the change cargo test -p xcl --lib hle::kbm passes, 7 passed

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1541 (PresentX 1541)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19650 MB

this PR:

xcl-smoke v1
commit: b385b898eb28047623f703102637006954c5c149
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1423 (PresentX 1424)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19101 MB

Not tested

  • By hand with a real window and mouse; the smoke run takes no input.
  • A button held at the very first poll after start is also ignored until it is let go.
  • NVIDIA and Intel GPUs.

AI use

  • Claude Code with Claude Opus 5.5: found the problem, wrote the change, the tests and this description; I reviewed the diff and ran the tests and smoke runs above.

🤖 Generated with Claude Code

**@⁠emirduran707** on GitHub · 2026-11-24 12:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/1172) `emirduran707:kbm-focus-click` → `main` · +50 −6 · 1 files · 1 commits · open Keyboard and mouse as a gamepad: clicking the XCL window to bring it back to the front also pulled the right trigger. `apply` reads the buttons with `GetAsyncKeyState`, and starts doing so as soon as the window has the focus again, while the focusing click's button is still held. In a title where the right trigger fires, every click into the window fired once. A small `Buttons` state now ignores a left, right or middle button that is already down when the window gets the focus, until that button is let go. The state is cleared where the mouse state is already reset: on focus loss and when a window drag or resize starts. The middle button (right stick click) moved out of `VK_KEYS` so it goes through the same check. **What is in it** - `crates/xcl/src/hle/kbm.rs`: `Buttons`, kept in the mouse state and used by `apply`; test `the_click_that_focuses_the_window_is_no_press`. **Tested** - AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release - `cargo test --workspace -- --test-threads=4` on b385b89: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests - the new test fails with the old behaviour (a held button is a press at once: `left: 1`, `right: 0`); with the change `cargo test -p xcl --lib hle::kbm` passes, 7 passed **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1541 (PresentX 1541) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19650 MB ``` this PR: ``` xcl-smoke v1 commit: b385b898eb28047623f703102637006954c5c149 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1423 (PresentX 1424) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19101 MB ``` **Not tested** - By hand with a real window and mouse; the smoke run takes no input. - A button held at the very first poll after start is also ignored until it is let go. - NVIDIA and Intel GPUs. **AI use** - Claude Code with Claude Opus 5.5: found the problem, wrote the change, the tests and this description; I reviewed the diff and ran the tests and smoke runs above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`apply` read the mouse buttons with GetAsyncKeyState as soon as the XCL
window was in front again. A click on the inactive window both brings
it to the front and holds the button down, so the first polls after it
saw the button held and pulled the mapped trigger (or clicked the right
stick): clicking back into the window fired.

A button already down when the window gets the focus is now left out
until it is let go (`Buttons`, kept with the mouse state). The mouse
state is reset on focus loss and when a move/size loop starts, so the
next button held after either is taken for the focusing click. Other
buttons pressed meanwhile and later clicks are passed on as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:45:59 +00:00
Author
Owner

@⁠fromthemoonx on GitHub · 2026-11-24 13:45 UTC · original

NVIDIA run with the whole suite, since Not tested lists NVIDIA.

Tested

  • NVIDIA GeForce RTX 3060 12 GB, driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974); rustc 1.100.0 stable-x86_64-pc-windows-msvc; debug
  • Exact head b385b898eb28047623f703102637006954c5c149 (on its base 47efa2e): cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4: 742 passed, 0 failed, 41 ignored, the same as yours
  • Merged onto current main 930e8b4 (no conflict; main has gained ten commits since your base): 752 passed, 0 failed, 41 ignored
  • Fails with the old behaviour, as you say: with Buttons::pressed returning down (every held button a press), kbm::tests::the_click_that_focuses_the_window_is_no_press fails with left: 1, right: 0
  • hle::kbm tests, 10 runs: 10 of 10 passed (7 each)
  • SKIPPED (no wave64 on this adapter): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware

Not tested

  • Clicking into a real XCL window with a title running (no title here); release build.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds and tests on the machine above, including the old-behaviour check, and wrote this report from the output.
**@⁠fromthemoonx** on GitHub · 2026-11-24 13:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/1172#issuecomment-7133294766) NVIDIA run with the whole suite, since **Not tested** lists NVIDIA. **Tested** - NVIDIA GeForce RTX 3060 12 GB, driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974); rustc 1.100.0 `stable-x86_64-pc-windows-msvc`; debug - **Exact head `b385b898eb28047623f703102637006954c5c149`** (on its base `47efa2e`): `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4`: **742 passed, 0 failed, 41 ignored**, the same as yours - **Merged onto current `main` `930e8b4`** (no conflict; `main` has gained ten commits since your base): **752 passed, 0 failed, 41 ignored** - **Fails with the old behaviour, as you say:** with `Buttons::pressed` returning `down` (every held button a press), `kbm::tests::the_click_that_focuses_the_window_is_no_press` fails with `left: 1, right: 0` - `hle::kbm` tests, 10 runs: **10 of 10 passed** (7 each) - SKIPPED (no wave64 on this adapter): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` **Not tested** - Clicking into a real XCL window with a title running (no title here); release build. **AI use** - Claude Code (Claude Opus 5.5) ran the builds and tests on the machine above, including the old-behaviour check, and wrote this report from the output.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 07:46 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 07:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/1172#issuecomment-7156241948) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠S1m0ne1997 on GitHub · 2026-11-25 14:37 UTC · original · edited 2026-11-25 14:40 UTC

Test report for b385b898eb28047623f703102637006954c5c149 (this PR's head), for #1607.

Tested

  • NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, 47 GB RAM, Windows 11 Home 10.0.26300, rustc 1.100.0 (0ef1bc386 2026-11-09) x86_64-pc-windows-msvc, debug.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 at the head: 742 passed, 0 failed, 41 ignored.
  • SKIPPED (2): gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64).

Regression run (retail title, scripts/smoke.ps1 -Seconds 60, release; main built from the commit in its block, this PR from its head, no uncommitted changes)

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1599 (PresentX 1599)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16384 MB

this PR:

xcl-smoke v1
commit: b385b898eb28047623f703102637006954c5c149
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1546 (PresentX 1546)
presents per 2 s (last 3): 56 41 9
device removals: 0
crashes: 0
peak commit: 25443 MB

Peak commit is over the 125 % rule: this PR's run peaked at 25 443 MB, 155 % of main's 16 384 MB (frames: within 80 %). I can't tell from this whether the PR causes it: this branch is based on 47efa2e 490 commits older than the main commit (06c9f55) its run is compared with and each side was run once. A smoke run of 47efa2e itself or of this PR rebased onto current main would separate the two.

Not tested

  • AMD, other NVIDIA cards and drivers, Linux. I did not review the diff; this report is the build, the suite and the regression run only.

AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.

**@⁠S1m0ne1997** on GitHub · 2026-11-25 14:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1172#issuecomment-7165577562) · edited 2026-11-25 14:40 UTC Test report for `b385b898eb28047623f703102637006954c5c149` (this PR's head), for #1607. **Tested** - NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, 47 GB RAM, Windows 11 Home 10.0.26300, `rustc 1.100.0 (0ef1bc386 2026-11-09)` `x86_64-pc-windows-msvc`, debug. - `cargo build --workspace`, then `cargo test --workspace -- --test-threads=4` at the head: **742 passed, 0 failed, 41 ignored**. - SKIPPED (2): `gpu_geometry_wave32_prefix_count_over_a_mask` (no wave64), `gpu_wave32_program_in_wave64_hardware` (no wave64). **Regression run** (retail title, `scripts/smoke.ps1 -Seconds 60`, release; `main` built from the commit in its block, this PR from its head, no uncommitted changes) main: ``` xcl-smoke v1 commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324 gpu: NVIDIA GeForce RTX 4090 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1599 (PresentX 1599) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16384 MB ``` this PR: ``` xcl-smoke v1 commit: b385b898eb28047623f703102637006954c5c149 gpu: NVIDIA GeForce RTX 4090 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1546 (PresentX 1546) presents per 2 s (last 3): 56 41 9 device removals: 0 crashes: 0 peak commit: 25443 MB ``` **Peak commit is over the 125 % rule:** this PR's run peaked at 25 443 MB, 155 % of `main`'s 16 384 MB (frames: within 80 %). I can't tell from this whether the PR causes it: this branch is based on `47efa2e` 490 commits older than the `main` commit (`06c9f55`) its run is compared with and each side was run once. A smoke run of `47efa2e` itself or of this PR rebased onto current `main` would separate the two. **Not tested** - AMD, other NVIDIA cards and drivers, Linux. I did not review the diff; this report is the build, the suite and the regression run only. *AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.*
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1172/head:github-bot/gh-1172'
git switch 'github-bot/gh-1172'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1172'
git switch 'github-bot/gh-1172'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1172'
git switch 'github-bot/gh-1172'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1172'
git switch 'main'
git merge --squash 'github-bot/gh-1172'
git switch 'main'
git merge --ff-only 'github-bot/gh-1172'
git switch 'main'
git merge 'github-bot/gh-1172'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.