Calculate the mouse focus inverse transform only when needed #69598
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.
Revival of #49158
Supersedes #49158
fix #69593
Co-authored-by: Marcel Admiraal madmiraal@users.noreply.github.com
madmiraal did the heavy lifting, I just fixed merge conflicts.
Orignal description:
Currently,
gui.focus_inv_xform
is used to determine the location of an event within aControl
.Viewport::_gui_find_control()
has the side-effect of updatinggui.focus_inv_xform
. This would be fineif _gui_find_control()
was just used to assigngui.mouse_focus
, but it's not. The result is, when a mouse button release event happens, sometimesgui.focus_inv_xform
does not provide the location of the event inside the Control where the mouse button press event happened.Instead of calculating the
mouse_focus
'sControl
's inverse transform every time_gui_find_control()
is called and storing the result for later use, this PR calculates the required inverse transform only when it is needed. This will not only prevent the wrong inverse transform sometimes being used, but should result in better performance too.Edited 2023-01-09: Fix merge conflict