mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 19:12:22 +00:00
fix(macos): restore dashboard frame double-click zoom (#118976)
This commit is contained in:
@@ -32171,7 +32171,7 @@
|
||||
},
|
||||
{
|
||||
"kind": "conditional-branch",
|
||||
"line": 898,
|
||||
"line": 888,
|
||||
"path": "apps/macos/Sources/OpenClaw/DashboardWindowController.swift",
|
||||
"source": "[\\(host)]",
|
||||
"surface": "apple",
|
||||
|
||||
@@ -24,16 +24,6 @@ private final class DashboardWindow: NSWindow {
|
||||
}
|
||||
}
|
||||
|
||||
private final class DashboardWindowDragRegionView: NSView {
|
||||
override var mouseDownCanMoveWindow: Bool {
|
||||
true
|
||||
}
|
||||
|
||||
override func mouseDown(with event: NSEvent) {
|
||||
window?.performDrag(with: event)
|
||||
}
|
||||
}
|
||||
|
||||
private final class DashboardLinkSplitView: NSSplitView {
|
||||
var onDividerDragEnded: (() -> Void)?
|
||||
|
||||
@@ -597,7 +587,7 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
|
||||
else {
|
||||
return
|
||||
}
|
||||
window.performDrag(with: event)
|
||||
DashboardWindowDragGesture.handle(event, in: window)
|
||||
}
|
||||
|
||||
static func isWindowDragRequest(_ body: Any) -> Bool {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import AppKit
|
||||
|
||||
enum DashboardWindowDragGesture {
|
||||
@MainActor
|
||||
static func handle(_ event: NSEvent, in window: NSWindow) {
|
||||
// These custom surfaces replace AppKit's titlebar hit region. Preserve
|
||||
// its maximize gesture instead of consuming the second click as a drag.
|
||||
if event.type == .leftMouseDown, event.clickCount == 2 {
|
||||
window.performZoom(nil)
|
||||
return
|
||||
}
|
||||
window.performDrag(with: event)
|
||||
}
|
||||
}
|
||||
|
||||
final class DashboardWindowDragRegionView: NSView {
|
||||
override var mouseDownCanMoveWindow: Bool {
|
||||
true
|
||||
}
|
||||
|
||||
override func mouseDown(with event: NSEvent) {
|
||||
guard let window else { return }
|
||||
DashboardWindowDragGesture.handle(event, in: window)
|
||||
}
|
||||
}
|
||||
@@ -41,9 +41,55 @@ private final class DashboardBrowserImportGate {
|
||||
}
|
||||
}
|
||||
|
||||
private final class DashboardWindowGestureSpy: NSWindow {
|
||||
private(set) var dragCount = 0
|
||||
private(set) var zoomCount = 0
|
||||
|
||||
override func performDrag(with _: NSEvent) {
|
||||
self.dragCount += 1
|
||||
}
|
||||
|
||||
override func performZoom(_: Any?) {
|
||||
self.zoomCount += 1
|
||||
}
|
||||
}
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
struct DashboardWindowSmokeTests {
|
||||
@Test func `dashboard frame routes single click to drag and double click to zoom`() throws {
|
||||
let window = DashboardWindowGestureSpy(
|
||||
contentRect: NSRect(x: 0, y: 0, width: 800, height: 600),
|
||||
styleMask: [.titled, .resizable],
|
||||
backing: .buffered,
|
||||
defer: false)
|
||||
let dragRegion = DashboardWindowDragRegionView(
|
||||
frame: NSRect(x: 0, y: 0, width: 300, height: 12))
|
||||
window.contentView = dragRegion
|
||||
let mouseDownEvent: (Int) -> NSEvent? = { clickCount in
|
||||
NSEvent.mouseEvent(
|
||||
with: .leftMouseDown,
|
||||
location: NSPoint(x: 100, y: 6),
|
||||
modifierFlags: [],
|
||||
timestamp: 0,
|
||||
windowNumber: window.windowNumber,
|
||||
context: nil,
|
||||
eventNumber: clickCount,
|
||||
clickCount: clickCount,
|
||||
pressure: 1)
|
||||
}
|
||||
|
||||
dragRegion.mouseDown(with: try #require(mouseDownEvent(1)))
|
||||
|
||||
#expect(window.dragCount == 1)
|
||||
#expect(window.zoomCount == 0)
|
||||
|
||||
dragRegion.mouseDown(with: try #require(mouseDownEvent(2)))
|
||||
|
||||
#expect(window.dragCount == 1)
|
||||
#expect(window.zoomCount == 1)
|
||||
}
|
||||
|
||||
@Test func `dashboard window controller shows and closes`() throws {
|
||||
let url = try #require(URL(string: "http://127.0.0.1:18789/control/#token=device-token"))
|
||||
let controller = DashboardWindowController(
|
||||
|
||||
Reference in New Issue
Block a user