Merge branch 'fix-ui-issues' of git://github.com/stefnotch/FlaxEngine into stefnotch-fix-ui-issues

This commit is contained in:
Wojtek Figat
2021-02-15 10:22:55 +01:00
3 changed files with 14 additions and 7 deletions

View File

@@ -479,6 +479,10 @@ void WindowsWindow::StartTrackingMouse(bool useMouseScreenOffset)
_trackingMouseOffset = Vector2::Zero;
_isUsingMouseOffset = useMouseScreenOffset;
int32 x = 0 , y = 0, width = 0, height = 0;
GetScreenInfo(x, y, width, height);
_mouseOffsetScreenSize = Rectangle(x, y, width, height);
SetCapture(_handle);
}
}
@@ -712,18 +716,20 @@ LRESULT WindowsWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (_isTrackingMouse && _isUsingMouseOffset)
{
// Check if move mouse to another edge of the desktop
Vector2 destopSize = Platform::GetVirtualDesktopSize();
Vector2 desktopLocation = _mouseOffsetScreenSize.Location;
Vector2 destopSize = _mouseOffsetScreenSize.GetBottomRight();
const Vector2 mousePos(static_cast<float>(WINDOWS_GET_X_LPARAM(lParam)), static_cast<float>(WINDOWS_GET_Y_LPARAM(lParam)));
Vector2 mousePosition = ClientToScreen(mousePos);
Vector2 newMousePosition = mousePosition;
if (mousePosition.X <= 1)
if (mousePosition.X <= desktopLocation.X + 2)
newMousePosition.X = destopSize.X - 2;
else if (mousePosition.X >= destopSize.X - 1)
newMousePosition.X = 2;
if (mousePosition.Y <= 1)
newMousePosition.X = desktopLocation.X + 2;
if (mousePosition.Y <= desktopLocation.Y + 2)
newMousePosition.Y = destopSize.Y - 2;
else if (mousePosition.Y >= destopSize.Y - 1)
newMousePosition.Y = 2;
newMousePosition.Y = desktopLocation.Y + 2;
if (!Vector2::NearEqual(mousePosition, newMousePosition))
{
_trackingMouseOffset -= newMousePosition - mousePosition;