Clicking dock icon when minimized does not restore window
AngeloStavrow opened this issue · 5 comments
I've asked about this in a couple of Slack groups, here are my findings so far.
(This work can be found in the restore-window-when-clicking-dock-icon
branch of the repo.)
Adding a @NSApplicationDelegateAdaptor
and pointing it to a class that conforms to NSApplicationDelegate and implements applicationShouldHandleReopen(_:hasVisibleWindows:)
gets the deminiaturize-minimized-window behaviour working if I ensure that this file is the delegate for NSApplication (apparently, that's not necessarily true just from setting the delegate adaptor property wrapper) — but then the reopen-closed-windows behaviour stops working, as does the Settings Scene that opens the app's preferences window (the menu item is disabled).
So right now, we can either have the reopen-closed-window behaviour and the preferences window working, or we can have the deminiaturize-minimized-window behaviour working. I'll dig a bit further, but I'm removing the 1.0 milestone from this issue because while it's what a good macOS app-citizen does, it's not a launch blocker and we have more important work to do here.
I used NSApp.hide instead of starting the finder. Maybe this also works in your case.
Hey @KHKnobl, sorry for not replying sooner — I didn't see this until now! Would you have a sample implementation you can share?
I took over your solution and just changed:
func applicationDidChangeOcclusionState(_ notification: Notification) {
print("💬 Fired:", #function)
if let window = NSApp.windows.first, window.isMiniaturized {
NSApp.hide(self)
}
}
That works great, thanks!