Skip to content

Commit

Permalink
Check for key window first
Browse files Browse the repository at this point in the history
  • Loading branch information
lukakerr committed Mar 10, 2019
1 parent c099e62 commit 2471fdd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Pine/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
completionHandler: { _,_,_ in }
)
}

Utils.getCurrentMainWindowController()?.window?.makeKeyAndOrderFront(nil)
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Pine/Helpers/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class Utils {

/// The current main window controller of the application
public static func getCurrentMainWindowController() -> PineWindowController? {
if let keyWindow = NSApp.keyWindow, keyWindow.isVisible {
return keyWindow.windowController as? PineWindowController
}

return NSApp.windows.filter({ $0.isVisible }).first?.windowController as? PineWindowController
}

Expand Down

0 comments on commit 2471fdd

Please sign in to comment.