Monitor/Sources/FloatingMonitor/App/FloatingWindow.swift

32 lines
1.1 KiB
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 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)
// contentView
let view = NSView()
view.wantsLayer = true
view.layer?.backgroundColor = NSColor.clear.cgColor
self.contentView = view
}
}