Skip to content

Commit 28c52fa

Browse files
committed
Add the Cocoa notification driver
Supported on macOS 10.14+ and iOS.
1 parent 47cab7d commit 28c52fa

5 files changed

Lines changed: 428 additions & 0 deletions

File tree

Xcode/SDL/SDL.xcodeproj/project.pbxproj

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
00D0D0D810675E46004B05EF /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 007317C10858E15000B2BC32 /* Carbon.framework */; platformFilters = (macos, ); };
5757
02D6A1C228A84B8F00A7F002 /* SDL_hidapi_sinput.c in Sources */ = {isa = PBXBuildFile; fileRef = 02D6A1C128A84B8F00A7F001 /* SDL_hidapi_sinput.c */; };
5858
1485C3312BBA4AF30063985B /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1485C32F2BBA4A0C0063985B /* UniformTypeIdentifiers.framework */; platformFilters = (maccatalyst, macos, ); settings = {ATTRIBUTES = (Weak, ); }; };
59+
30840D4C2F76A822000F1D1B /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30840D4B2F76A822000F1D1B /* UserNotifications.framework */; };
60+
30840D4E2F76A8E7000F1D1B /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30840D4D2F76A8E7000F1D1B /* Security.framework */; };
5961
557D0CFA254586CA003913E3 /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F37DC5F225350EBC0002E6F7 /* CoreHaptics.framework */; platformFilters = (ios, maccatalyst, macos, tvos, ); settings = {ATTRIBUTES = (Weak, ); }; };
6062
557D0CFB254586D7003913E3 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A75FDABD23E28B6200529352 /* GameController.framework */; settings = {ATTRIBUTES = (Required, ); }; };
6163
5616CA4C252BB2A6005D5928 /* SDL_url.c in Sources */ = {isa = PBXBuildFile; fileRef = 5616CA49252BB2A5005D5928 /* SDL_url.c */; };
@@ -560,6 +562,11 @@
560562
F3FD042E2C9B755700824C4C /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F3FD042C2C9B755700824C4C /* SDL_hidapi_nintendo.h */; };
561563
F3FD042F2C9B755700824C4C /* SDL_hidapi_steam_hori.c in Sources */ = {isa = PBXBuildFile; fileRef = F3FD042D2C9B755700824C4C /* SDL_hidapi_steam_hori.c */; };
562564
FA73671D19A540EF004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; platformFilters = (ios, maccatalyst, macos, tvos, ); settings = {ATTRIBUTES = (Required, ); }; };
565+
00009183ED11C92F23FC0000 /* SDL_notification.c in Sources */ = {isa = PBXBuildFile; fileRef = 000059D16599F687D87B0000 /* SDL_notification.c */; };
566+
0000B6DBAE1F178E87010000 /* SDL_notification_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 000045BF87FD2865AB1C0000 /* SDL_notification_c.h */; };
567+
0000FB5C9B8CE5929A250000 /* SDL_cocoanotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 000088B5AFB11E40F7920000 /* SDL_cocoanotification.m */; };
568+
0000AF1D2CED20010C2D0000 /* SDL_notificationevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0000D6CCB566B8AE47FE0000 /* SDL_notificationevents.c */; };
569+
00004A19C923458228C10000 /* SDL_notificationevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0000FA7334391F6720820000 /* SDL_notificationevents_c.h */; };
563570
/* End PBXBuildFile section */
564571

565572
/* Begin PBXContainerItemProxy section */
@@ -617,6 +624,8 @@
617624
00D0D08310675DD9004B05EF /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
618625
02D6A1C128A84B8F00A7F001 /* SDL_hidapi_sinput.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_sinput.c; sourceTree = "<group>"; };
619626
1485C32F2BBA4A0C0063985B /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; };
627+
30840D4B2F76A822000F1D1B /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
628+
30840D4D2F76A8E7000F1D1B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
620629
5616CA49252BB2A5005D5928 /* SDL_url.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_url.c; sourceTree = "<group>"; };
621630
5616CA4A252BB2A6005D5928 /* SDL_sysurl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysurl.h; sourceTree = "<group>"; };
622631
5616CA4B252BB2A6005D5928 /* SDL_sysurl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_sysurl.m; sourceTree = "<group>"; };
@@ -1154,6 +1163,11 @@
11541163
F59C710600D5CB5801000001 /* SDL.info */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SDL.info; sourceTree = "<group>"; };
11551164
F5A2EF3900C6A39A01000001 /* BUGS.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = BUGS.txt; path = ../../BUGS.txt; sourceTree = SOURCE_ROOT; };
11561165
FA73671C19A540EF004122E4 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; };
1166+
000059D16599F687D87B0000 /* SDL_notification.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_notification.c; path = SDL_notification.c; sourceTree = "<group>"; };
1167+
000045BF87FD2865AB1C0000 /* SDL_notification_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_notification_c.h; path = SDL_notification_c.h; sourceTree = "<group>"; };
1168+
000088B5AFB11E40F7920000 /* SDL_cocoanotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_cocoanotification.m; path = SDL_cocoanotification.m; sourceTree = "<group>"; };
1169+
0000D6CCB566B8AE47FE0000 /* SDL_notificationevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_notificationevents.c; path = SDL_notificationevents.c; sourceTree = "<group>"; };
1170+
0000FA7334391F6720820000 /* SDL_notificationevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_notificationevents_c.h; path = SDL_notificationevents_c.h; sourceTree = "<group>"; };
11571171
/* End PBXFileReference section */
11581172

11591173
/* Begin PBXFrameworksBuildPhase section */
@@ -1162,11 +1176,13 @@
11621176
buildActionMask = 2147483647;
11631177
files = (
11641178
1485C3312BBA4AF30063985B /* UniformTypeIdentifiers.framework in Frameworks */,
1179+
30840D4E2F76A8E7000F1D1B /* Security.framework in Frameworks */,
11651180
A7381E971D8B6A0300B177DD /* AudioToolbox.framework in Frameworks */,
11661181
00D0D0D810675E46004B05EF /* Carbon.framework in Frameworks */,
11671182
007317A40858DECD00B2BC32 /* Cocoa.framework in Frameworks */,
11681183
A7381E961D8B69D600B177DD /* CoreAudio.framework in Frameworks */,
11691184
557D0CFA254586CA003913E3 /* CoreHaptics.framework in Frameworks */,
1185+
30840D4C2F76A822000F1D1B /* UserNotifications.framework in Frameworks */,
11701186
00D0D08410675DD9004B05EF /* CoreFoundation.framework in Frameworks */,
11711187
FA73671D19A540EF004122E4 /* CoreVideo.framework in Frameworks */,
11721188
00CFA89D106B4BA100758660 /* ForceFeedback.framework in Frameworks */,
@@ -1431,6 +1447,7 @@
14311447
F3E5A6EA2AD5E0E600293D83 /* SDL_properties.c */,
14321448
F386F6E62884663E001840AA /* SDL_utils.c */,
14331449
F386F6E52884663E001840AA /* SDL_utils_c.h */,
1450+
0000A12B47E1FC5391780000 /* notification */,
14341451
);
14351452
name = "Library Source";
14361453
path = ../../src;
@@ -1460,6 +1477,8 @@
14601477
564624341FF821B70074AC87 /* Frameworks */ = {
14611478
isa = PBXGroup;
14621479
children = (
1480+
30840D4D2F76A8E7000F1D1B /* Security.framework */,
1481+
30840D4B2F76A822000F1D1B /* UserNotifications.framework */,
14631482
1485C32F2BBA4A0C0063985B /* UniformTypeIdentifiers.framework */,
14641483
F382339B2738ED6600F7F527 /* CoreBluetooth.framework */,
14651484
F376F7272559B77100CFC0BC /* CoreAudio.framework */,
@@ -2308,6 +2327,8 @@
23082327
A7D8A93723E2514000DCD162 /* SDL_touch_c.h */,
23092328
A7D8A92F23E2514000DCD162 /* SDL_windowevents.c */,
23102329
A7D8A94323E2514000DCD162 /* SDL_windowevents_c.h */,
2330+
0000D6CCB566B8AE47FE0000 /* SDL_notificationevents.c */,
2331+
0000FA7334391F6720820000 /* SDL_notificationevents_c.h */,
23112332
);
23122333
path = events;
23132334
sourceTree = "<group>";
@@ -2529,6 +2550,24 @@
25292550
path = resources;
25302551
sourceTree = "<group>";
25312552
};
2553+
0000A12B47E1FC5391780000 /* notification */ = {
2554+
isa = PBXGroup;
2555+
children = (
2556+
000059D16599F687D87B0000 /* SDL_notification.c */,
2557+
000045BF87FD2865AB1C0000 /* SDL_notification_c.h */,
2558+
0000B071CC4D6AB5CE640000 /* cocoa */,
2559+
);
2560+
path = notification;
2561+
sourceTree = "<group>";
2562+
};
2563+
0000B071CC4D6AB5CE640000 /* cocoa */ = {
2564+
isa = PBXGroup;
2565+
children = (
2566+
000088B5AFB11E40F7920000 /* SDL_cocoanotification.m */,
2567+
);
2568+
path = cocoa;
2569+
sourceTree = "<group>";
2570+
};
25322571
/* End PBXGroup section */
25332572

25342573
/* Begin PBXHeadersBuildPhase section */
@@ -3166,6 +3205,9 @@
31663205
0000A03C0F32C43816F40000 /* SDL_asyncio_windows_ioring.c in Sources */,
31673206
0000A877C7DB9FA935FC0000 /* SDL_uikitpen.m in Sources */,
31683207
63124A422E5C357500A53610 /* SDL_hidapi_zuiki.c in Sources */,
3208+
00009183ED11C92F23FC0000 /* SDL_notification.c in Sources */,
3209+
0000FB5C9B8CE5929A250000 /* SDL_cocoanotification.m in Sources */,
3210+
0000AF1D2CED20010C2D0000 /* SDL_notificationevents.c in Sources */,
31693211
);
31703212
runOnlyForDeploymentPostprocessing = 0;
31713213
};

src/SDL.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ bool SDL_InitSubSystem(SDL_InitFlags flags)
358358
SDL_DBus_Init();
359359
#endif
360360

361+
#ifdef SDL_PLATFORM_APPLE
362+
// Apple platforms require the notification delegate to be registered early.
363+
Cocoa_RegisterNotificationDelegate();
364+
#endif
365+
361366
#ifdef SDL_PLATFORM_WINDOWS
362367
if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) {
363368
if (!SDL_HelperWindowCreate()) {

src/notification/SDL_notification_c.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
extern SDL_NotificationID SDL_SYS_ShowNotification(SDL_PropertiesID props);
2828
extern void SDL_CleanupNotifications();
2929

30+
#ifdef SDL_PLATFORM_APPLE
31+
extern void Cocoa_RegisterNotificationDelegate();
32+
#endif
33+
3034
#ifdef SDL_VIDEO_DRIVER_WAYLAND
3135
extern const char *SDL_GetNotificationActivationToken();
3236
#endif

0 commit comments

Comments
 (0)