diff --git a/DynamicIsland/DynamicIslandApp.swift b/DynamicIsland/DynamicIslandApp.swift index ba00b70..0cac7ea 100644 --- a/DynamicIsland/DynamicIslandApp.swift +++ b/DynamicIsland/DynamicIslandApp.swift @@ -156,6 +156,16 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func applicationWillTerminate(_ notification: Notification) { + let userInfo: [String: Any] = [ + AtollDistributedNotifications.UserInfoKey.sourcePID: NSNumber(value: ProcessInfo.processInfo.processIdentifier) + ] + DistributedNotificationCenter.default().postNotificationName( + AtollDistributedNotifications.didBecomeIdle, + object: nil, + userInfo: userInfo, + deliverImmediately: true + ) + // Cancel any pending window size updates windowSizeUpdateWorkItem?.cancel() NotificationCenter.default.removeObserver(self) @@ -393,6 +403,16 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func applicationDidFinishLaunching(_ notification: Notification) { + let userInfo: [String: Any] = [ + AtollDistributedNotifications.UserInfoKey.sourcePID: NSNumber(value: ProcessInfo.processInfo.processIdentifier) + ] + DistributedNotificationCenter.default().postNotificationName( + AtollDistributedNotifications.didBecomeActive, + object: nil, + userInfo: userInfo, + deliverImmediately: true + ) + LockScreenLiveActivityWindowManager.shared.configure(viewModel: vm) LockScreenManager.shared.configure(viewModel: vm) extensionXPCServiceHost.start() diff --git a/DynamicIsland/services/Extensions/AtollDistributedNotifications.swift b/DynamicIsland/services/Extensions/AtollDistributedNotifications.swift new file mode 100644 index 0000000..fda5463 --- /dev/null +++ b/DynamicIsland/services/Extensions/AtollDistributedNotifications.swift @@ -0,0 +1,20 @@ +/* + * Atoll (DynamicIsland) + * Copyright (C) 2024-2026 Atoll Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + */ + +import Foundation + +enum AtollDistributedNotifications { + static let didBecomeActive = Notification.Name("com.ebullioscopic.Atoll.lifecycle.didBecomeActive") + static let didBecomeIdle = Notification.Name("com.ebullioscopic.Atoll.lifecycle.didBecomeIdle") + + enum UserInfoKey { + static let sourcePID = "sourcePID" + } +}