Lead show moved pane despite unsent text
This commit is contained in:
@@ -24,6 +24,7 @@ final class PaneFocus {
|
||||
if self.window === window {
|
||||
return
|
||||
}
|
||||
log.notice("pane focus: attach window=\(ObjectIdentifier(window).debugDescription, privacy: .public) title=\(window.title, privacy: .public)")
|
||||
detach()
|
||||
self.window = window
|
||||
let center = NotificationCenter.default
|
||||
@@ -60,6 +61,7 @@ final class PaneFocus {
|
||||
}
|
||||
|
||||
func detach() {
|
||||
log.notice("pane focus: detach window=\(self.window.map { ObjectIdentifier($0).debugDescription } ?? "nil", privacy: .public) observers=\(self.observers.count)")
|
||||
for o in observers {
|
||||
NotificationCenter.default.removeObserver(o)
|
||||
}
|
||||
@@ -125,6 +127,7 @@ final class PaneFocus {
|
||||
}
|
||||
if let p = contentPoint(view.bounds, in: view) {
|
||||
inside = paneFrame.contains(p)
|
||||
log.notice("pane focus: responder \(String(describing: type(of: view)), privacy: .public) point=\(p.debugDescription, privacy: .public) frame=\(self.paneFrame.debugDescription, privacy: .public) inside=\(self.inside)")
|
||||
}
|
||||
update()
|
||||
}
|
||||
@@ -135,6 +138,7 @@ final class PaneFocus {
|
||||
}
|
||||
let p = content.convert(location, from: nil)
|
||||
inside = paneFrame.contains(CGPoint(x: p.x, y: content.isFlipped ? p.y : content.bounds.height - p.y))
|
||||
log.notice("pane focus: click point=\(p.debugDescription, privacy: .public) flipped=\(content.isFlipped) frame=\(self.paneFrame.debugDescription, privacy: .public) inside=\(self.inside)")
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.responderChanged()
|
||||
}
|
||||
@@ -143,6 +147,9 @@ final class PaneFocus {
|
||||
private func update() {
|
||||
let now = (window?.isKeyWindow ?? false) && NSApp.isActive && inside
|
||||
let draft = !drafts.isEmpty
|
||||
let attached = window.map { ObjectIdentifier($0).debugDescription } ?? "nil"
|
||||
let keyWindow = NSApp.keyWindow.map { ObjectIdentifier($0).debugDescription } ?? "nil"
|
||||
log.notice("pane focus: update window=\(attached, privacy: .public) keyWindow=\(keyWindow, privacy: .public) key=\(self.window?.isKeyWindow ?? false) active=\(NSApp.isActive) inside=\(self.inside) now=\(now) draft=\(draft) focused=\(self.focused) drafting=\(self.drafting)")
|
||||
if now == focused && draft == drafting {
|
||||
return
|
||||
}
|
||||
@@ -158,6 +165,7 @@ final class PaneFocus {
|
||||
await previous?.value
|
||||
do {
|
||||
_ = try await api.client.setPaneFocus(body: .json(body)).noContent
|
||||
log.notice("pane focus: sent focused=\(body.focused) drafting=\(body.drafting)")
|
||||
} catch {
|
||||
log.error("set pane focus: \(errorText(error), privacy: .public)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user