← All repositories

listless

A simple list app for Apple platforms

git clone https://code.inqk.net/listless.git


commit 578be3c28aa16d0b69444ce30ab08ef437a1228e
parent 853143d75c5a54671f5ca588a72dc872b8597835
Author: Michael Camilleri <[email protected]>
Date:   Sun, 19 Apr 2026 08:43:13 +0900

Set default launch policy to `.accessory` in macOS version

This commit is a further step in preventing Listless from launching upon
receipt of a CloudKit sync notification. Continued investigation has
suggested that the problem is that the app is always lauching with an
activation policy of `.regular`. It seems that the better approach is to
launch by default as `.accessory` and only promote to `.regular` when
there is evidence of explicit user intent to launch the app.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

Diffstat

MListlessMac/ListlessMacApp.swift | 16+++++++++++++---

1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/ListlessMac/ListlessMacApp.swift b/ListlessMac/ListlessMacApp.swift

@@ -45,16 +45,26 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
         applyAppearanceMode(UserDefaults.standard.integer(forKey: Self.appearanceModeKey))
         keyValueSyncBridge.start()
         installMainMenu()
-        openNewWindow()
+    }
+
+    func applicationDidBecomeActive(_ notification: Notification) {
+        promoteAndShowWindowIfNeeded()
     }
 
     func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
         if !flag {
-            openNewWindow()
+            promoteAndShowWindowIfNeeded()
         }
         return true
     }
 
+    private func promoteAndShowWindowIfNeeded() {
+        NSApp.setActivationPolicy(.regular)
+        if !NSApp.windows.contains(where: { $0.isVisible }) {
+            openNewWindow()
+        }
+    }
+
     func applicationDidUnhide(_ notification: Notification) {
         NSApp.keyWindow?.makeFirstResponder(nil)
     }
@@ -442,7 +452,7 @@ enum ListlessMacMain {
     static func main() {
         let app = NSApplication.shared
         let delegate = AppDelegate()
-        app.setActivationPolicy(.regular)
+        app.setActivationPolicy(.accessory)
         app.delegate = delegate
         withExtendedLifetime(delegate) {
             app.run()