Skip to content

Commit cdd71b5

Browse files
authored
Automatic Window Deminimization on Dock Icon Click (#1907)
1 parent cb2fdb2 commit cdd71b5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

CodeEdit/AppDelegate.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
6969
}
7070

7171
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
72-
if flag {
72+
guard flag else {
73+
handleOpen()
7374
return false
7475
}
7576

76-
handleOpen()
77-
77+
/// Check if all windows are either miniaturized or not visible.
78+
/// If so, attempt to find the first miniaturized window and deminiaturize it.
79+
guard sender.windows.allSatisfy({ $0.isMiniaturized || !$0.isVisible }) else { return false }
80+
sender.windows.first(where: { $0.isMiniaturized })?.deminiaturize(sender)
7881
return false
7982
}
8083

0 commit comments

Comments
 (0)