import Cocoa
import FlutterMacOS
import window_manager

class MainFlutterWindow: NSWindow {
  override func awakeFromNib() {
    let flutterViewController = FlutterViewController()
    let windowFrame = self.frame
    self.contentViewController = flutterViewController
    self.setFrame(windowFrame, display: true)

    RegisterGeneratedPlugins(registry: flutterViewController)

    super.awakeFromNib()
  }

  // window manager hidden at launch
  override public func order(_ place: NSWindow.OrderingMode, relativeTo otherWin: Int) {
    super.order(place, relativeTo: otherWin)
//    hiddenWindowAtLaunch()
  }

  override public func performClose(_ sender: Any?) {
    // 重写关闭方法，不直接关闭窗口
    self.orderOut(nil)
  }

  override public func close() {
    // 重写关闭方法，不直接关闭窗口
    self.orderOut(nil)
  }
}
