Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Jan 25, 2026

This changes makes the Cursor Capture opt-in to prevent capture in GUIEdit.

TODO

  • Replicate in Generals

@xezon xezon added Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker Tools Affects Tools only ThisProject The issue was introduced by this project, or this task is specific to this project labels Jan 25, 2026
@ElTioRata
Copy link

Works as intended. Cursor is free!

@xezon
Copy link
Author

xezon commented Jan 26, 2026

@greptileai

@greptile-apps
Copy link

greptile-apps bot commented Jan 26, 2026

Greptile Overview

Greptile Summary

This PR makes cursor capture opt-in by requiring explicit initCapture() call, preventing unwanted capture in GUIEdit tool. The change moves initCapture() from protected to public API and requires it to be called explicitly after Mouse::init().

Key changes:

  • Mouse::initCapture() moved from protected to public API
  • Default m_cursorCaptureMode changed from CursorCaptureMode_Default to 0 (disabled)
  • initCapture() call removed from Mouse::init() (automatic) and added to GameClient::init() (explicit)
  • GUIEdit tool calls only Mouse::init() without initCapture(), so cursor capture remains disabled

Impact:

  • Game client explicitly enables cursor capture via TheMouse->initCapture()
  • GUIEdit tool keeps cursor free since it never calls initCapture()
  • No behavioral change for the game, only affects tools that don't need capture

Confidence Score: 5/5

  • safe to merge with no risks identified
  • the change is well-contained, follows a clear opt-in pattern, applies the same logic consistently across both Generals and GeneralsMD codebases, and solves the stated problem without introducing side effects
  • No files require special attention

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Include/GameClient/Mouse.h moved initCapture() from protected to public API to enable explicit initialization
Generals/Code/GameEngine/Source/GameClient/Input/Mouse.cpp set default m_cursorCaptureMode to 0 and removed automatic initCapture() call from init()
Generals/Code/GameEngine/Source/GameClient/GameClient.cpp added explicit initCapture() call after init() in game client initialization
GeneralsMD/Code/GameEngine/Include/GameClient/Mouse.h moved initCapture() from protected to public API to enable explicit initialization
GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cpp set default m_cursorCaptureMode to 0 and removed automatic initCapture() call from init()
GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp added explicit initCapture() call after init() in game client initialization

Sequence Diagram

sequenceDiagram
    participant GC as GameClient::init()
    participant M as Mouse
    participant CB as CaptureBlock

    Note over GC: Game Client Initialization
    GC->>M: init()
    activate M
    Note over M: m_cursorCaptureMode = 0<br/>(capture disabled by default)
    Note over M: m_captureBlockReasonBits<br/>has NoInit bit set
    M-->>GC: initialized
    deactivate M
    
    GC->>M: initCapture()
    activate M
    M->>CB: unblockCapture(NoInit)
    Note over M: Reads prefs.getCursorCaptureMode()
    Note over M: m_cursorCaptureMode = user prefs
    Note over M: Clears NoInit block bit
    M-->>GC: capture enabled
    deactivate M

    Note over GC: Cursor capture now active

    participant GE as GUIEdit::initEditor()
    participant M2 as Mouse (GUIEdit)

    Note over GE: GUIEdit Tool Initialization
    GE->>M2: init()
    activate M2
    Note over M2: m_cursorCaptureMode = 0<br/>(capture disabled)
    Note over M2: m_captureBlockReasonBits<br/>has NoInit bit set
    M2-->>GE: initialized
    deactivate M2
    
    Note over GE: NO initCapture() call
    Note over M2: Cursor remains free<br/>(NoInit bit blocks capture)
Loading

Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@xezon
Copy link
Author

xezon commented Jan 27, 2026

Replicated in Generals without conflicts

@xezon xezon merged commit 64d9b08 into TheSuperHackers:main Jan 28, 2026
25 checks passed
@xezon xezon deleted the xezon/fix-mouse-capture-in-tools branch January 28, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project Tools Affects Tools only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor stuck inside GUIEdit workspace

3 participants