Fix mouse cursor setting on macOS to properly handle screen scale

This commit is contained in:
Wojtek Figat
2023-07-15 14:01:56 +02:00
parent 84c99ea1c3
commit 6d48fce763
2 changed files with 4 additions and 4 deletions

View File

@@ -301,15 +301,16 @@ Float2 MacPlatform::GetMousePosition()
CGEventRef event = CGEventCreate(nullptr);
CGPoint cursor = CGEventGetLocation(event);
CFRelease(event);
return Float2((float)cursor.x, (float)cursor.y);
return Float2((float)cursor.x, (float)cursor.y) * MacPlatform::ScreenScale;
}
void MacPlatform::SetMousePosition(const Float2& pos)
{
CGPoint cursor;
cursor.x = (CGFloat)pos.X;
cursor.y = (CGFloat)pos.Y;
cursor.x = (CGFloat)(pos.X / MacPlatform::ScreenScale);
cursor.y = (CGFloat)(pos.Y / MacPlatform::ScreenScale);
CGWarpMouseCursorPosition(cursor);
CGAssociateMouseAndMouseCursorPosition(true);
}
Float2 MacPlatform::GetDesktopSize()

View File

@@ -643,7 +643,6 @@ MacWindow::MacWindow(const CreateWindowSettings& settings)
// TODO: impl StartPosition for MacWindow
// TODO: impl Fullscreen for MacWindow
// TODO: impl ShowInTaskbar for MacWindow
// TODO: impl AllowInput for MacWindow
// TODO: impl IsTopmost for MacWindow
}