fix warnings

This commit is contained in:
Ian Gulliver
2026-10-18 00:31:46 -07:00
parent e8599a7fce
commit bd66538383
11 changed files with 169 additions and 209 deletions
+20 -17
View File
@@ -12,7 +12,7 @@ final class PaneFocus {
private var focused = false
private(set) var drafting = false
private var sending: Task<Void, Never>?
private var observers: [any NSObjectProtocol] = []
private var observers: [NotificationCenter.ObservationToken] = []
private var responder: NSKeyValueObservation?
private var clicks: Any?
@@ -27,22 +27,20 @@ final class PaneFocus {
detach()
self.window = window
let center = NotificationCenter.default
for name in [NSWindow.didBecomeKeyNotification, NSWindow.didResignKeyNotification] {
observers.append(center.addObserver(forName: name, object: window, queue: .main) { [weak self] _ in
MainActor.assumeIsolated {
logFocus(name.rawValue)
self?.update()
}
})
}
for name in [NSApplication.didBecomeActiveNotification, NSApplication.didResignActiveNotification] {
observers.append(center.addObserver(forName: name, object: nil, queue: .main) { [weak self] _ in
MainActor.assumeIsolated {
logFocus(name.rawValue)
self?.update()
}
})
}
observers = [
center.addObserver(of: window, for: .didBecomeKey) { [weak self] _ in
self?.changed(NSWindow.didBecomeKeyNotification)
},
center.addObserver(of: window, for: .didResignKey) { [weak self] _ in
self?.changed(NSWindow.didResignKeyNotification)
},
center.addObserver(of: NSApplication.self, for: .didBecomeActive) { [weak self] _ in
self?.changed(NSApplication.didBecomeActiveNotification)
},
center.addObserver(of: NSApplication.self, for: .didResignActive) { [weak self] _ in
self?.changed(NSApplication.didResignActiveNotification)
},
]
responder = window.observe(\.firstResponder, options: [.new]) { [weak self] _, _ in
Task { @MainActor in
self?.responderChanged()
@@ -115,6 +113,11 @@ final class PaneFocus {
return CGPoint(x: r.midX, y: content.isFlipped ? r.midY : content.bounds.height - r.midY)
}
private func changed(_ name: Notification.Name) {
logFocus(name.rawValue)
update()
}
private func responderChanged() {
guard let view = window?.firstResponder as? NSView, view !== window?.contentView else {
update()