diff --git a/Sources/Ghostbar/App/AppDelegate.swift b/Sources/Ghostbar/App/AppDelegate.swift index 1034a41..dcd9ee6 100644 --- a/Sources/Ghostbar/App/AppDelegate.swift +++ b/Sources/Ghostbar/App/AppDelegate.swift @@ -69,7 +69,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { } func menuWillOpen(_ menu: NSMenu) { - NSApp.activate(ignoringOtherApps: true) } @objc func toggleChat() { diff --git a/Sources/Ghostbar/UI/ChatWindow.swift b/Sources/Ghostbar/UI/ChatWindow.swift index 73d4b55..f818d54 100644 --- a/Sources/Ghostbar/UI/ChatWindow.swift +++ b/Sources/Ghostbar/UI/ChatWindow.swift @@ -17,7 +17,7 @@ class ChatWindow: NSObject, NSWindowDelegate { window = MovableWindow( contentRect: initialFrame, - styleMask: [.titled, .closable, .resizable, .miniaturizable, .fullSizeContentView], + styleMask: [.titled, .closable, .resizable, .miniaturizable, .fullSizeContentView, .nonactivatingPanel], backing: .buffered, defer: false ) @@ -28,6 +28,8 @@ class ChatWindow: NSObject, NSWindowDelegate { window.standardWindowButton(.miniaturizeButton)?.isHidden = true window.standardWindowButton(.zoomButton)?.isHidden = true window.level = .floating + window.isFloatingPanel = true + window.hidesOnDeactivate = false if shouldCenter { window.center() } window.isReleasedWhenClosed = false window.sharingType = .none @@ -50,8 +52,8 @@ class ChatWindow: NSObject, NSWindowDelegate { } func showAndFocus() { - NSApp.activate(ignoringOtherApps: true) - window.makeKeyAndOrderFront(nil) + window.orderFrontRegardless() + window.makeKey() window.sharingType = .none } diff --git a/Sources/Ghostbar/UI/MovableWindow.swift b/Sources/Ghostbar/UI/MovableWindow.swift index 274cf9e..f558271 100644 --- a/Sources/Ghostbar/UI/MovableWindow.swift +++ b/Sources/Ghostbar/UI/MovableWindow.swift @@ -1,9 +1,11 @@ import AppKit -class MovableWindow: NSWindow { +class MovableWindow: NSPanel { private var dragging = false private let headerHeight: CGFloat = 38 + override var canBecomeKey: Bool { true } + override func sendEvent(_ event: NSEvent) { let h = contentView?.frame.height ?? frame.height let inHeader = event.locationInWindow.y >= h - headerHeight diff --git a/Sources/Ghostbar/UI/PrivateDropdown.swift b/Sources/Ghostbar/UI/PrivateDropdown.swift index c97dedb..7940059 100644 --- a/Sources/Ghostbar/UI/PrivateDropdown.swift +++ b/Sources/Ghostbar/UI/PrivateDropdown.swift @@ -40,7 +40,7 @@ class PrivateDropdown: NSObject, NSTableViewDataSource, NSTableViewDelegate { panel = NSPanel( contentRect: NSRect(x: 0, y: 0, width: 250, height: 200), - styleMask: [.borderless], + styleMask: [.borderless, .nonactivatingPanel], backing: .buffered, defer: false) panel.sharingType = .none panel.backgroundColor = NSColor.controlBackgroundColor @@ -79,7 +79,7 @@ class PrivateDropdown: NSObject, NSTableViewDataSource, NSTableViewDelegate { tableView.scrollRowToVisible(idx) } win.addChildWindow(panel, ordered: .above) - panel.makeKeyAndOrderFront(nil) + panel.orderFrontRegardless() } @objc private func rowClicked() {