浏览代码

Fix search field focus while keeping window drag behavior.

Disable background dragging that blocked text input, add a compact dedicated drag strip, and make interactive widget panels reliably become key so search fields accept typing.

Made-with: Cursor
huzaifahayat12 3 月之前
父节点
当前提交
25a5a6f45a

+ 2 - 1
google_apps/AppDelegate.swift

@@ -111,7 +111,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
         window.titlebarAppearsTransparent = true
         window.titleVisibility = .hidden
         window.styleMask.insert(.fullSizeContentView)
-        window.isMovableByWindowBackground = true
+        // Avoid treating SwiftUI search fields as the draggable window background (clicks/typing fail otherwise).
+        window.isMovableByWindowBackground = false
         window.minSize = NSSize(width: 760, height: 520)
 
         let targetContentSize = NSSize(width: 980, height: 700)

+ 23 - 0
google_apps/LauncherRootView.swift

@@ -167,6 +167,11 @@ struct LauncherRootView: View {
             .padding(.horizontal, 10)
             .padding(.top, 14)
             .padding(.bottom, 8)
+            .overlay(alignment: .top) {
+                WindowDragHandle()
+                    .frame(height: 6)
+                    .padding(.horizontal, 12)
+            }
         }
         .sheet(item: $selectedApp) { app in
             AppDetailView(app: app)
@@ -530,6 +535,24 @@ struct LauncherRootView: View {
     }
 }
 
+/// Dedicated drag strip so the window remains movable while text fields stay fully interactive.
+private struct WindowDragHandle: NSViewRepresentable {
+    func makeNSView(context: Context) -> DragHandleView {
+        let view = DragHandleView()
+        view.wantsLayer = true
+        view.layer?.backgroundColor = NSColor.clear.cgColor
+        return view
+    }
+
+    func updateNSView(_ nsView: DragHandleView, context: Context) {}
+}
+
+private final class DragHandleView: NSView {
+    override func mouseDown(with event: NSEvent) {
+        window?.performDrag(with: event)
+    }
+}
+
 private struct TileReorderDropDelegate: DropDelegate {
     let destinationAppID: UUID
     @Binding var draggedAppID: UUID?

+ 4 - 2
google_apps/Widgets/DesktopWidgetWindowManager.swift

@@ -107,7 +107,8 @@ final class DesktopWidgetWindowManager: ObservableObject {
                 backing: .buffered,
                 defer: false
             )
-            panel.becomesKeyOnlyIfNeeded = true
+            // SwiftUI TextFields need the panel to become key reliably; `true` often blocks typing on desktop widgets.
+            panel.becomesKeyOnlyIfNeeded = false
         } else {
             panel = DesktopWidgetPanel(
                 contentRect: NSRect(x: 0, y: 0, width: size.width, height: size.height),
@@ -373,7 +374,8 @@ private final class InteractiveMapsWidgetPanel: NSPanel {
     override var canBecomeMain: Bool { false }
 
     override func mouseDown(with event: NSEvent) {
-        orderFront(nil)
+        NSApp.activate(ignoringOtherApps: true)
+        makeKeyAndOrderFront(nil)
         super.mouseDown(with: event)
     }
 }