# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1592286382 0 # Node ID b71f46cd58b9ba83e36a35c26e758583452b52d2 # Parent 50196f67a1299be2d852acd4547febe8e515fc4c Mac: Implemented notification click callback pre-Mojave 10.14. diff -r 50196f67a129 -r b71f46cd58b9 mac/dw.m --- a/mac/dw.m Tue Jun 16 04:45:30 2020 +0000 +++ b/mac/dw.m Tue Jun 16 05:46:22 2020 +0000 @@ -1351,6 +1351,7 @@ -(void)applicationDidFinishLaunching:(NSNotification *)aNotification; #ifdef BUILDING_FOR_MOUNTAIN_LION -(BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification; +-(void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification; #endif @end @@ -1457,6 +1458,27 @@ { return YES; } +-(void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)usernotification +{ + NSScanner *objScanner = [NSScanner scannerWithString:usernotification.identifier]; + unsigned long long handle; + HWND notification; + + // Skip the dw-notification- prefix + [objScanner scanString:@"dw-notification-" intoString:nil]; + [objScanner scanUnsignedLongLong:&handle]; + notification = DW_UINT_TO_POINTER(handle); + + switch(usernotification.activationType) + { + case NSUserNotificationActivationTypeContentsClicked: + _event_handler(notification, nil, 8); + break; + default: + break; + } + dw_signal_disconnect_by_window(notification); +} #endif @end @@ -10862,6 +10884,8 @@ #ifdef BUILDING_FOR_MOUNTAIN_LION if(notification) { + NSString *notid = [NSString stringWithFormat:@"dw-notification-%llu", (unsigned long long)notification]; + #ifdef BUILDING_FOR_MOJAVE // Schedule the notification. if (@available(macOS 10.14, *)) @@ -10869,7 +10893,6 @@ if([[NSBundle mainBundle] bundleIdentifier] != nil) { UNMutableNotificationContent* content = (UNMutableNotificationContent *)notification; - NSString *notid = [NSString stringWithFormat:@"dw-notification-%llu", (unsigned long long)notification]; UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:notid content:content trigger:nil]; UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; @@ -10880,7 +10903,9 @@ #endif { // Fallback on earlier versions - [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]; + NSUserNotification *request = (NSUserNotification *)notification; + request.identifier = notid; + [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:request]; } return DW_ERROR_NONE; }