kbm: the window takes the cursor when it has the focus at attach #974

Open
github-bot wants to merge 2 commits from github-bot/gh-974 into main AGit
Owner

@⁠b4rightnow on GitHub · 2026-11-24 09:46 UTC · original
b4rightnow:kbm/startup-capture → main · +73 −23 · 1 files · 2 commits · open

Stacked on #973; only the top commit (5b2d568) belongs here.

Sometimes the mouse did nothing in a title until the XCL window was clicked away from and back. The window is created with WS_VISIBLE, so CreateWindowExW shows and activates it and sends its WM_ACTIVATE before it returns. kbm::attach, which records the window, runs only after that (present.rs, window_thread), so on_message took that message for another window's and passed over it. The cursor was never held, and mouse movement, which counts only while the cursor is held, went unread until the window was activated again. It happened only when Windows activated the new window; otherwise the first click into it was the activation and input worked. Keyboard keys were not affected (they need only the focus).

attach now takes the cursor itself when the window has the focus by then, through cursor_hold as that WM_ACTIVATE would have.

What is in it

  • crates/xcl/src/hle/kbm.rs: attach holds the cursor of a window that has the focus (attach_activation → cursor_hold); the test a_window_attached_with_the_focus_takes_the_cursor.

Tested

  • NVIDIA GeForce RTX 3080 Ti (driver 621.01), AMD Ryzen 7 9800X3D, Windows 11 Pro 26200, rustc 1.100.0; tests in debug, regression runs in release.
  • cargo test --workspace -- --test-threads=4 on 5b2d568: 721 passed, 0 failed, 41 ignored.
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64).
  • cargo test -p xcl --lib kbm: 9 passed, 0 failed.
  • By hand on the same machine (tested by me, the PR's author), a retail title with this build: the mouse moves the camera right after start, without clicking another window and back.

Regression run

main:

xcl-smoke v1
commit: 6bac4b4419886acc940d479dcf8815d0b1804435
gpu: NVIDIA GeForce RTX 3080 Ti
title: 28c7ff61
seconds: 60
exit: 0x0
frames shown: 3202 (PresentX 3203)
presents per 2 s (last 3): 120 120 120
device removals: 0
crashes: 0
peak commit: 18098 MB

this PR:

xcl-smoke v1
commit: 5b2d568992cce45124d58d0396dcecea595072d1
gpu: NVIDIA GeForce RTX 3080 Ti
title: 28c7ff61
seconds: 60
exit: 0x0
frames shown: 3105 (PresentX 3105)
presents per 2 s (last 3): 55 84 120
device removals: 0
crashes: 0
peak commit: 22191 MB

Not tested

  • An automated test of a real window's activation order: the unit test covers the decision only.
  • AMD and Intel GPUs; Windows 10.

AI use

  • Claude Code, Claude Opus 5.5: found the cause, wrote the change and its test, ran the tests and the regression runs, wrote this description. The hand test was mine.
**@⁠b4rightnow** on GitHub · 2026-11-24 09:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/974) `b4rightnow:kbm/startup-capture` → `main` · +73 −23 · 1 files · 2 commits · open Stacked on #973; only the top commit (5b2d568) belongs here. Sometimes the mouse did nothing in a title until the XCL window was clicked away from and back. The window is created with `WS_VISIBLE`, so `CreateWindowExW` shows and activates it and sends its `WM_ACTIVATE` before it returns. `kbm::attach`, which records the window, runs only after that (`present.rs`, `window_thread`), so `on_message` took that message for another window's and passed over it. The cursor was never held, and mouse movement, which counts only while the cursor is held, went unread until the window was activated again. It happened only when Windows activated the new window; otherwise the first click into it was the activation and input worked. Keyboard keys were not affected (they need only the focus). `attach` now takes the cursor itself when the window has the focus by then, through `cursor_hold` as that `WM_ACTIVATE` would have. **What is in it** - `crates/xcl/src/hle/kbm.rs`: `attach` holds the cursor of a window that has the focus (`attach_activation` → `cursor_hold`); the test `a_window_attached_with_the_focus_takes_the_cursor`. **Tested** - NVIDIA GeForce RTX 3080 Ti (driver 621.01), AMD Ryzen 7 9800X3D, Windows 11 Pro 26200, rustc 1.100.0; tests in debug, regression runs in release. - `cargo test --workspace -- --test-threads=4` on 5b2d568: 721 passed, 0 failed, 41 ignored. - SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64). - `cargo test -p xcl --lib kbm`: 9 passed, 0 failed. - By hand on the same machine (tested by me, the PR's author), a retail title with this build: the mouse moves the camera right after start, without clicking another window and back. **Regression run** main: ``` xcl-smoke v1 commit: 6bac4b4419886acc940d479dcf8815d0b1804435 gpu: NVIDIA GeForce RTX 3080 Ti title: 28c7ff61 seconds: 60 exit: 0x0 frames shown: 3202 (PresentX 3203) presents per 2 s (last 3): 120 120 120 device removals: 0 crashes: 0 peak commit: 18098 MB ``` this PR: ``` xcl-smoke v1 commit: 5b2d568992cce45124d58d0396dcecea595072d1 gpu: NVIDIA GeForce RTX 3080 Ti title: 28c7ff61 seconds: 60 exit: 0x0 frames shown: 3105 (PresentX 3105) presents per 2 s (last 3): 55 84 120 device removals: 0 crashes: 0 peak commit: 22191 MB ``` **Not tested** - An automated test of a real window's activation order: the unit test covers the decision only. - AMD and Intel GPUs; Windows 10. **AI use** - Claude Code, Claude Opus 5.5: found the cause, wrote the change and its test, ran the tests and the regression runs, wrote this description. The hand test was mine.
A click on the XCL window's title bar snapped the cursor to the centre of
the window and hid it. Two messages took the cursor there: WM_ACTIVATE,
which a click on the title bar of an inactive window sends with
WA_CLICKACTIVE, and WM_EXITSIZEMOVE, which ends the move loop that any
click on the title bar starts, even without a drag. Both clipped the cursor
to the one-pixel point at the client area's centre.

Only keyboard activation (Alt+Tab, the window opening) and a click in the
client area (WM_LBUTTONDOWN) take the cursor now. WM_SIZE and WM_MOVE move
the held point only while the cursor is held, so maximising from the title
bar leaves it free too. The decision is a pure function (cursor_hold) with
a unit test.
The XCL window is created with WS_VISIBLE, so CreateWindowExW shows and
activates it and sends its WM_ACTIVATE before returning. kbm::attach, which
records the window, runs only after that, so on_message took that message
for another window's and passed over it. The cursor was never held, and
mouse movement (counted only while it is held) went unread until the window
was activated again: another window clicked and back. It happened only when
Windows activated the new window; otherwise the first click into it was the
activation and input worked.

attach now takes the cursor itself when the window has the focus by then,
through cursor_hold as a WM_ACTIVATE would.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:38:48 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 13:51 UTC · original

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

  • lib kbm: 5 passed, 0 failed.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 13:51 UTC · [original](https://github.com/xcl-dev/xcl/pull/974#issuecomment-7133441378) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - lib kbm: 5 passed, 0 failed. Thanks!
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:38 UTC · original

Empirical test report (5b2d5689)

PR #974, tested at commit 5b2d568992cce45124d58d0396dcecea595072d1.

Hardware / environment

  • Windows x64, build 26200. AMD CPU (Family 23, Model 113, Stepping 0), 12 logical processors visible.
  • rustc 1.100.0 (0ef1bc386 2026-11-09). DXC 1.9.2609.5 (01b62ad47), as reported by the bundled dxcompiler.dll.
  • Unoptimized test profile with debug info and incremental compilation disabled. The focused run used XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. Both commands ran directly through Cargo, outside Invoke-ArcTest.ps1, with zero Arc GPU mutex hold.

Commands and results

  • cargo test --workspace --no-run exited 0 and built the workspace test executables.
  • cargo test -p xcl --lib 'hle::kbm::tests::' -- --nocapture exited 0. The test summary recorded 8 passed, 0 failed, 0 ignored, and 693 filtered out. The log contained 0 uppercase SKIPPED lines.

Observed behavior

  • a_window_attached_with_the_focus_takes_the_cursor passed. With foreground input, the cursor decision requests capture. With background input, it does not request capture.
  • title_bar_clicks_leave_the_cursor_free passed. The decision leaves the cursor free through title-bar activation, moving, and maximizing. Client-area clicks and ordinary activation request capture. A held cursor follows resizing and is released on focus loss.
  • Both added tests exercise Rust decision helpers and require neither D3D12 nor a GPU.

Not tested

The full GPU workspace suite, game smoke runs, and live Win32 window activation and cursor capture were omitted.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr974-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/974#issuecomment-7153991778) ### Empirical test report (5b2d5689) PR #974, tested at commit `5b2d568992cce45124d58d0396dcecea595072d1`. **Hardware / environment** - Windows x64, build 26200. AMD CPU (Family 23, Model 113, Stepping 0), 12 logical processors visible. - `rustc 1.100.0 (0ef1bc386 2026-11-09)`. DXC `1.9.2609.5 (01b62ad47)`, as reported by the bundled `dxcompiler.dll`. - Unoptimized test profile with debug info and incremental compilation disabled. The focused run used `XCL_ADAPTER=NONE_CPU_ONLY` and `RUST_TEST_NOCAPTURE=1`. Both commands ran directly through Cargo, outside `Invoke-ArcTest.ps1`, with zero Arc GPU mutex hold. **Commands and results** - `cargo test --workspace --no-run` exited 0 and built the workspace test executables. - `cargo test -p xcl --lib 'hle::kbm::tests::' -- --nocapture` exited 0. The test summary recorded 8 passed, 0 failed, 0 ignored, and 693 filtered out. The log contained 0 uppercase `SKIPPED` lines. **Observed behavior** - `a_window_attached_with_the_focus_takes_the_cursor` passed. With foreground input, the cursor decision requests capture. With background input, it does not request capture. - `title_bar_clicks_leave_the_cursor_free` passed. The decision leaves the cursor free through title-bar activation, moving, and maximizing. Client-area clicks and ordinary activation request capture. A held cursor follows resizing and is released on focus loss. - Both added tests exercise Rust decision helpers and require neither D3D12 nor a GPU. **Not tested** The full GPU workspace suite, game smoke runs, and live Win32 window activation and cursor capture were omitted. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr974-focused.log` and published.
Author
Owner

@⁠S1m0ne1997 on GitHub · 2026-11-25 14:28 UTC · original

Test report for 5b2d568992cce45124d58d0396dcecea595072d1 (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: 721 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: 5b2d568992cce45124d58d0396dcecea595072d1
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1629 (PresentX 1629)
presents per 2 s (last 3): 34 59 60
device removals: 0
crashes: 0
peak commit: 17788 MB

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:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/974#issuecomment-7165340933) Test report for `5b2d568992cce45124d58d0396dcecea595072d1` (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: **721 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: 5b2d568992cce45124d58d0396dcecea595072d1 gpu: NVIDIA GeForce RTX 4090 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1629 (PresentX 1629) presents per 2 s (last 3): 34 59 60 device removals: 0 crashes: 0 peak commit: 17788 MB ``` **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.*
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 14:49 UTC · original

amd-win test report for head 5b2d568992cce45124d58d0396dcecea595072d1

Setup

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 (build 26200), rustc 1.100.0, debug build for tests, release for smoke
  • Tested as a local merge of the PR head onto main 06c9f5505f63f10c5ec49ef932d75b2c28177324 (merge commit bf7c558c0fde86eaefa6780ccb011b2436324b23; it merged without conflicts). That is not the PR head itself, so the smoke block below names the merge commit.

Tests

  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4: 1266 passed, 1 failed, 46 ignored, 7 SKIPPED lines (f16/f32 per-lane form, no heap windows)
  • The 1 failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] GPU 0x1 vs CPU 0x7fffffff). It fails the same way on main (1264 passed, 1 failed, 46 ignored), so it is not caused by this PR.
  • The PR's new test hle::kbm::tests::a_window_attached_with_the_focus_takes_the_cursor passes.

Regression run (60 s, same title, networking off; main first, then the merge)

xcl-smoke v1  main 06c9f5505f63f10c5ec49ef932d75b2c28177324
frames shown: 1540, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 16495 MB
xcl-smoke v1  merge bf7c558c0fde86eaefa6780ccb011b2436324b23
frames shown: 1583, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 14849 MB

Exit code 0x0 on both. The full xcl-smoke blocks are not pasted because of the merge-commit caveat above.

Not tested

  • Not tested by hand: whether the cursor is taken at launch when the window has focus, and the title-bar click path (stacked on #973). Only the unit tests and a title run were done.
  • NVIDIA, wave32-only GPUs.

AI use: this run and report were done by Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-25 14:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/974#issuecomment-7165872475) **amd-win test report** for head `5b2d568992cce45124d58d0396dcecea595072d1` **Setup** - AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 (build 26200), rustc 1.100.0, debug build for tests, release for smoke - Tested as a local merge of the PR head onto `main` `06c9f5505f63f10c5ec49ef932d75b2c28177324` (merge commit `bf7c558c0fde86eaefa6780ccb011b2436324b23`; it merged without conflicts). That is not the PR head itself, so the smoke block below names the merge commit. **Tests** - `cargo build --workspace` then `cargo test --workspace --no-fail-fast -- --test-threads=4`: **1266 passed, 1 failed, 46 ignored**, 7 `SKIPPED` lines (f16/f32 per-lane form, no heap windows) - The 1 failure is `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` (seed 722: `res[30]` GPU 0x1 vs CPU 0x7fffffff). It fails the same way on `main` (1264 passed, 1 failed, 46 ignored), so it is not caused by this PR. - The PR's new test `hle::kbm::tests::a_window_attached_with_the_focus_takes_the_cursor` passes. **Regression run** (60 s, same title, networking off; `main` first, then the merge) ``` xcl-smoke v1 main 06c9f5505f63f10c5ec49ef932d75b2c28177324 frames shown: 1540, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 16495 MB xcl-smoke v1 merge bf7c558c0fde86eaefa6780ccb011b2436324b23 frames shown: 1583, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 14849 MB ``` Exit code 0x0 on both. The full `xcl-smoke` blocks are not pasted because of the merge-commit caveat above. **Not tested** - Not tested by hand: whether the cursor is taken at launch when the window has focus, and the title-bar click path (stacked on #973). Only the unit tests and a title run were done. - NVIDIA, wave32-only GPUs. **AI use:** this run and report were done by Claude Code (Claude Sonnet 5.5).
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 03:23 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 03:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/974#issuecomment-7181677405) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
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/974/head:github-bot/gh-974'
git switch 'github-bot/gh-974'

Merge

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