Skip to content

Commit

Permalink
fix: closing alttab windows gives focus to previous app (closes lwoui…
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Aug 30, 2024
1 parent e890a60 commit 0e6f200
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/api-wrappers/HelperExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,11 @@ extension Optional where Wrapped == String {
return (self ?? "").localizedStandardCompare(string ?? "")
}
}

extension NSWindow {
func hideAppIfLastWindowIsClosed() {
if (!NSApp.windows.contains { $0.isVisible && $0.className != "NSStatusBarWindow" && $0.windowNumber != windowNumber}) {
App.shared.hide(nil)
}
}
}
5 changes: 5 additions & 0 deletions src/ui/FeedbackWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,9 @@ class FeedbackWindow: NSWindow {
}
return result
}

override func close() {
hideAppIfLastWindowIsClosed()
super.close()
}
}
5 changes: 5 additions & 0 deletions src/ui/preferences-window/PreferencesWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@ class PreferencesWindow: NSWindow, NSToolbarDelegate {
func toolbarSelectableItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return Array(toolbarItems.keys)
}

override func close() {
hideAppIfLastWindowIsClosed()
super.close()
}
}

0 comments on commit 0e6f200

Please sign in to comment.