2024-04-30 23:38:49 +08:00
|
|
|
import Cocoa
|
|
|
|
|
import FlutterMacOS
|
2024-11-09 20:17:57 +08:00
|
|
|
import window_ext
|
2024-04-30 23:38:49 +08:00
|
|
|
|
2024-10-27 16:59:23 +08:00
|
|
|
@main
|
2024-04-30 23:38:49 +08:00
|
|
|
class AppDelegate: FlutterAppDelegate {
|
2024-11-09 20:17:57 +08:00
|
|
|
|
|
|
|
|
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
|
|
|
|
|
WindowExtPlugin.instance?.handleShouldTerminate()
|
|
|
|
|
return .terminateCancel
|
|
|
|
|
}
|
2024-12-09 01:40:39 +08:00
|
|
|
|
|
|
|
|
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
|
|
|
|
|
return true
|
|
|
|
|
}
|
2024-11-09 20:17:57 +08:00
|
|
|
|
|
|
|
|
override func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
|
|
|
|
if !flag {
|
|
|
|
|
for window in NSApp.windows {
|
|
|
|
|
if !window.isVisible {
|
|
|
|
|
window.setIsVisible(true)
|
|
|
|
|
}
|
|
|
|
|
window.makeKeyAndOrderFront(self)
|
|
|
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}
|
2024-04-30 23:38:49 +08:00
|
|
|
}
|