From 3d8d37306e39db5c8eb41fafd95a13112d573f62 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Thu, 11 Jun 2026 22:24:39 +0800
Subject: [PATCH] Center filtered Waterfall columns
---
C1.source/Sources/Aligner/QuickSwitchRootView.swift | 107 ++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 92 insertions(+), 15 deletions(-)
diff --git a/C1.source/Sources/Aligner/QuickSwitchRootView.swift b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
index dba70d2..4f8f371 100644
--- a/C1.source/Sources/Aligner/QuickSwitchRootView.swift
+++ b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
@@ -82,9 +82,12 @@
private var lastProjectionTransitionFadeInLayerCount = 0
private var lastProjectionTransitionFadeOutLayerCount = 0
private var lastProjectionTransitionDurationMilliseconds: Double = 0
+ private var suppressEventInput = false
+ private var suppressEventBackgroundClicks = false
var onEscape: (() -> Void)?
var onCommitSelection: ((QuickSwitchSelection, QuickSwitchCommitSource) -> Void)?
- var onSpaceLaneClick: ((UInt64) -> Void)?
+ var onSpaceLaneClick: ((UInt64, Int) -> Void)?
+ var onBackgroundClick: (() -> Bool)?
var onRequestClose: ((QuickSwitchCloseRequest) -> Void)?
var onCloseConfirmationDisabled: (() -> Void)?
@@ -379,6 +382,13 @@
}
override func keyDown(with event: NSEvent) {
+ if suppressEventInput {
+ DevelopmentDiagnostics.log("quickSwitch.view.keyDown.ignoredForDebugSequence", [
+ "keyCode": event.keyCode
+ ])
+ return
+ }
+
switch event.keyCode {
case TriggerKeyCode.escape where Self.shouldDismissOnEscape(event):
onEscape?()
@@ -462,6 +472,15 @@
}
override func mouseDown(with event: NSEvent) {
+ if suppressEventInput {
+ DevelopmentDiagnostics.log("quickSwitch.view.mouseDown.ignoredForDebugSequence", [
+ "x": event.locationInWindow.x,
+ "y": event.locationInWindow.y,
+ "bounds": NSStringFromRect(bounds)
+ ])
+ return
+ }
+
if handleCloseConfirmationMouseDown(at: event.locationInWindow) {
return
}
@@ -477,7 +496,7 @@
}
if let segment = spaceLaneSegment(at: event.locationInWindow) {
- clickSpaceLaneSegment(segment)
+ clickSpaceLaneSegment(segment, clickCount: max(1, event.clickCount))
return
}
@@ -491,6 +510,9 @@
"y": event.locationInWindow.y,
"bounds": NSStringFromRect(bounds)
])
+ if !suppressEventBackgroundClicks, onBackgroundClick?() == true {
+ return
+ }
super.mouseDown(with: event)
}
@@ -532,6 +554,15 @@
break
}
}
+ }
+
+ func setSuppressEventBackgroundClicks(_ suppressed: Bool) {
+ suppressEventBackgroundClicks = suppressed
+ }
+
+ func setSuppressEventInput(_ suppressed: Bool) {
+ suppressEventInput = suppressed
+ suppressEventBackgroundClicks = suppressed
}
func beginPerformanceFirstFrameMeasurement() {
@@ -1207,8 +1238,21 @@
}
recordMouseCommand("click-space:\(spaceID)")
if let segment = spaceLaneSegment(spaceID: spaceID) {
- clickSpaceLaneSegment(segment)
+ clickSpaceLaneSegment(segment, clickCount: 1)
}
+ case "double-click-space" where parts.count == 2:
+ guard let spaceID = UInt64(parts[1]) else {
+ recordMouseCommand("invalid:\(command)")
+ return
+ }
+ recordMouseCommand("double-click-space:\(spaceID)")
+ if let segment = spaceLaneSegment(spaceID: spaceID) {
+ clickSpaceLaneSegment(segment, clickCount: 1)
+ clickSpaceLaneSegment(segment, clickCount: 2)
+ }
+ case "click-background":
+ recordMouseCommand("click-background")
+ _ = onBackgroundClick?()
case "hover-card" where parts.count == 3:
guard let appGroupIndex = Int(parts[1]), let windowIndex = Int(parts[2]) else {
recordMouseCommand("invalid:\(command)")
@@ -1324,13 +1368,14 @@
focusSpace(segment.space.id, persistent: false, source: source)
}
- private func clickSpaceLaneSegment(_ segment: SpaceLaneSegmentLayers) {
+ private func clickSpaceLaneSegment(_ segment: SpaceLaneSegmentLayers, clickCount: Int = 1) {
DevelopmentDiagnostics.log("quickSwitch.view.clickSpaceLane", [
"spaceID": segment.space.id,
- "label": segment.space.label
+ "label": segment.space.label,
+ "clickCount": clickCount
])
lastSpaceLaneClickSpaceID = segment.space.id
- onSpaceLaneClick?(segment.space.id)
+ onSpaceLaneClick?(segment.space.id, clickCount)
lastSpaceLaneClickSpaceID = segment.space.id
}
@@ -1623,6 +1668,11 @@
return
}
+ if waterfallShouldKeepFilteredColumnsCentered {
+ ensureWaterfallCardVisibleVertically(selection)
+ return
+ }
+
switch horizontalIntent {
case .reveal:
ensureWaterfallColumnVisible(column)
@@ -1706,6 +1756,10 @@
}
private var waterfallAlignmentScrollRange: ClosedRange<CGFloat> {
+ if waterfallShouldKeepFilteredColumnsCentered {
+ return 0...0
+ }
+
var minimumOffset: CGFloat = 0
var maximumOffset = waterfallMaxScrollOffset
@@ -1730,6 +1784,10 @@
private func clampedWaterfallAlignmentOffset(_ offset: CGFloat) -> CGFloat {
let range = waterfallAlignmentScrollRange
return min(max(range.lowerBound, offset), range.upperBound)
+ }
+
+ private var waterfallShouldKeepFilteredColumnsCentered: Bool {
+ currentViewModel?.lockedSpaceID != nil && waterfallMaxScrollOffset <= 0.5
}
private func setWaterfallScrollOffset(_ offset: CGFloat, animated: Bool) {
@@ -2443,9 +2501,11 @@
let isActive = isHovered || isFocused || isLocked
let isAssociated = (isAppAssociated || isWindowAssociated) && !isActive
- segment.containerLayer.borderWidth = (hasWindows || isCurrent || isActive || isAssociated) ? 1.5 : 1
+ segment.containerLayer.borderWidth = isLocked
+ ? 6
+ : (hasWindows || isCurrent || isActive || isAssociated) ? 1.5 : 1
segment.containerLayer.borderColor = (isActive
- ? spaceLaneOccupiedColor.withAlphaComponent(0.62)
+ ? spaceLaneOccupiedColor.withAlphaComponent(isLocked ? 0.92 : 0.62)
: isAssociated
? spaceLaneOccupiedColor.withAlphaComponent(0.50)
: hasWindows
@@ -2472,17 +2532,20 @@
colors: spaceLaneIdleOccupiedGradientColors()
)
}
+ segment.containerLayer.shadowColor = isLocked
+ ? NSColor.white.withAlphaComponent(0.98).cgColor
+ : NSColor.black.cgColor
segment.containerLayer.shadowOpacity = (hasWindows || isLocked)
- ? (isActive ? 0.26 : isAssociated ? 0.18 : isCurrent ? 0.14 : 0)
+ ? (isLocked ? 0.72 : isActive ? 0.26 : isAssociated ? 0.18 : isCurrent ? 0.14 : 0)
: 0
segment.containerLayer.shadowRadius = (hasWindows || isLocked)
- ? (isActive ? 24 : isAssociated ? 18 : isCurrent ? 12 : 0)
+ ? (isLocked ? 30 : isActive ? 24 : isAssociated ? 18 : isCurrent ? 12 : 0)
: 0
segment.containerLayer.shadowOffset = CGSize(
width: 0,
- height: (hasWindows || isLocked) ? (isActive ? -6 : isAssociated ? -4 : isCurrent ? -2.5 : 0) : 0
+ height: (hasWindows || isLocked) ? (isLocked ? 0 : isActive ? -6 : isAssociated ? -4 : isCurrent ? -2.5 : 0) : 0
)
- segment.containerLayer.zPosition = isActive ? 30 : isAssociated ? 18 : isCurrent ? 10 : 0
+ segment.containerLayer.zPosition = isLocked ? 42 : isActive ? 30 : isAssociated ? 18 : isCurrent ? 10 : 0
segment.containerLayer.transform = (isActive || isAssociated)
? CATransform3DMakeScale(isActive ? 1.03 : 1.015, isActive ? 1.03 : 1.015, 1)
: CATransform3DIdentity
@@ -2969,9 +3032,9 @@
}
let columnWidth = waterfallColumnWidth()
- let totalWidth = WaterfallMetrics.contentHorizontalPadding * 2
- + CGFloat(waterfallColumns.count) * columnWidth
+ let columnsWidth = CGFloat(waterfallColumns.count) * columnWidth
+ CGFloat(max(0, waterfallColumns.count - 1)) * WaterfallMetrics.gap
+ let totalWidth = WaterfallMetrics.contentHorizontalPadding * 2 + columnsWidth
waterfallContentWidth = max(waterfallLayer.bounds.width, totalWidth)
waterfallScrollOffset = clampedWaterfallAlignmentOffset(waterfallScrollOffset)
waterfallContentLayer.frame = CGRect(
@@ -2981,7 +3044,7 @@
height: waterfallLayer.bounds.height
)
- var x = WaterfallMetrics.contentHorizontalPadding
+ var x = waterfallColumnStartX(columnsWidth: columnsWidth)
for column in waterfallColumns {
column.containerLayer.frame = CGRect(
x: x,
@@ -2992,6 +3055,15 @@
layoutWaterfallColumn(column)
x += columnWidth + WaterfallMetrics.gap
}
+ }
+
+ private func waterfallColumnStartX(columnsWidth: CGFloat) -> CGFloat {
+ guard currentViewModel?.lockedSpaceID != nil else {
+ return WaterfallMetrics.contentHorizontalPadding
+ }
+
+ let centeredStart = (waterfallContentWidth - columnsWidth) / 2
+ return max(WaterfallMetrics.contentHorizontalPadding, centeredStart)
}
private func layoutWaterfallColumn(_ column: WaterfallColumnLayers) {
@@ -4426,8 +4498,13 @@
"gradientColors": gradientColorDictionaries(from: segment.containerLayer),
"borderColor": colorDictionary(from: segment.containerLayer.borderColor),
"borderWidth": Double(segment.containerLayer.borderWidth),
+ "shadowColor": colorDictionary(from: segment.containerLayer.shadowColor),
"shadowOpacity": Double(segment.containerLayer.shadowOpacity),
"shadowRadius": Double(segment.containerLayer.shadowRadius),
+ "shadowOffset": [
+ "width": Double(segment.containerLayer.shadowOffset.width),
+ "height": Double(segment.containerLayer.shadowOffset.height)
+ ],
"appFrame": dictionary(from: segment.appLayer.frame),
"frame": dictionary(from: segment.containerLayer.frame),
"visibleFrame": dictionary(from: visibleFrame),
--
Gitblit v1.9.3