import AppKit

/// 半透明悬浮窗口
final class FloatingWindow: NSWindow {
    override var canBecomeKey: Bool { true }
    override var canBecomeMain: Bool { false }

    override init(
        contentRect: NSRect = NSRect(x: 0, y: 0, width: 250, height: 300),
        styleMask style: NSWindow.StyleMask = [.borderless, .resizable],
        backing backingStoreType: NSWindow.BackingStoreType = .buffered,
        defer flag: Bool = false
    ) {
        super.init(contentRect: contentRect, styleMask: style, backing: backingStoreType, defer: flag)

        self.level = .floating
        self.collectionBehavior = [.canJoinAllSpaces, .stationary, .fullScreenAuxiliary]

        self.isOpaque = false
        self.backgroundColor = .clear
        self.hasShadow = true
        self.isMovableByWindowBackground = true
        self.minSize = NSSize(width: 240, height: 200)
        self.titlebarAppearsTransparent = true
        self.titleVisibility = .hidden
    }
}
