diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dda58905..50e712fad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,12 +162,26 @@ if (UNIX) if (APPLE) set (CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS} -DGTEST_USE_OWN_TR1_TUPLE=1") + if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) + set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0) + endif() + + if(CMAKE_OSX_DEPLOYMENT_TARGET GREATER_EQUAL 11.0) + set(SYNERGY_OSX_DEPLOYMENT_TARGET 1100) + elseif(CMAKE_OSX_DEPLOYMENT_TARGET GREATER_EQUAL 10.15) + set(SYNERGY_OSX_DEPLOYMENT_TARGET 1015) + elseif(CMAKE_OSX_DEPLOYMENT_TARGET GREATER_EQUAL 10.14) + set(SYNERGY_OSX_DEPLOYMENT_TARGET 1014) + else() + set(SYNERGY_OSX_DEPLOYMENT_TARGET 1013) + endif() + add_compile_definitions(OSX_DEPLOYMENT_TARGET=${SYNERGY_OSX_DEPLOYMENT_TARGET}) + find_library (lib_ScreenSaver ScreenSaver) find_library (lib_IOKit IOKit) find_library (lib_ApplicationServices ApplicationServices) find_library (lib_Foundation Foundation) find_library (lib_Carbon Carbon) - find_library (lib_UserNotifications UserNotifications) list (APPEND libs ${lib_ScreenSaver} @@ -175,9 +189,15 @@ if (UNIX) ${lib_ApplicationServices} ${lib_Foundation} ${lib_Carbon} - ${lib_UserNotifications} ) + if(SYNERGY_OSX_DEPLOYMENT_TARGET GREATER_EQUAL 1014) + find_library (lib_UserNotifications UserNotifications) + list (APPEND libs + ${lib_UserNotifications} + ) + endif() + else() # not-apple # add include dir for bsd (posix uses /usr/include/) diff --git a/ChangeLog b/ChangeLog index 1877cd0eb..4f35301ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ Bug fixes: - #7029 | #7033 Wrong encoding for text copied between linux and windows - #7015 Fix Windows service not starting up after sleep - #7036 Fix tray icon not changing theme on Big Sur +- #7046 Fix MacOS 10.13 build Enhancements: - #6998 Remove functionality related to the screen saver synchronisation diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2a2342997..3a829137c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -80,13 +80,13 @@ jobs: catalina-std: image: macOS-10.15 platform: x86-64 - version: 10.13 + version: 10.14 buildType: "standard" prefix: "synergy" catalina-ent: image: macOS-10.15 platform: x86-64 - version: 10.13 + version: 10.14 buildType: "enterprise" prefix: "synergy-enterprise" pool: diff --git a/src/gui/src/AppDelegate.h b/src/gui/src/AppDelegate.h index fa1e09c7b..81b50720c 100644 --- a/src/gui/src/AppDelegate.h +++ b/src/gui/src/AppDelegate.h @@ -5,9 +5,12 @@ extern "C" { #endif #import +#if OSX_DEPLOYMENT_TARGET >= 1014 #import - @interface AppDelegate : NSObject +#else +@interface AppDelegate : NSObject +#endif @end diff --git a/src/gui/src/AppDelegate.mm b/src/gui/src/AppDelegate.mm index 7c994dba8..04cdcf3a1 100644 --- a/src/gui/src/AppDelegate.mm +++ b/src/gui/src/AppDelegate.mm @@ -12,13 +12,16 @@ -(void)applicationDidFinishLaunching:(NSNotification *)aNotification { [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self]; +#if OSX_DEPLOYMENT_TARGET >= 1014 [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self]; +#endif } -(BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification{ return YES; } +#if OSX_DEPLOYMENT_TARGET >= 1014 -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{ @@ -29,5 +32,6 @@ completionHandler(presentationOptions); } +#endif @end diff --git a/src/gui/src/OSXHelpers.mm b/src/gui/src/OSXHelpers.mm index a5fde23f6..0c98afc16 100644 --- a/src/gui/src/OSXHelpers.mm +++ b/src/gui/src/OSXHelpers.mm @@ -29,23 +29,22 @@ void requestOSXNotificationPermission() { - if (@available(macOS 10.14, *)) +#if OSX_DEPLOYMENT_TARGET >= 1014 + if (isOSXDevelopmentBuild()) { - if (isOSXDevelopmentBuild()) - { - qWarning("Not requesting notification permission in dev build"); - return; - } - - UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; - [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound) - completionHandler:^(BOOL granted, NSError * _Nullable error) { - if(error != nil) - { - qWarning("Notification permission request error: %s", [[NSString stringWithFormat:@"%@", error] UTF8String]); - } - }]; + qWarning("Not requesting notification permission in dev build"); + return; } + + UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; + [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound) + completionHandler:^(BOOL granted, NSError * _Nullable error) { + if(error != nil) + { + qWarning("Notification permission request error: %s", [[NSString stringWithFormat:@"%@", error] UTF8String]); + } + }]; +#endif } bool @@ -58,44 +57,41 @@ isOSXDevelopmentBuild() bool showOSXNotification(const QString& title, const QString& body) { - if (@available(macOS 10.14, *)) +#if OSX_DEPLOYMENT_TARGET >= 1014 + // accessing notification center on unsigned build causes an immidiate + // application shutodown (in this case synergys) and cannot be caught + // to avoid issues with it need to first check if this is a dev build + if (isOSXDevelopmentBuild()) { - // accessing notification center on unsigned build causes an immidiate - // application shutodown (in this case synergys) and cannot be caught - // to avoid issues with it need to first check if this is a dev build - if (isOSXDevelopmentBuild()) - { - qWarning("Not showing notification in dev build"); - return false; - } - - requestOSXNotificationPermission(); - - UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; - - UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; - content.title = title.toNSString(); - content.body = body.toNSString(); - - // Create the request object. - UNNotificationRequest* request = [UNNotificationRequest - requestWithIdentifier:@"SecureInput" content:content trigger:nil]; - - [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) { - if (error != nil) { - qWarning("Notification display request error: %s", [[NSString stringWithFormat:@"%@", error] UTF8String]); - } - }]; - } - else - { - NSUserNotification* notification = [[NSUserNotification alloc] init]; - notification.title = title.toNSString(); - notification.informativeText = body.toNSString(); - notification.soundName = NSUserNotificationDefaultSoundName; //Will play a default sound - [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notification]; - [notification autorelease]; + qWarning("Not showing notification in dev build"); + return false; } + + requestOSXNotificationPermission(); + + UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; + + UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; + content.title = title.toNSString(); + content.body = body.toNSString(); + + // Create the request object. + UNNotificationRequest* request = [UNNotificationRequest + requestWithIdentifier:@"SecureInput" content:content trigger:nil]; + + [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) { + if (error != nil) { + qWarning("Notification display request error: %s", [[NSString stringWithFormat:@"%@", error] UTF8String]); + } + }]; +#else + NSUserNotification* notification = [[NSUserNotification alloc] init]; + notification.title = title.toNSString(); + notification.informativeText = body.toNSString(); + notification.soundName = NSUserNotificationDefaultSoundName; //Will play a default sound + [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notification]; + [notification autorelease]; +#endif return true; }