From 6d48fce76320a46ecdc5239493ba6dc0ff649244 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 15 Jul 2023 14:01:56 +0200 Subject: [PATCH] Fix mouse cursor setting on macOS to properly handle screen scale --- Source/Engine/Platform/Mac/MacPlatform.cpp | 7 ++++--- Source/Engine/Platform/Mac/MacWindow.cpp | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Platform/Mac/MacPlatform.cpp b/Source/Engine/Platform/Mac/MacPlatform.cpp index 04f928bba..15b526f02 100644 --- a/Source/Engine/Platform/Mac/MacPlatform.cpp +++ b/Source/Engine/Platform/Mac/MacPlatform.cpp @@ -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() diff --git a/Source/Engine/Platform/Mac/MacWindow.cpp b/Source/Engine/Platform/Mac/MacWindow.cpp index 90bb07279..c55f36c7c 100644 --- a/Source/Engine/Platform/Mac/MacWindow.cpp +++ b/Source/Engine/Platform/Mac/MacWindow.cpp @@ -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 }