From d21215b44252ed845468551f240e2fffa7fc2741 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sat, 17 Oct 2026 10:06:12 -0700 Subject: [PATCH] swipe misses focus --- mac/Sources/Byre/Dialogs.swift | 9 +++++++++ mac/Sources/Byre/PaneFocus.swift | 2 ++ mac/Sources/Byre/Switcher.swift | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/mac/Sources/Byre/Dialogs.swift b/mac/Sources/Byre/Dialogs.swift index 5897c8d..c41f2ff 100644 --- a/mac/Sources/Byre/Dialogs.swift +++ b/mac/Sources/Byre/Dialogs.swift @@ -97,6 +97,7 @@ final class Overlays { if switcher != nil { return } + logFocus("open switcher") 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 { let text: String diff --git a/mac/Sources/Byre/PaneFocus.swift b/mac/Sources/Byre/PaneFocus.swift index 7bd5b36..9c78fcf 100644 --- a/mac/Sources/Byre/PaneFocus.swift +++ b/mac/Sources/Byre/PaneFocus.swift @@ -30,6 +30,7 @@ final class PaneFocus { 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() } }) @@ -37,6 +38,7 @@ final class PaneFocus { 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() } }) diff --git a/mac/Sources/Byre/Switcher.swift b/mac/Sources/Byre/Switcher.swift index f2fff4d..19e861c 100644 --- a/mac/Sources/Byre/Switcher.swift +++ b/mac/Sources/Byre/Switcher.swift @@ -383,7 +383,11 @@ private struct SwitcherBox: View { .shadow(color: .black.opacity(0.18), radius: 14, y: 8) .onAppear { DispatchQueue.main.async { + logFocus("switcher before focus") focused = true + DispatchQueue.main.async { + logFocus("switcher after focus focused=\(focused)") + } } } .onChange(of: model.focusRequest) {