Skip to content
Merged
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
17 changes: 11 additions & 6 deletions Notty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// Timestamp of last close — prevents the global monitor from closing
// the panel right before togglePanel reopens it
var lastCloseTime: Date = .distantPast
var hasBeenPositioned: Bool = false // position under icon only on first open

// File where notes are saved
let saveURL = FileManager.default.homeDirectoryForCurrentUser
Expand Down Expand Up @@ -317,12 +318,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
textView.string = saved
}

// Position the panel just below the menu bar icon
if let button = statusItem.button, let btnWindow = button.window {
let buttonRect = btnWindow.convertToScreen(button.frame)
let x = buttonRect.midX - panel.frame.width / 2
let y = buttonRect.minY - panel.frame.height - 4
panel.setFrameOrigin(NSPoint(x: x, y: y))
// Position under the icon only on the very first open —
// after that, keep the position set by drag or resize
if !hasBeenPositioned {
if let button = statusItem.button, let btnWindow = button.window {
let buttonRect = btnWindow.convertToScreen(button.frame)
let x = buttonRect.midX - panel.frame.width / 2
let y = buttonRect.minY - panel.frame.height - 4
panel.setFrameOrigin(NSPoint(x: x, y: y))
}
hasBeenPositioned = true
}

// IMPORTANT ORDER:
Expand Down
Loading