Editor updates mouse position while game widget is unfocused#10319
Open
aidencurtis wants to merge 2 commits intoFacepunch:masterfrom
Open
Editor updates mouse position while game widget is unfocused#10319aidencurtis wants to merge 2 commits intoFacepunch:masterfrom
aidencurtis wants to merge 2 commits intoFacepunch:masterfrom
Conversation
1a9d2bf to
2756f30
Compare
2756f30 to
0fee600
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Thanks for contributing to s&box ❤️
Please fill out the sections below to help us review your change efficiently.
Summary
Bottom line: Fixes undesired behaviour when game widget is unfocused in editor.
Motivation & Context
Fixes: #10261
As someone developing a point and click game who wants to iterate between IDE / Terminal and s&box, this is a very annoying issue. Every single re-focus click is moving my character somewhere my mouse is not hovering (usually at the border of the screen). This will greatly improve my developer experience while working on games for the engine.
Implementation Details
While in editor and in play mode, the game widget can be unfocused (editor is unfocused, or interacting with editor panels). In this state, SDL stops reporting mouse positions, so the engine loses track of the cursor while it's hovering over the game widget.
To fix this, GameMode now enables MouseTracking and subscribes to the MouseMove event. When a move is received while the widget is unfocused, it calls InputRouter::OnMousePositionChange with the widget-local cursor position and a computed delta, keeping the mouse state in sync using the same path as native input.
InputRouter::OnMousePositionChange itself is also cleaned up. Position is now set before the relative-mode and capturechecks, and delta accumulation is skipped during mouse capture. GetRelativeMouseMode() is respected, zeroing the delta, which is consistent with pre-existing behaviour.
I've tested this in-editor, in-game, with mouse enabled, disabled, unfocused, in split view, scene view, within prefabs, etc. and can't seem to find any regressions.
Screenshots / Videos (if applicable)
Checklist