From dd87dc7046a369f99358647ca7f3c59b81ecc2f2 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 8 Feb 2023 13:51:56 +0100 Subject: [PATCH] fix: Building on macOS --- lib/libimhex/include/hex/helpers/utils_macos.hpp | 9 ++++++--- lib/libimhex/source/helpers/utils_macos.m | 5 +++++ main/source/init/splash_window.cpp | 6 +----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/libimhex/include/hex/helpers/utils_macos.hpp b/lib/libimhex/include/hex/helpers/utils_macos.hpp index b5ae40345..81e88a0f7 100644 --- a/lib/libimhex/include/hex/helpers/utils_macos.hpp +++ b/lib/libimhex/include/hex/helpers/utils_macos.hpp @@ -2,9 +2,12 @@ #if defined(OS_MACOS) - #include + extern "C" { - extern "C" void openWebpageMacos(const char *url); - extern "C" bool isMacosSystemDarkModeEnabled(); + void openWebpageMacos(const char *url); + bool isMacosSystemDarkModeEnabled(); + float getBackingScaleFactorMacos(); + + } #endif \ No newline at end of file diff --git a/lib/libimhex/source/helpers/utils_macos.m b/lib/libimhex/source/helpers/utils_macos.m index 81a068847..2bd39a463 100644 --- a/lib/libimhex/source/helpers/utils_macos.m +++ b/lib/libimhex/source/helpers/utils_macos.m @@ -4,6 +4,7 @@ #include #include #include + #include #include #include @@ -25,4 +26,8 @@ } } + float getBackingScaleFactorMacos(void) { + return [[NSScreen mainScreen] backingScaleFactor]; + } + #endif diff --git a/main/source/init/splash_window.cpp b/main/source/init/splash_window.cpp index 863664712..d74824acb 100644 --- a/main/source/init/splash_window.cpp +++ b/main/source/init/splash_window.cpp @@ -22,10 +22,6 @@ #include #include -#if defined (OS_MACOS) - #include -#endif - using namespace std::literals::chrono_literals; namespace hex::init { @@ -209,7 +205,7 @@ namespace hex::init { meanScale = 1.0F; #if defined(OS_MACOS) - meanScale /= NSScreen.mainScreen.backingScaleFactor; + meanScale /= getBackingScaleFactorMacos(); #endif ImHexApi::System::impl::setGlobalScale(meanScale);