Skip to content

Commit 00b459a

Browse files
fix(macos): restore dashboard frame double-click zoom (#118976)
1 parent 554968f commit 00b459a

4 files changed

Lines changed: 73 additions & 12 deletions

File tree

‎apps/.i18n/native-source.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32171,7 +32171,7 @@
3217132171
},
3217232172
{
3217332173
"kind": "conditional-branch",
32174-
"line": 898,
32174+
"line": 888,
3217532175
"path": "apps/macos/Sources/OpenClaw/DashboardWindowController.swift",
3217632176
"source": "[\\(host)]",
3217732177
"surface": "apple",

‎apps/macos/Sources/OpenClaw/DashboardWindowController.swift‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ private final class DashboardWindow: NSWindow {
2424
}
2525
}
2626

27-
private final class DashboardWindowDragRegionView: NSView {
28-
override var mouseDownCanMoveWindow: Bool {
29-
true
30-
}
31-
32-
override func mouseDown(with event: NSEvent) {
33-
window?.performDrag(with: event)
34-
}
35-
}
36-
3727
private final class DashboardLinkSplitView: NSSplitView {
3828
var onDividerDragEnded: (() -> Void)?
3929

@@ -597,7 +587,7 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
597587
else {
598588
return
599589
}
600-
window.performDrag(with: event)
590+
DashboardWindowDragGesture.handle(event, in: window)
601591
}
602592

603593
static func isWindowDragRequest(_ body: Any) -> Bool {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import AppKit
2+
3+
enum DashboardWindowDragGesture {
4+
@MainActor
5+
static func handle(_ event: NSEvent, in window: NSWindow) {
6+
// These custom surfaces replace AppKit's titlebar hit region. Preserve
7+
// its maximize gesture instead of consuming the second click as a drag.
8+
if event.type == .leftMouseDown, event.clickCount == 2 {
9+
window.performZoom(nil)
10+
return
11+
}
12+
window.performDrag(with: event)
13+
}
14+
}
15+
16+
final class DashboardWindowDragRegionView: NSView {
17+
override var mouseDownCanMoveWindow: Bool {
18+
true
19+
}
20+
21+
override func mouseDown(with event: NSEvent) {
22+
guard let window else { return }
23+
DashboardWindowDragGesture.handle(event, in: window)
24+
}
25+
}

‎apps/macos/Tests/OpenClawIPCTests/DashboardWindowSmokeTests.swift‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,55 @@ private final class DashboardBrowserImportGate {
4141
}
4242
}
4343

44+
private final class DashboardWindowGestureSpy: NSWindow {
45+
private(set) var dragCount = 0
46+
private(set) var zoomCount = 0
47+
48+
override func performDrag(with _: NSEvent) {
49+
self.dragCount += 1
50+
}
51+
52+
override func performZoom(_: Any?) {
53+
self.zoomCount += 1
54+
}
55+
}
56+
4457
@Suite(.serialized)
4558
@MainActor
4659
struct DashboardWindowSmokeTests {
60+
@Test func `dashboard frame routes single click to drag and double click to zoom`() throws {
61+
let window = DashboardWindowGestureSpy(
62+
contentRect: NSRect(x: 0, y: 0, width: 800, height: 600),
63+
styleMask: [.titled, .resizable],
64+
backing: .buffered,
65+
defer: false)
66+
let dragRegion = DashboardWindowDragRegionView(
67+
frame: NSRect(x: 0, y: 0, width: 300, height: 12))
68+
window.contentView = dragRegion
69+
let mouseDownEvent: (Int) -> NSEvent? = { clickCount in
70+
NSEvent.mouseEvent(
71+
with: .leftMouseDown,
72+
location: NSPoint(x: 100, y: 6),
73+
modifierFlags: [],
74+
timestamp: 0,
75+
windowNumber: window.windowNumber,
76+
context: nil,
77+
eventNumber: clickCount,
78+
clickCount: clickCount,
79+
pressure: 1)
80+
}
81+
82+
dragRegion.mouseDown(with: try #require(mouseDownEvent(1)))
83+
84+
#expect(window.dragCount == 1)
85+
#expect(window.zoomCount == 0)
86+
87+
dragRegion.mouseDown(with: try #require(mouseDownEvent(2)))
88+
89+
#expect(window.dragCount == 1)
90+
#expect(window.zoomCount == 1)
91+
}
92+
4793
@Test func `dashboard window controller shows and closes`() throws {
4894
let url = try #require(URL(string: "http://127.0.0.1:18789/control/#token=device-token"))
4995
let controller = DashboardWindowController(

0 commit comments

Comments
 (0)