gameinput: let go of the cursor clip while the window is dragged (RT-GAMEINPUT-CLIP-DRAG) #2487

Merged
Tyrannys merged 1 commit from upstream-pr/2487 into main 2026-11-28 08:06:15 +00:00
Tyrannys commented 2026-11-27 18:13:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T18:13:51Z.


Claimed in the coordination issue as: RT-GAMEINPUT-CLIP-DRAG (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7225229818). It comes from a user's report: when you grab the window, it is pulled downwards on the monitor instead of being dragged. Thanks for the report.

Depends on: none.

What and why

With raw input on, the keyboard pad keeps the cursor inside the foreground window's client area. clip_cursor() in runtime/shims/gameinput.cpp calls ClipCursor on the client rect and repeats it every 100 ms while the window has focus. A press on the title bar (non-client area) was pulled into the client area. During the modal move loop that followed, each re-clip pulled the cursor down again, and the window followed it down the screen. The two SetWindowPos calls (d3d12_xs_device.cpp, dxgi_com.cpp) already pass SWP_NOMOVE, so they are not the cause.

The clip is now released (ClipCursor(nullptr)) in these cases:

  • The window's thread is in a move/size or menu loop (GetGUIThreadInfo: GUI_INMOVESIZE, GUI_INMENUMODE, GUI_SYSTEMMENUMODE).
  • A mouse press that began outside the client area is still held. This includes a press on the title bar that activated the window, so the press was already down when the clip was first wanted.

A press in the client area keeps the clip, so a click still cannot land on another window, as before. The clip comes back once the button is released and the loop has ended.

The decision is a pure helper, rt::gameinput::detail::CursorClipGate (new runtime/shims/gameinput_clip.h). It takes "wanted", "modal loop", "button down" and "cursor in client", and returns whether to clip now. clip_cursor() reads those four inputs from Windows and applies the result. docs/gameinput.md describes the new release cases.

Tested

  • New gameinput_clip test (runtime/test/gameinput_clip_test.cpp, no window, no SDL). It covers:
    • A client-area press, which stays clipped even when dragged to the edge.
    • A title-bar press, then the move loop, then release. There is no clip until the release, then the clip returns.
    • Focus gained by a title-bar press, which gives no clip, and focus gained by a client press, which clips at once.
    • A modal loop alone, with no buttons held.
  • The helper is new, so this test has no "fails on main" run. The bug needs a real window drag, which is not automated here.
  • gameinput, gameinput_script, gameinput_host and gameinput_clip pass in an SDL3 build. gameinput_no_sdl, gameinput_no_sdl_script, gameinput_host and gameinput_clip pass in a build without SDL3.
  • Not checked by hand by dragging a game window: a boot was running on this machine.

No game files, logs or screenshots.

GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5531210672 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2487). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-27T18:13:51Z. --- Claimed in the coordination issue as: RT-GAMEINPUT-CLIP-DRAG (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7225229818). It comes from a user's report: when you grab the window, it is pulled downwards on the monitor instead of being dragged. Thanks for the report. Depends on: none. ### What and why With raw input on, the keyboard pad keeps the cursor inside the foreground window's client area. `clip_cursor()` in `runtime/shims/gameinput.cpp` calls `ClipCursor` on the client rect and repeats it every 100 ms while the window has focus. A press on the title bar (non-client area) was pulled into the client area. During the modal move loop that followed, each re-clip pulled the cursor down again, and the window followed it down the screen. The two `SetWindowPos` calls (`d3d12_xs_device.cpp`, `dxgi_com.cpp`) already pass `SWP_NOMOVE`, so they are not the cause. The clip is now released (`ClipCursor(nullptr)`) in these cases: - The window's thread is in a move/size or menu loop (`GetGUIThreadInfo`: `GUI_INMOVESIZE`, `GUI_INMENUMODE`, `GUI_SYSTEMMENUMODE`). - A mouse press that began outside the client area is still held. This includes a press on the title bar that activated the window, so the press was already down when the clip was first wanted. A press in the client area keeps the clip, so a click still cannot land on another window, as before. The clip comes back once the button is released and the loop has ended. The decision is a pure helper, `rt::gameinput::detail::CursorClipGate` (new `runtime/shims/gameinput_clip.h`). It takes "wanted", "modal loop", "button down" and "cursor in client", and returns whether to clip now. `clip_cursor()` reads those four inputs from Windows and applies the result. `docs/gameinput.md` describes the new release cases. ### Tested - New `gameinput_clip` test (`runtime/test/gameinput_clip_test.cpp`, no window, no SDL). It covers: - A client-area press, which stays clipped even when dragged to the edge. - A title-bar press, then the move loop, then release. There is no clip until the release, then the clip returns. - Focus gained by a title-bar press, which gives no clip, and focus gained by a client press, which clips at once. - A modal loop alone, with no buttons held. - The helper is new, so this test has no "fails on main" run. The bug needs a real window drag, which is not automated here. - `gameinput`, `gameinput_script`, `gameinput_host` and `gameinput_clip` pass in an SDL3 build. `gameinput_no_sdl`, `gameinput_no_sdl_script`, `gameinput_host` and `gameinput_clip` pass in a build without SDL3. - Not checked by hand by dragging a game window: a boot was running on this machine. No game files, logs or screenshots. GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
timbot103 commented 2026-11-28 02:01:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:01:44Z.


Reviewed at head 28829e0aa on Windows 11 (MSVC 2022 19.44).

Verification

  • Built gameinput_clip_test.
  • gameinput_clip_test: passed.

Notes (non-blocking)

  • The pure clip-gate helper (gameinput_clip.h:10-30) and polling-path suppression on move/size/menu flags (gameinput.cpp:1793-1816, 1905, 2039-2045) are clean and well-tested.
  • Minor docs note (docs/gameinput.md:164-168; gameinput.cpp:1793-1825): Once a client-area ClipCursor has already settled with no active move/menu loop, Windows constrains the cursor inside the client rectangle so a user cannot reach the title bar or resize border to initiate an outside-client click. This change cleanly handles drags already in progress (e.g., activation drags or system-menu Move); clarifying the supported entry paths in docs/gameinput.md would set accurate expectations.

Approve.

AI-assisted review + local MSVC verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232079180 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2487#issuecomment-7232079180). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T02:01:44Z. --- Reviewed at head `28829e0aa` on Windows 11 (MSVC 2022 `19.44`). ### Verification - Built `gameinput_clip_test`. - `gameinput_clip_test`: **passed**. ### Notes (non-blocking) - The pure clip-gate helper (`gameinput_clip.h:10-30`) and polling-path suppression on move/size/menu flags (`gameinput.cpp:1793-1816`, `1905`, `2039-2045`) are clean and well-tested. - **Minor docs note (`docs/gameinput.md:164-168`; `gameinput.cpp:1793-1825`):** Once a client-area `ClipCursor` has already settled with no active move/menu loop, Windows constrains the cursor inside the client rectangle so a user cannot reach the title bar or resize border to initiate an outside-client click. This change cleanly handles drags already in progress (e.g., activation drags or system-menu Move); clarifying the supported entry paths in `docs/gameinput.md` would set accurate expectations. Approve. AI-assisted review + local MSVC verification.
DadaCap commented 2026-11-28 08:06:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T08:06:18Z.


Merged into main (merge commit 766963e34), approved by DadaCap (maintainer). Thanks!

Checked before merging: Its new test gameinput_clip passes with main merged in, and the existing gameinput test still passes. The merge was pinned to the head commit that was tested (28829e0aa).

AI-assisted (Claude Code), posted for DadaCap.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7236365530 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2487#issuecomment-7236365530). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T08:06:18Z. --- Merged into `main` (merge commit 766963e34), approved by DadaCap (maintainer). Thanks! Checked before merging: Its new test `gameinput_clip` passes with main merged in, and the existing `gameinput` test still passes. The merge was pinned to the head commit that was tested (28829e0aa). _AI-assisted (Claude Code), posted for DadaCap._
OreoFR commented 2026-11-28 22:02:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:02:51Z.


Verified by OreoFR

  • Base: main 09c153948 + PR head 28829e0aa; integration package 6 of 6 (1 PR, merged without conflict)
  • Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests
  • Red on main: n/a (integration test; main baseline: xbox_present and d3d12_set_descriptor_heaps)
  • Green with the PR: ctest: only xbox_present and d3d12_set_descriptor_heaps fail, as on main; the new gameinput_clip test passes, with gameinput, gameinput_script, gameinput_host
  • Verdict: CLEAN PACKAGE (no new failure vs main)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246457691 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2487#issuecomment-7246457691). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T22:02:51Z. --- **Verified by OreoFR** - Base: main `09c153948` + PR head `28829e0aa`; integration package 6 of 6 (1 PR, merged without conflict) - Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests - Red on main: n/a (integration test; main baseline: xbox_present and d3d12_set_descriptor_heaps) - Green with the PR: ctest: only xbox_present and d3d12_set_descriptor_heaps fail, as on main; the new gameinput_clip test passes, with gameinput, gameinput_script, gameinput_host - Verdict: CLEAN PACKAGE (no new failure vs main) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
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
ProjectLeonida/mandy!2487
No description provided.