fix(input): pause mouse capture and warp while dragging or resizing the window #1002

Merged
adwen-007 merged 1 commit from upstream-pr/1002 into main 2026-11-29 08:16:57 +00:00
adwen-007 commented 2026-11-28 10:57:26 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by adwen-007 on 2026-11-28T10:57:26Z.


Problem

When VICTORY_MOUSE_WARP=1 and VICTORY_MOUSE_CAPTURE=1 are enabled in windowed mode, grabbing the title bar to drag or resize the window triggers WM_MOVE / capture logic that re-clips and warps the cursor back to the window center mid-drag, causing the window to jump across the screen.

Fix

  • Pause mouse capture/warp in crates/victory-hle/src/modules/lifecycle.rs on WM_NCLBUTTONDOWN / WM_ENTERSIZEMOVE, and resume cleanly on WM_EXITSIZEMOVE or client-area click (WM_LBUTTONDOWN).

Verification

  • Verified on Windows 10 (19045) in 1440p/1080p windowed mode with VICTORY_MOUSE_CAPTURE=1 and VICTORY_MOUSE_WARP=1: window drags and resizes smoothly without cursor warp interference, and camera capture resumes on click inside the game window.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5539395163 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1002). Originally posted by [adwen-007](https://github.com/adwen-007) on 2026-11-28T10:57:26Z. --- ### Problem When `VICTORY_MOUSE_WARP=1` and `VICTORY_MOUSE_CAPTURE=1` are enabled in windowed mode, grabbing the title bar to drag or resize the window triggers `WM_MOVE` / capture logic that re-clips and warps the cursor back to the window center mid-drag, causing the window to jump across the screen. ### Fix - Pause mouse capture/warp in `crates/victory-hle/src/modules/lifecycle.rs` on `WM_NCLBUTTONDOWN` / `WM_ENTERSIZEMOVE`, and resume cleanly on `WM_EXITSIZEMOVE` or client-area click (`WM_LBUTTONDOWN`). ### Verification - Verified on Windows 10 (19045) in 1440p/1080p windowed mode with `VICTORY_MOUSE_CAPTURE=1` and `VICTORY_MOUSE_WARP=1`: window drags and resizes smoothly without cursor warp interference, and camera capture resumes on click inside the game window.
Dukestar69 commented 2026-11-28 11:49:39 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T11:49:39Z.

Review: APPROVED


Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge in crates/victory-hle/src/modules/lifecycle.rs; cargo xtask policy passed (294 files ok).
  • Tests: cargo test -p victory-hle --lib lifecycle:: passed (11 passed; 0 failed, including mouse_reference_handles_focus_reset_and_warp) with 0 compiler warnings.

Nice UX fix pausing mouse capture/warp during window move/resize loops (WM_ENTERSIZEMOVE / WM_EXITSIZEMOVE). LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6097620011 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1002#pullrequestreview-6097620011). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T11:49:39Z. **Review:** APPROVED --- Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge in `crates/victory-hle/src/modules/lifecycle.rs`; `cargo xtask policy` passed (`294 files ok`). - **Tests**: `cargo test -p victory-hle --lib lifecycle::` passed (`11 passed; 0 failed`, including `mouse_reference_handles_focus_reset_and_warp`) with 0 compiler warnings. Nice UX fix pausing mouse capture/warp during window move/resize loops (`WM_ENTERSIZEMOVE` / `WM_EXITSIZEMOVE`). LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Jesper-Andersson commented 2026-11-28 20:39:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Jesper-Andersson on 2026-11-28T20:39:49Z.


One more place that may pull the cursor while the title bar is dragged, if I read main 923e38c right (read from code; not run on main).

The PR pauses the capture and warp in lifecycle.rs. With the mouse and keyboard profile (VICTORY_MNK_BINDINGS), crates/victory-hle/src/modules/mnk.rs has its own pull: sample() (line 223) calls recenter() (lines 164-185) about every 8 ms whenever the foreground window is ours and F1 is closed. recenter() reads GetCursorPos and, if the cursor is off the client centre, calls SetCursorPos to the centre. It does not check whether the cursor is inside the client area, whether a button is held, or whether a move/size loop is running. A title-bar click makes our window the foreground one, so I would expect the window to be pulled back or impossible to drag. The only ways out I can see on main are F1 (which stops the pull) and leaving the window (Alt+Tab).

On our fork, an earlier version captured on activation, and a click on the title bar did capture the mouse there; that is what led us to look. It is a different code path from main's, so this is not confirmation for main.

Suggestion, not a request: if the pause in this PR is meant to cover the MnK profile too, recenter() would need the same condition (no pull from WM_NCLBUTTONDOWN to WM_EXITSIZEMOVE, and none when the cursor is outside the client area). A release key would also help; #731 proposes Alt for the capture.

This was written with AI assistance (Claude Code).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7245449715 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1002#issuecomment-7245449715). Originally posted by [Jesper-Andersson](https://github.com/Jesper-Andersson) on 2026-11-28T20:39:49Z. --- One more place that may pull the cursor while the title bar is dragged, if I read main `923e38c` right (read from code; not run on main). The PR pauses the capture and warp in `lifecycle.rs`. With the mouse and keyboard profile (`VICTORY_MNK_BINDINGS`), `crates/victory-hle/src/modules/mnk.rs` has its own pull: `sample()` (line 223) calls `recenter()` (lines 164-185) about every 8 ms whenever the foreground window is ours and F1 is closed. `recenter()` reads `GetCursorPos` and, if the cursor is off the client centre, calls `SetCursorPos` to the centre. It does not check whether the cursor is inside the client area, whether a button is held, or whether a move/size loop is running. A title-bar click makes our window the foreground one, so I would expect the window to be pulled back or impossible to drag. The only ways out I can see on main are F1 (which stops the pull) and leaving the window (Alt+Tab). On our fork, an earlier version captured on activation, and a click on the title bar did capture the mouse there; that is what led us to look. It is a different code path from main's, so this is not confirmation for main. Suggestion, not a request: if the pause in this PR is meant to cover the MnK profile too, `recenter()` would need the same condition (no pull from `WM_NCLBUTTONDOWN` to `WM_EXITSIZEMOVE`, and none when the cursor is outside the client area). A release key would also help; #731 proposes Alt for the capture. This was written with AI assistance (Claude Code).
adwen-007 commented 2026-11-28 21:39:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by adwen-007 on 2026-11-28T21:39:12Z.


Thanks @Jesper-Andersson — great catch!

Rebased onto main (923e38c) and updated crates/victory-hle/src/modules/mnk.rs (f71c8b9) to cover the MnK profile as well:

  • Exposed lifecycle::mouse_dragging() (WM_ENTERSIZEMOVE / WM_NCLBUTTONDOWN → WM_EXITSIZEMOVE / WM_LBUTTONDOWN / focus loss) and guarded both mnk::sample() and mnk::recenter().
  • Added a client-area bounds check in mnk::recenter() before initial centering (!centered), so clicking the title bar or window chrome never pulls the cursor into the client area.

Verified cargo check -p victory-hle passes cleanly with zero warnings.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7246173707 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1002#issuecomment-7246173707). Originally posted by [adwen-007](https://github.com/adwen-007) on 2026-11-28T21:39:12Z. --- Thanks @Jesper-Andersson — great catch! Rebased onto `main` (`923e38c`) and updated `crates/victory-hle/src/modules/mnk.rs` (`f71c8b9`) to cover the MnK profile as well: - Exposed `lifecycle::mouse_dragging()` (`WM_ENTERSIZEMOVE` / `WM_NCLBUTTONDOWN` → `WM_EXITSIZEMOVE` / `WM_LBUTTONDOWN` / focus loss) and guarded both `mnk::sample()` and `mnk::recenter()`. - Added a client-area bounds check in `mnk::recenter()` before initial centering (`!centered`), so clicking the title bar or window chrome never pulls the cursor into the client area. Verified `cargo check -p victory-hle` passes cleanly with zero warnings.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!1002
No description provided.