tmandry / Swindler

macOS window management library for Swift
https://tmandry.github.io/Swindler/docs/main/
MIT License
695 stars 66 forks source link

Don't receive ScreenLayoutChangedEvent events #42

Closed choco closed 5 years ago

choco commented 5 years ago

Maybe I'm doing something wrong, but I don't receive ScreenLayoutChangedEvent events.

swindler.on { (event: ScreenLayoutChangedEvent) in
                print("screen changed") 
}

With the above if I change some parameter, for example the resolution, nothing is printed.

If I register manually (which is the same way Swindler does)

NotificationCenter.default.addObserver(forName: NSApplication.didChangeScreenParametersNotification,
                                               object: NSApplication.shared,
                                               queue: OperationQueue.main) {
                                                notification -> Void in
                                                print("screen parameters changed")}

it works.

Oh, and the example app in the project still uses the old API.

tmandry commented 5 years ago

Thanks for reporting! Looks like the wrong NotificationCenter was being used. Fix coming up in #44.

I wish I could come up with a way to do integration testing on this stuff..