Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Sources/Ghostbar/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
}

func menuWillOpen(_ menu: NSMenu) {
NSApp.activate(ignoringOtherApps: true)
}

@objc func toggleChat() {
Expand Down
8 changes: 5 additions & 3 deletions Sources/Ghostbar/UI/ChatWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
Expand All @@ -50,8 +52,8 @@ class ChatWindow: NSObject, NSWindowDelegate {
}

func showAndFocus() {
NSApp.activate(ignoringOtherApps: true)
window.makeKeyAndOrderFront(nil)
window.orderFrontRegardless()
window.makeKey()
window.sharingType = .none
}

Expand Down
4 changes: 3 additions & 1 deletion Sources/Ghostbar/UI/MovableWindow.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/Ghostbar/UI/PrivateDropdown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down