Make the menu bar icon visible on a full menu bar

New status items land leftmost, which on a notched Mac lands under the
notch and is invisible, so the app appeared broken. Replace MenuBarExtra
with a managed status item that carries an autosave name and a persisted
preferred position, and add a diagnostic dump to verify placement.

💘 Generated with Crush

Assisted-by: Crush:deepseek-v4.1-flash
This commit is contained in:
2026-09-27 00:07:56 +08:00
parent 83cb12eddc
commit 8767b73234
5 changed files with 134 additions and 17 deletions
+12 -2
View File
@@ -57,13 +57,13 @@ final class MenuBarItemManager: ObservableObject {
items = Self.enumerate()
}
nonisolated static func enumerate() -> [MenuBarItem] {
nonisolated static func enumerate(includeOwn: Bool = false) -> [MenuBarItem] {
let ownPID = ProcessInfo.processInfo.processIdentifier
var found: [MenuBarItem] = []
for app in NSWorkspace.shared.runningApplications {
let pid = app.processIdentifier
if pid == ownPID { continue }
if !includeOwn && pid == ownPID { continue }
let axApp = AXUIElementCreateApplication(pid)
guard let bar = extrasMenuBar(of: axApp),
let children = children(of: bar) else { continue }
@@ -126,6 +126,16 @@ final class MenuBarItemManager: ObservableObject {
!string.isEmpty else { return nil }
return string
}
nonisolated static func pointAttribute(_ element: AXUIElement, _ attribute: String) -> CGPoint? {
var value: CFTypeRef?
guard AXUIElementCopyAttributeValue(element, attribute as CFString, &value) == .success,
let value,
CFGetTypeID(value) == AXValueGetTypeID() else { return nil }
var point = CGPoint.zero
guard AXValueGetValue(value as! AXValue, .cgPoint, &point) else { return nil }
return point
}
}
/// Best-effort menu bar item hiding. A zero-width spacer status item is created