File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -303,10 +303,18 @@ public func tray_set_theme_callback(_ cb: @escaping ThemeCallback) {
303303
304304@_cdecl ( " tray_is_menu_dark " )
305305public func tray_is_menu_dark( ) -> Int32 {
306+ if !Thread. isMainThread {
307+ return DispatchQueue . main. sync { tray_is_menu_dark ( ) }
308+ }
306309 let ctx = trayInstance. flatMap { contexts [ $0] } ?? contexts. values. first
307- guard let button = ctx? . statusItem. button else { return 1 }
308- guard let name = button. effectiveAppearance. bestMatch ( from: [ NSAppearance . Name. darkAqua, NSAppearance . Name. aqua] ) else {
309- return 1 // assume dark if unknown
310+ let appearance : NSAppearance
311+ if let button = ctx? . statusItem. button {
312+ appearance = button. effectiveAppearance
313+ } else {
314+ appearance = NSApp . effectiveAppearance
315+ }
316+ guard let name = appearance. bestMatch ( from: [ . darkAqua, . aqua] ) else {
317+ return 1
310318 }
311319 return name == . darkAqua ? 1 : 0
312320}
You can’t perform that action at this time.
0 commit comments