fix(panel): drag the window manually and make the whole header a drag bar

performDrag did nothing while the app was inactive (verified: mouseDown reached the drag view, performDrag returned, the frame never changed). Move the window from the screen-space mouse delta in mouseDown/mouseDragged instead.

Make the header a full-width 56 pt bar flush with the panel top, with the drag view behind it and the language/gear buttons above, so the whole top area moves the panel.

Verified: make verify green; synthetic drags from the title, top edge, empty header and grip moved the panel by the full delta while Finder was frontmost; body drag does not move it.
This commit is contained in:
schihei committed 2026-11-26 15:03:31 +01:00
1 parent f8064ac430
commit d126124f97
4 files changed
+75 -44

No files matched your search

+48 -40
View File
@@ -12,17 +12,21 @@ struct PanelView: View {
@State private var showSource = true
var body: some View {
VStack(alignment: .leading, spacing: 10) {
VStack(alignment: .leading, spacing: 0) {
header
if model.configuration.showSourcePreview, let source = model.source {
sourcePreview(source)
VStack(alignment: .leading, spacing: 10) {
if model.configuration.showSourcePreview, let source = model.source {
sourcePreview(source)
}
translationArea
warningArea
errorArea
footer
}
translationArea
warningArea
errorArea
footer
.padding(.horizontal, 16)
.padding(.top, 10)
.padding(.bottom, 16)
}
.padding(16)
.frame(width: 540)
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
.clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous))
@@ -30,6 +34,7 @@ struct PanelView: View {
RoundedRectangle(cornerRadius: 14, style: .continuous)
.strokeBorder(.separator, lineWidth: 1)
)
.ignoresSafeArea(.container, edges: .top)
.onAppear { showSource = model.configuration.showSourcePreview }
.onChange(of: model.configuration.showSourcePreview) { _, newValue in
showSource = newValue
@@ -40,9 +45,10 @@ struct PanelView: View {
}
private var header: some View {
HStack(spacing: 10) {
ZStack(alignment: .leading) {
WindowDragArea()
ZStack {
WindowDragArea()
Color.primary.opacity(0.04).allowsHitTesting(false)
HStack(spacing: 10) {
HStack(spacing: 10) {
Image(systemName: "line.3.horizontal")
.font(.system(size: 12, weight: .semibold))
@@ -61,38 +67,40 @@ struct PanelView: View {
}
}
.allowsHitTesting(false)
}
.frame(height: 44)
.contentShape(Rectangle())
.help(String(localized: "Drag to move panel"))
.accessibilityLabel(String(localized: "Move panel"))
.accessibilityElement(children: .combine)
.accessibilityLabel(String(localized: "Move panel"))
Spacer()
Button {
showLanguagePicker.toggle()
} label: {
Label(model.configuration.target.localizedDisplayName, systemImage: "globe")
.labelStyle(.titleAndIcon)
Spacer().allowsHitTesting(false)
Button {
showLanguagePicker.toggle()
} label: {
Label(model.configuration.target.localizedDisplayName, systemImage: "globe")
.labelStyle(.titleAndIcon)
}
.accessibilityLabel(String(localized: "Target language"))
.popover(isPresented: $showLanguagePicker, arrowEdge: .bottom) {
LanguagePickerView(
selection: Binding(
get: { model.configuration.target },
set: { language in
Task { await model.setTarget(language) }
}
),
recent: model.configuration.recentTargets
)
}
Button {
openSettings()
} label: {
Image(systemName: "gearshape")
}
.accessibilityLabel(String(localized: "Settings"))
}
.accessibilityLabel(String(localized: "Target language"))
.popover(isPresented: $showLanguagePicker, arrowEdge: .bottom) {
LanguagePickerView(
selection: Binding(
get: { model.configuration.target },
set: { language in
Task { await model.setTarget(language) }
}
),
recent: model.configuration.recentTargets
)
}
Button {
openSettings()
} label: {
Image(systemName: "gearshape")
}
.accessibilityLabel(String(localized: "Settings"))
.padding(.horizontal, 16)
}
.frame(height: 56)
.frame(maxWidth: .infinity)
.help(String(localized: "Drag to move panel"))
}
private var sourceLanguageLabel: String {