From bbac90c85901f9b15afa12075024d11860cd4330 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Mon, 19 Nov 2018 11:31:03 +0200 Subject: [PATCH] [macOS] Change runtime OS version checks to allow build with MacOS 10.9 SDK, --- platform/osx/os_osx.mm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 8123aaa4270..e7b3e35381a 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -76,6 +76,13 @@ #define NSWindowStyleMaskBorderless NSBorderlessWindowMask #endif +#ifndef NSAppKitVersionNumber10_12 +#define NSAppKitVersionNumber10_12 1504 +#endif +#ifndef NSAppKitVersionNumber10_14 +#define NSAppKitVersionNumber10_14 1671 +#endif + static void get_key_modifier_state(unsigned int p_osx_state, Ref state) { state->set_shift((p_osx_state & NSEventModifierFlagShift)); @@ -1237,7 +1244,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a ERR_FAIL_COND_V(window_object == nil, ERR_UNAVAILABLE); window_view = [[GodotContentView alloc] init]; - if (@available(macOS 10.14, *)) { + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14) { [window_view setWantsLayer:TRUE]; } @@ -1472,7 +1479,7 @@ public: switch (p_type) { case ERR_WARNING: - if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) { + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_12) { os_log_info(OS_LOG_DEFAULT, "WARNING: %{public}s: %{public}s\nAt: %{public}s:%i.", p_function, err_details, p_file, p_line); @@ -1482,7 +1489,7 @@ public: logf_error("\E[0;33m At: %s:%i.\E[0m\n", p_file, p_line); break; case ERR_SCRIPT: - if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) { + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_12) { os_log_error(OS_LOG_DEFAULT, "SCRIPT ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.", p_function, err_details, p_file, p_line); @@ -1492,7 +1499,7 @@ public: logf_error("\E[0;35m At: %s:%i.\E[0m\n", p_file, p_line); break; case ERR_SHADER: - if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) { + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_12) { os_log_error(OS_LOG_DEFAULT, "SHADER ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.", p_function, err_details, p_file, p_line); @@ -1503,7 +1510,7 @@ public: break; case ERR_ERROR: default: - if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) { + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_12) { os_log_error(OS_LOG_DEFAULT, "ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.", p_function, err_details, p_file, p_line); @@ -2174,11 +2181,7 @@ void OS_OSX::set_window_size(const Size2 p_size) { if (menuBarHeight != 0.f) { size.y += menuBarHeight; } else { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_12) { -#else - { -#endif size.y += [[NSStatusBar systemStatusBar] thickness]; } }