comparison mac/dw.m @ 2150:be4547734f0b

Mac: Remove the old notification center when building for Big Sur 11.0. This means apps built for Big Sur will not generate notifications when run on macOS prior to Mojave (10.14). If you need this support build for Mojave or Catalina (10.15).
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 10 Sep 2020 23:58:33 +0000
parents c08e03168a9e
children 467401a1ca69
comparison
equal deleted inserted replaced
2149:c08e03168a9e 2150:be4547734f0b
1360 <NSApplicationDelegate> 1360 <NSApplicationDelegate>
1361 #endif 1361 #endif
1362 { 1362 {
1363 } 1363 }
1364 -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; 1364 -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
1365 #ifdef BUILDING_FOR_MOUNTAIN_LION 1365 #if defined(BUILDING_FOR_MOUNTAIN_LION) && !defined(BUILDING_FOR_BIG_SUR)
1366 -(void)applicationDidFinishLaunching:(NSNotification *)aNotification; 1366 -(void)applicationDidFinishLaunching:(NSNotification *)aNotification;
1367 -(BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification; 1367 -(BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification;
1368 -(void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification; 1368 -(void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification;
1369 #endif 1369 #endif
1370 @end 1370 @end
1451 { 1451 {
1452 if(_event_handler(sender, nil, 6) > 0) 1452 if(_event_handler(sender, nil, 6) > 0)
1453 return NSTerminateCancel; 1453 return NSTerminateCancel;
1454 return NSTerminateNow; 1454 return NSTerminateNow;
1455 } 1455 }
1456 #ifdef BUILDING_FOR_MOUNTAIN_LION 1456 #if defined(BUILDING_FOR_MOUNTAIN_LION) && !defined(BUILDING_FOR_BIG_SUR)
1457 -(void)applicationDidFinishLaunching:(NSNotification *)aNotification 1457 -(void)applicationDidFinishLaunching:(NSNotification *)aNotification
1458 { 1458 {
1459 #ifdef BUILDING_FOR_MOJAVE 1459 #ifdef BUILDING_FOR_MOJAVE
1460 if (@available(macOS 10.14, *)) {} else 1460 if (@available(macOS 10.14, *)) {} else
1461 #endif 1461 #endif
10877 } 10877 }
10878 } 10878 }
10879 else 10879 else
10880 #endif 10880 #endif
10881 { 10881 {
10882 #ifndef BUILDING_FOR_BIG_SUR
10882 // Fallback on earlier versions 10883 // Fallback on earlier versions
10883 NSUserNotification *notification = [[NSUserNotification alloc] init]; 10884 NSUserNotification *notification = [[NSUserNotification alloc] init];
10884 10885
10885 if(notification) 10886 if(notification)
10886 { 10887 {
10888 notification.informativeText = [NSString stringWithUTF8String:outbuf]; 10889 notification.informativeText = [NSString stringWithUTF8String:outbuf];
10889 if(imagepath) 10890 if(imagepath)
10890 notification.contentImage = [[NSImage alloc] initWithContentsOfFile:[NSString stringWithUTF8String:imagepath]]; 10891 notification.contentImage = [[NSImage alloc] initWithContentsOfFile:[NSString stringWithUTF8String:imagepath]];
10891 retval = notification; 10892 retval = notification;
10892 } 10893 }
10894 #endif
10893 } 10895 }
10894 return retval; 10896 return retval;
10895 #else 10897 #else
10896 return NULL; 10898 return NULL;
10897 #endif 10899 #endif
10925 } 10927 }
10926 } 10928 }
10927 else 10929 else
10928 #endif 10930 #endif
10929 { 10931 {
10932 #ifndef BUILDING_FOR_BIG_SUR
10930 // Fallback on earlier versions 10933 // Fallback on earlier versions
10931 NSUserNotification *request = (NSUserNotification *)notification; 10934 NSUserNotification *request = (NSUserNotification *)notification;
10932 request.identifier = notid; 10935 request.identifier = notid;
10933 [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:request]; 10936 [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:request];
10937 #endif
10934 } 10938 }
10935 return DW_ERROR_NONE; 10939 return DW_ERROR_NONE;
10936 } 10940 }
10937 #endif 10941 #endif
10938 return DW_ERROR_UNKNOWN; 10942 return DW_ERROR_UNKNOWN;