swipe misses focus

This commit is contained in:
Ian Gulliver
2026-10-17 10:06:12 -07:00
parent 7452bd5936
commit d21215b442
3 changed files with 15 additions and 0 deletions
+9
View File
@@ -97,6 +97,7 @@ final class Overlays {
if switcher != nil { if switcher != nil {
return return
} }
logFocus("open switcher")
switcher = SwitcherModel(store: store, overlays: self, anchor: pickerFrame) switcher = SwitcherModel(store: store, overlays: self, anchor: pickerFrame)
} }
@@ -183,6 +184,14 @@ final class Overlays {
} }
} }
@MainActor
func logFocus(_ what: String) {
let key = NSApp.keyWindow
let main = NSApp.mainWindow
let responder = key?.firstResponder.map { String(describing: type(of: $0)) } ?? "nil"
log.notice("focus debug: \(what, privacy: .public) active=\(NSApp.isActive) key=\(key?.title ?? "nil", privacy: .public) main=\(main?.title ?? "nil", privacy: .public) mainIsKey=\(main?.isKeyWindow ?? false) responder=\(responder, privacy: .public)")
}
struct ModalText: View { struct ModalText: View {
let text: String let text: String
+2
View File
@@ -30,6 +30,7 @@ final class PaneFocus {
for name in [NSWindow.didBecomeKeyNotification, NSWindow.didResignKeyNotification] { for name in [NSWindow.didBecomeKeyNotification, NSWindow.didResignKeyNotification] {
observers.append(center.addObserver(forName: name, object: window, queue: .main) { [weak self] _ in observers.append(center.addObserver(forName: name, object: window, queue: .main) { [weak self] _ in
MainActor.assumeIsolated { MainActor.assumeIsolated {
logFocus(name.rawValue)
self?.update() self?.update()
} }
}) })
@@ -37,6 +38,7 @@ final class PaneFocus {
for name in [NSApplication.didBecomeActiveNotification, NSApplication.didResignActiveNotification] { for name in [NSApplication.didBecomeActiveNotification, NSApplication.didResignActiveNotification] {
observers.append(center.addObserver(forName: name, object: nil, queue: .main) { [weak self] _ in observers.append(center.addObserver(forName: name, object: nil, queue: .main) { [weak self] _ in
MainActor.assumeIsolated { MainActor.assumeIsolated {
logFocus(name.rawValue)
self?.update() self?.update()
} }
}) })
+4
View File
@@ -383,7 +383,11 @@ private struct SwitcherBox: View {
.shadow(color: .black.opacity(0.18), radius: 14, y: 8) .shadow(color: .black.opacity(0.18), radius: 14, y: 8)
.onAppear { .onAppear {
DispatchQueue.main.async { DispatchQueue.main.async {
logFocus("switcher before focus")
focused = true focused = true
DispatchQueue.main.async {
logFocus("switcher after focus focused=\(focused)")
}
} }
} }
.onChange(of: model.focusRequest) { .onChange(of: model.focusRequest) {