Skip to content

Commit

Permalink
Improve status bar tooltip (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanzhong authored Nov 17, 2024
1 parent 5a25e9e commit ef45659
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions LunarBarMac/Sources/Main/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
object: nil
)

NotificationCenter.default.addObserver(
self,
selector: #selector(windowDidUpdate(_:)),
name: NSWindow.didUpdateNotification,
object: nil
)

NotificationCenter.default.addObserver(
self,
selector: #selector(windowDidResignKey(_:)),
Expand Down Expand Up @@ -170,6 +177,19 @@ private extension AppDelegate {
}
}

@objc func windowDidUpdate(_ notification: Notification) {
guard let window = notification.object as? NSWindow, window.className == "NSToolTipPanel" else {
return
}

guard presentedPopover == nil else {
return
}

// Tooltip from the status bar sometimes has incorrect appearance
window.appearance = NSApp.effectiveAppearance
}

@objc func windowDidResignKey(_ notification: Notification) {
guard (notification.object as? NSWindow)?.contentViewController is AppMainVC else {
return
Expand Down

0 comments on commit ef45659

Please sign in to comment.