jonathangarelick / SoundSeer

SoundSeer is a macOS app that shows your current song & controls in the menu bar.
128 stars 2 forks source link

dynamically resize MenuBarExtra #19

Closed jonathangarelick closed 7 months ago

jonathangarelick commented 7 months ago

https://stackoverflow.com/questions/9139197/how-to-get-all-nsstatusitem-elements-of-nsstatusbar-in-osx?rq=3

jonathangarelick commented 7 months ago

https://github.com/ feedback-assistant /reports/issues/37#issuecomment-537366857

observer = NotificationCenter.default.addObserver(forName: NSWindow.didChangeOcclusionStateNotification, object: statusItem.button!.window, queue: nil) { _ in
    // We don't want to report when you manually make it invisible.
    guard self.statusItem.isVisible else {
        return
    }

    print("Is status item force-hidden by the system:", self.statusItem.button!.window?.occlusionState.contains(.visible) == false)
}
jonathangarelick commented 7 months ago

get window of a swiftui view

https://stackoverflow.com/questions/63432700/how-to-access-nswindow-from-main-app-using-only-swiftui

jonathangarelick commented 7 months ago

Not sure if I'll need to use this. The window occlusion event is a bit flaky?

func isMenuBarExtraVisible() -> Bool {
        let processNamesWithStatusItems = Set(
            (CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as! [NSDictionary])
                .filter { $0[kCGWindowLayer] as! Int == 25 }
                .map { $0[kCGWindowOwnerName] as! String }
        )

        return processNamesWithStatusItems.contains("SoundSeer")
    }
jonathangarelick commented 7 months ago

It probably is not a good idea to dynamically maximize. It would inevitably cause the song to flicker every time this happens.

One option is to make a menu option to reset song size.

jonathangarelick commented 7 months ago

make the dropdown menu double the prefix length