Files
PiliPlus/macos/Runner/MainFlutterWindow.swift
泠音 2d389424af fix(macos): 🐛 restore opaque window background for title bar (#2448)
Keep the first-frame-ready show flow from #1287, but stop clearing the
native window background so the macOS title bar no longer appears transparent.

Co-authored-by: Wine Fox <fox@ling.plus>
2026-07-21 12:36:19 +08:00

30 lines
983 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Cocoa
import FlutterMacOS
class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let flutterViewController = FlutterViewController.init()
//
self.isReleasedWhenClosed = false
self.contentViewController = flutterViewController
self.setFrame(self.frame, display: true)
// 使/
self.isOpaque = true
self.backgroundColor = .windowBackgroundColor
RegisterGeneratedPlugins(registry: flutterViewController)
//
NotificationCenter.default.addObserver(
forName: NSNotification.Name("io.flutter.embedding.engine.firstFrame"),
object: flutterViewController.engine, queue: .main
) { [weak self] _ in
self?.makeKeyAndOrderFront(nil)
NSApp.activate(ignoringOtherApps: true)
}
// makeKeyAndOrderFront
super.awakeFromNib()
}
}