Standalone Game (Windowed) GetMousePosition returns wrong values

I just noticed, that with 4.12 Preview my canvas-UI behaves a little weird when starting my game in Standalone-Game-mode (Only in windowed mode, PIE works as usual) and after tracking it down a bit I found that with 4.12

UGameplayStatics::GetPlayerController(this, 0)->GetMousePosition(MousePos.X, MousePos.Y);

or alternatively (Both give me the same, changed results)

MousePos.X = GEngine->GameViewport->Viewport->GetMouseX();
MousePos.Y = GEngine->GameViewport->Viewport->GetMouseY();

returns different numbers than it did in 4.11. Those changed numbers seem to correlate with something else I noticed: The bounds of the mouse-capture seem to have changed. Whereas in 4.11 the mouse was captured only in the part of the window that shows the actual game (the border of the window was outside of the capture-box), in 4.12 the mouse can now be moved over the window-border but at the bottom of the window there is a little part of the window where the mouse now can’t be moved to, which seems to be pretty much the height of the border that has been added at the top. The width has a similar problem, but here the mouse can now actually be moved outside the window.

This means that the top left when using GetMousePosition is now above the border and at the bottom right there is a small portion of screen where it will return (0|0) as if the mouse was not hovering above the viewport.

It’s a little hard to show since I seem to not be able to screenshot my cursor, but still, maybe it helps :slight_smile: Just believe me when I say: In both screenshots, the cursor is in pretty much in the same position, in the bottom right of the window.

This is with 4.11 (The cursor is within the window and thus gives me the proper values):
http://puu.sh/oZjVJ/febed20a19.jpg

With 4.12 (The cursor is still within the window, but this time around UE4 thinks it’s not)
http://puu.sh/oZk27/36915c444d.jpg

That’s good news :slight_smile: Thank you for letting me know!

Hey,

This was a temporary regression in 4.12 on Windows, and should already be fixed in the latest 4.12 from GitHub.

Your assessment is correct. The regression started treating 0,0 as the top-left of the window rather than the top-left of the client area; this caused some issues with mouse input, but only affected windows with an OS border.

Thanks.