refactor: use auto-released notification observer api
This commit is contained in:
1 parent
6215b65ec9
commit
9e932799ee
2 files changed
+12
-8
No files matched your search
@@ -2,10 +2,10 @@ import Cocoa
|
||||
|
||||
class SpacesEvents {
|
||||
static func observe() {
|
||||
NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.activeSpaceDidChangeNotification, object: nil, queue: nil, using: handleEvent)
|
||||
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(handleEvent), name: NSWorkspace.activeSpaceDidChangeNotification, object: nil)
|
||||
}
|
||||
|
||||
private static func handleEvent(_ notification: Notification) {
|
||||
@objc private static func handleEvent(_ notification: Notification) {
|
||||
Logger.debug(notification.name.rawValue)
|
||||
// if UI was kept open during Space transition, the Spaces may be obsolete; we refresh them
|
||||
Spaces.refreshSpacesAndWindows()
|
||||
|
||||
@@ -258,12 +258,16 @@ class ScrollView: NSScrollView {
|
||||
}
|
||||
|
||||
private func observeScrollingEvents() {
|
||||
NotificationCenter.default.addObserver(forName: NSScrollView.didEndLiveScrollNotification, object: nil, queue: nil) { [weak self] _ in
|
||||
self?.isCurrentlyScrolling = false
|
||||
}
|
||||
NotificationCenter.default.addObserver(forName: NSScrollView.willStartLiveScrollNotification, object: nil, queue: nil) { [weak self] _ in
|
||||
self?.isCurrentlyScrolling = true
|
||||
}
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(scrollingStarted), name: NSScrollView.willStartLiveScrollNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(scrollingEnded), name: NSScrollView.didEndLiveScrollNotification, object: nil)
|
||||
}
|
||||
|
||||
@objc private func scrollingStarted() {
|
||||
isCurrentlyScrolling = true
|
||||
}
|
||||
|
||||
@objc private func scrollingEnded() {
|
||||
isCurrentlyScrolling = false
|
||||
}
|
||||
|
||||
private func resetHoveredWindow() {
|
||||
|
||||
Reference in new issue
Block a user