From 9ba7cd3b47fb91eaaa8d0c3df8b7286a89be1756 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Sun, 28 Jun 2026 21:19:30 +0800
Subject: [PATCH] Freeze 0.1.12 local QA baseline
---
C1.source/Sources/Aligner/QuickSwitchRootView.swift | 824 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 710 insertions(+), 114 deletions(-)
diff --git a/C1.source/Sources/Aligner/QuickSwitchRootView.swift b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
index f137091..7bb50aa 100644
--- a/C1.source/Sources/Aligner/QuickSwitchRootView.swift
+++ b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
@@ -58,6 +58,7 @@
private var appShelfContentWidth: CGFloat = 0
private var appShelfScrollOffset: CGFloat = 0
private var appShelfTrackingArea: NSTrackingArea?
+ private var lastKnownMouseWindowLocation: CGPoint?
private var hoveredAppGroupIndex: Int?
private var hoveredWindowID: UInt32?
private var hoveredSpaceID: UInt64?
@@ -99,6 +100,8 @@
private var windowIndexKeyPendingClearTask: Task<Void, Never>?
private var lastWindowIndexKeyCommand: String?
private var lastWindowIndexKeyCommitCode: String?
+ private var windowShortcutFilterPhase: WindowShortcutFilterPhase = .none
+ private var lastWindowShortcutPreCommitFilterSnapshot: WindowShortcutPreCommitFilterSnapshot?
private var lastBoundaryBounceAxis: String?
private var lastBoundaryBounceDirection: String?
private var boundaryBounceCount = 0
@@ -345,6 +348,47 @@
let startedAt: CFTimeInterval
}
+ private enum WindowShortcutFilterPhase: String {
+ case none
+ case appPending
+ case targetPreCommit
+ case invalid
+ case expired
+ }
+
+ private enum WindowShortcutFilterState: String {
+ case none
+ case matched
+ case dimmed
+ case target
+ }
+
+ private struct WindowShortcutPreCommitFilterSnapshot {
+ let targetCode: String
+ let targetWindowID: UInt32
+ let matchedWindowIDs: [UInt32]
+ let dimmedWindowIDs: [UInt32]
+
+ var reportDictionary: [String: Any] {
+ [
+ "phase": WindowShortcutFilterPhase.targetPreCommit.rawValue,
+ "targetCode": targetCode,
+ "targetWindowID": Int(targetWindowID),
+ "matchedWindowIDs": matchedWindowIDs.map(Int.init),
+ "dimmedWindowIDs": dimmedWindowIDs.map(Int.init)
+ ]
+ }
+ }
+
+ private struct WindowShortcutFilterReport {
+ let active: Bool
+ let phase: WindowShortcutFilterPhase
+ let pendingAppGroupIndex: Int?
+ let prefix: String?
+ let matchedWindowIDs: [UInt32]
+ let dimmedWindowIDs: [UInt32]
+ }
+
private struct ProjectionLayerSnapshot {
let layer: CALayer
let frame: CGRect
@@ -373,6 +417,27 @@
static let compressedIndexFontSize: CGFloat = 14
static let indexWidth: CGFloat = 18
static let indexHeight: CGFloat = 24
+ static let magneticFirstNeighborInfluence: CGFloat = 0
+ static let magneticSecondNeighborInfluence: CGFloat = 0
+ static let magneticHoverLift: CGFloat = 4
+ static let magneticFirstNeighborLift: CGFloat = 0
+ static let magneticSecondNeighborLift: CGFloat = 0
+ static let magneticAnimationDuration: CFTimeInterval = 0.16
+ static let magneticAnimationTimingName = CAMediaTimingFunctionName.easeOut
+ static let closeButtonHitOutset: CGFloat = 0
+ }
+
+ private struct AppShelfMagneticState {
+ let influence: CGFloat
+ let lift: CGFloat
+
+ var isActive: Bool {
+ influence > 0
+ }
+
+ var isNeighbor: Bool {
+ influence > 0 && influence < 1
+ }
}
private enum RootLayoutMetrics {
@@ -694,6 +759,7 @@
override func mouseMoved(with event: NSEvent) {
guard debugHoveredAppGroupIndex == nil else { return }
+ lastKnownMouseWindowLocation = event.locationInWindow
clearWindowIndexKeyPending()
let toggleHovered = viewModeToggleButtonContains(windowLocation: event.locationInWindow)
@@ -730,6 +796,7 @@
override func mouseExited(with event: NSEvent) {
guard debugHoveredAppGroupIndex == nil else { return }
+ lastKnownMouseWindowLocation = nil
clearWindowIndexKeyPending()
isViewModeToggleButtonHovered = false
suppressViewModeToggleHoverPreview = false
@@ -748,51 +815,75 @@
])
return
}
+
+ if handleMouseDown(at: event.locationInWindow, clickCount: max(1, event.clickCount), allowBackgroundClick: true) {
+ return
+ }
+
+ super.mouseDown(with: event)
+ }
+
+ @discardableResult
+ private func handleMouseDown(at windowLocation: CGPoint, clickCount: Int, allowBackgroundClick: Bool) -> Bool {
clearWindowIndexKeyPending()
- if handleCloseConfirmationMouseDown(at: event.locationInWindow) {
- return
+ if handleCloseConfirmationMouseDown(at: windowLocation) {
+ return true
}
- if viewModeToggleButtonContains(windowLocation: event.locationInWindow) {
+ if viewModeToggleButtonContains(windowLocation: windowLocation) {
clickViewModeToggleButton(source: "mouse")
- return
+ return true
}
- if themeToggleButtonContains(windowLocation: event.locationInWindow) {
+ if themeToggleButtonContains(windowLocation: windowLocation) {
clickThemeToggleButton(source: "mouse")
- return
+ return true
}
- if let closeTarget = closeButtonTarget(at: event.locationInWindow) {
+ if let closeTarget = waterfallCloseButtonTarget(at: windowLocation) {
beginCloseConfirmation(for: closeTarget)
- return
+ return true
}
- if let card = waterfallCard(at: event.locationInWindow) {
+ if let card = waterfallCard(at: windowLocation) {
clickWindowCard(card)
- return
+ return true
}
- if let segment = spaceLaneSegment(at: event.locationInWindow) {
- clickSpaceLaneSegment(segment, clickCount: max(1, event.clickCount))
- return
+ if let segment = spaceLaneSegment(at: windowLocation) {
+ clickSpaceLaneSegment(segment, clickCount: max(1, clickCount))
+ return true
}
- if let item = appShelfItem(at: event.locationInWindow) {
+ if let item = appShelfIconItem(at: windowLocation) {
+ if let closeTarget = appShelfCloseButtonTarget(at: windowLocation) {
+ beginCloseConfirmation(for: closeTarget)
+ } else {
+ clickAppShelfItem(item)
+ }
+ return true
+ }
+
+ if let closeTarget = closeButtonTarget(at: windowLocation) {
+ beginCloseConfirmation(for: closeTarget)
+ return true
+ }
+
+ if let item = appShelfItem(at: windowLocation) {
clickAppShelfItem(item)
- return
+ return true
}
DevelopmentDiagnostics.log("quickSwitch.view.mouseDown.miss", [
- "x": event.locationInWindow.x,
- "y": event.locationInWindow.y,
+ "x": windowLocation.x,
+ "y": windowLocation.y,
"bounds": NSStringFromRect(bounds)
])
- if !suppressEventBackgroundClicks, onBackgroundClick?() == true {
- return
+ if allowBackgroundClick, !suppressEventBackgroundClicks, onBackgroundClick?() == true {
+ return true
}
- super.mouseDown(with: event)
+ return false
}
func setDebugHoveredAppGroupIndex(_ index: Int?) {
@@ -1087,6 +1178,8 @@
clearWindowIndexKeyPending()
lastWindowIndexKeyCommand = nil
lastWindowIndexKeyCommitCode = nil
+ windowShortcutFilterPhase = .none
+ lastWindowShortcutPreCommitFilterSnapshot = nil
lastBoundaryBounceAxis = nil
lastBoundaryBounceDirection = nil
boundaryBounceCount = 0
@@ -1131,6 +1224,7 @@
needsLayout = true
ensureCurrentSelectionVisible(horizontalIntent: .alignWithAppShelf(animated: false))
+ refreshHoverTargetAfterViewRebuild()
needsLayout = true
if animatedProjection, let transitionSnapshot {
layoutSubtreeIfNeeded()
@@ -1405,6 +1499,7 @@
let firstFrameGatePassed = firstFrameP95.map { $0 < 150 } ?? false
let keyboardGatePassed = keyboardP95.map { $0 < 50 } ?? false
let hoverGatePassed = hoverP95.map { $0 <= 32 } ?? false
+ let shortcutFilterReport = makeWindowShortcutFilterReport()
return [
"viewClass": String(describing: Self.self),
@@ -1492,6 +1587,14 @@
"appShelfHoverIconSize": Double(AppShelfMetrics.hoverIconSize),
"appShelfSelectedIconSize": Double(AppShelfMetrics.selectedIconSize),
"appShelfMinIconSize": Double(AppShelfMetrics.minIconSize),
+ "appShelfMagneticHoverEnabled": appShelfMagneticHoverEnabled,
+ "appShelfMagneticFirstNeighborInfluence": Double(AppShelfMetrics.magneticFirstNeighborInfluence),
+ "appShelfMagneticSecondNeighborInfluence": Double(AppShelfMetrics.magneticSecondNeighborInfluence),
+ "appShelfMagneticHoverLift": Double(AppShelfMetrics.magneticHoverLift),
+ "appShelfMagneticFirstNeighborLift": Double(AppShelfMetrics.magneticFirstNeighborLift),
+ "appShelfMagneticSecondNeighborLift": Double(AppShelfMetrics.magneticSecondNeighborLift),
+ "appShelfMagneticAnimationDurationMilliseconds": Double(AppShelfMetrics.magneticAnimationDuration * 1_000),
+ "appShelfMagneticAnimationTimingName": AppShelfMetrics.magneticAnimationTimingName.rawValue,
"appShelfItems": appShelfItemReports(),
"waterfallFrame": dictionary(from: waterfallLayer.frame),
"waterfallViewMode": waterfallViewMode.rawValue,
@@ -1535,6 +1638,15 @@
"windowIndexKeyPendingAppSymbol": windowIndexKeyPending?.appSymbol ?? NSNull(),
"lastWindowIndexKeyCommand": lastWindowIndexKeyCommand ?? NSNull(),
"lastWindowIndexKeyCommitCode": lastWindowIndexKeyCommitCode ?? NSNull(),
+ "windowShortcutFilterActive": shortcutFilterReport.active,
+ "windowShortcutFilterPhase": shortcutFilterReport.phase.rawValue,
+ "windowShortcutFilterPendingAppGroupIndex": shortcutFilterReport.pendingAppGroupIndex ?? NSNull(),
+ "windowShortcutFilterPrefix": shortcutFilterReport.prefix ?? NSNull(),
+ "windowShortcutFilterMatchedCount": shortcutFilterReport.matchedWindowIDs.count,
+ "windowShortcutFilterDimmedCount": shortcutFilterReport.dimmedWindowIDs.count,
+ "windowShortcutFilterMatchedWindowIDs": shortcutFilterReport.matchedWindowIDs.map(Int.init),
+ "windowShortcutFilterDimmedWindowIDs": shortcutFilterReport.dimmedWindowIDs.map(Int.init),
+ "lastWindowShortcutPreCommitFilterSnapshot": lastWindowShortcutPreCommitFilterSnapshot?.reportDictionary ?? NSNull(),
"lastBoundaryBounceAxis": lastBoundaryBounceAxis ?? NSNull(),
"lastBoundaryBounceDirection": lastBoundaryBounceDirection ?? NSNull(),
"boundaryBounceCount": boundaryBounceCount,
@@ -1708,7 +1820,12 @@
recordKeyboardCommand("window:\(code)")
lastWindowIndexKeyCommand = "window:\(code)"
lastWindowIndexKeyCommitCode = code
- clearWindowIndexKeyPending()
+ lastWindowShortcutPreCommitFilterSnapshot = makeWindowShortcutPreCommitFilterSnapshot(
+ target: card,
+ code: code
+ )
+ windowShortcutFilterPhase = .targetPreCommit
+ clearWindowIndexKeyPending(resetShortcutFilter: false)
commitKeyboardWindowCard(card, trigger: "windowIndexKey")
return true
}
@@ -1716,8 +1833,10 @@
recordKeyboardCommand("windowInvalid:\(code)")
lastWindowIndexKeyCommand = "windowInvalid:\(code)"
lastWindowIndexKeyCommitCode = nil
+ windowShortcutFilterPhase = .invalid
+ lastWindowShortcutPreCommitFilterSnapshot = nil
selectionChangedByLastCommand = false
- clearWindowIndexKeyPending()
+ clearWindowIndexKeyPending(resetShortcutFilter: false)
return true
}
@@ -1728,11 +1847,21 @@
if focusAppShelfItemForKeyboard(indexSymbol: symbol, commandLabel: recordedCommand),
let ordinal = Self.appShelfIndexSymbols.firstIndex(of: symbol),
ordinal < appShelfItems.count {
- setWindowIndexKeyPending(
- appSymbol: symbol,
- appGroupIndex: appShelfItems[ordinal].item.appGroupIndex,
- startedAt: now
- )
+ let appGroupIndex = appShelfItems[ordinal].item.appGroupIndex
+ if let card = singleVisibleWaterfallCard(appGroupIndex: appGroupIndex) {
+ recordKeyboardCommand("windowSingle:\(symbol)")
+ lastWindowIndexKeyCommand = "windowSingle:\(symbol)"
+ lastWindowIndexKeyCommitCode = symbol
+ lastWindowShortcutPreCommitFilterSnapshot = nil
+ clearWindowIndexKeyPending()
+ commitKeyboardWindowCard(card, trigger: "windowIndexSingleApp")
+ } else {
+ setWindowIndexKeyPending(
+ appSymbol: symbol,
+ appGroupIndex: appGroupIndex,
+ startedAt: now
+ )
+ }
} else {
selectionChangedByLastCommand = false
clearWindowIndexKeyPending()
@@ -1783,6 +1912,9 @@
appGroupIndex: appGroupIndex,
startedAt: startedAt
)
+ windowShortcutFilterPhase = .appPending
+ lastWindowShortcutPreCommitFilterSnapshot = nil
+ needsLayout = true
windowIndexKeyPendingClearTask = Task { @MainActor [weak self] in
do {
try await Task.sleep(nanoseconds: UInt64(Self.windowIndexKeyPendingInterval * 1_000_000_000))
@@ -1799,13 +1931,26 @@
}
self.windowIndexKeyPending = nil
self.windowIndexKeyPendingClearTask = nil
+ self.windowShortcutFilterPhase = .expired
+ self.lastWindowShortcutPreCommitFilterSnapshot = nil
+ self.needsLayout = true
}
}
- private func clearWindowIndexKeyPending() {
+ private func clearWindowIndexKeyPending(resetShortcutFilter: Bool = true) {
+ let hadFilterState = windowIndexKeyPending != nil
+ || windowShortcutFilterPhase != .none
+ || lastWindowShortcutPreCommitFilterSnapshot != nil
windowIndexKeyPendingClearTask?.cancel()
windowIndexKeyPendingClearTask = nil
windowIndexKeyPending = nil
+ if resetShortcutFilter {
+ windowShortcutFilterPhase = .none
+ lastWindowShortcutPreCommitFilterSnapshot = nil
+ }
+ if hadFilterState {
+ needsLayout = true
+ }
}
@discardableResult
@@ -2059,6 +2204,11 @@
}
recordMouseCommand("hover-app:\(appGroupIndex)")
hoverAppGroup(appGroupIndex)
+ case "reapply-view-model":
+ if let currentViewModel {
+ apply(viewModel: currentViewModel)
+ }
+ recordMouseCommand("reapply-view-model")
case "click-app" where parts.count == 2:
guard let appGroupIndex = Int(parts[1]) else {
recordMouseCommand("invalid:\(command)")
@@ -2066,6 +2216,20 @@
}
recordMouseCommand("click-app:\(appGroupIndex)")
clickAppShelfItem(appGroupIndex: appGroupIndex)
+ case "click-app-center" where parts.count == 2:
+ guard let appGroupIndex = Int(parts[1]) else {
+ recordMouseCommand("invalid:\(command)")
+ return
+ }
+ recordMouseCommand("click-app-center:\(appGroupIndex)")
+ clickAppShelfItemViaMouse(appGroupIndex: appGroupIndex, probe: .iconCenter)
+ case "click-app-near-close" where parts.count == 2:
+ guard let appGroupIndex = Int(parts[1]) else {
+ recordMouseCommand("invalid:\(command)")
+ return
+ }
+ recordMouseCommand("click-app-near-close:\(appGroupIndex)")
+ clickAppShelfItemViaMouse(appGroupIndex: appGroupIndex, probe: .nearCloseOutsideHit)
case "hover-app-close" where parts.count == 2:
guard let appGroupIndex = Int(parts[1]) else {
recordMouseCommand("invalid:\(command)")
@@ -2206,6 +2370,7 @@
}
private func hoverAppGroup(_ appGroupIndex: Int, source: HoverTargetSource = .debug) {
+ lastKnownMouseWindowLocation = appShelfItemCenterWindowLocation(for: appGroupIndex)
updateHoverState(
appGroupIndex: appGroupIndex,
windowID: nil,
@@ -2328,6 +2493,64 @@
}
}
+ private enum AppShelfMouseClickProbe {
+ case iconCenter
+ case nearCloseOutsideHit
+ }
+
+ private func clickAppShelfItemViaMouse(appGroupIndex: Int, probe: AppShelfMouseClickProbe) {
+ guard let windowLocation = appShelfSyntheticMouseDownLocation(for: appGroupIndex, probe: probe) else {
+ DevelopmentDiagnostics.log("quickSwitch.view.clickAppShelfViaMouse.missingLocation", [
+ "appGroupIndex": appGroupIndex
+ ])
+ return
+ }
+ _ = handleMouseDown(at: windowLocation, clickCount: 1, allowBackgroundClick: false)
+ }
+
+ private func appShelfSyntheticMouseDownLocation(
+ for appGroupIndex: Int,
+ probe: AppShelfMouseClickProbe
+ ) -> CGPoint? {
+ layoutSubtreeIfNeeded()
+ guard let item = appShelfItems.first(where: { $0.item.appGroupIndex == appGroupIndex }) else {
+ return nil
+ }
+
+ let iconFrame = item.iconLayer.frame
+ let closeFrame = item.closeButton.containerLayer.frame
+ let pointInItem: CGPoint
+ switch probe {
+ case .iconCenter:
+ pointInItem = CGPoint(x: iconFrame.midX, y: iconFrame.midY)
+ case .nearCloseOutsideHit:
+ let fallbackPoint = CGPoint(
+ x: iconFrame.maxX - 4,
+ y: iconFrame.maxY - 14
+ )
+ if closeFrame.width > 0, closeFrame.height > 0 {
+ let candidate = CGPoint(x: closeFrame.minX - 4, y: closeFrame.midY)
+ pointInItem = iconFrame.contains(candidate) ? candidate : fallbackPoint
+ } else {
+ pointInItem = fallbackPoint
+ }
+ }
+
+ let pointInView = CGPoint(
+ x: glassLayer.frame.minX
+ + shelfLayer.frame.minX
+ + appShelfContentLayer.frame.minX
+ + item.containerLayer.frame.minX
+ + pointInItem.x,
+ y: glassLayer.frame.minY
+ + shelfLayer.frame.minY
+ + appShelfContentLayer.frame.minY
+ + item.containerLayer.frame.minY
+ + pointInItem.y
+ )
+ return convert(pointInView, to: nil)
+ }
+
private func scrollAppShelf(to targetOffset: CGFloat) {
layoutSubtreeIfNeeded()
let previousOffset = appShelfScrollOffset
@@ -2448,8 +2671,26 @@
private func refreshHoverTarget(at windowLocation: CGPoint) {
guard debugHoveredAppGroupIndex == nil else { return }
+ lastKnownMouseWindowLocation = windowLocation
let target = resolveHoverTarget(at: windowLocation)
setHoverTarget(target, alignsWaterfallWithAppShelf: target.shouldAlignWaterfallWithAppShelf)
+ }
+
+ private func refreshHoverTargetAfterViewRebuild() {
+ guard debugHoveredAppGroupIndex == nil, currentViewModel != nil else { return }
+
+ layoutSubtreeIfNeeded()
+ let windowLocation = lastKnownMouseWindowLocation ?? window?.mouseLocationOutsideOfEventStream
+ guard let windowLocation else { return }
+
+ let locationInView = convert(windowLocation, from: nil)
+ guard bounds.contains(locationInView) else {
+ lastKnownMouseWindowLocation = nil
+ setHoverTarget(.none)
+ return
+ }
+
+ refreshHoverTarget(at: windowLocation)
}
private func resolveHoverTarget(at windowLocation: CGPoint) -> HoverTarget {
@@ -4454,17 +4695,41 @@
)
: nil
- applySpaceLaneContentVisualState(segment, isLocked: isLocked)
+ applySpaceLaneContentVisualState(
+ segment,
+ isLocked: isLocked,
+ usesLightActiveFill: resolvedTheme == .dark && hasWindows && !isLocked && (isActive || isAssociated)
+ )
}
- private func applySpaceLaneContentVisualState(_ segment: SpaceLaneSegmentLayers, isLocked: Bool) {
- let primaryTextColor: NSColor = isLocked ? .white : themePalette.spaceLanePrimaryText
+ private func applySpaceLaneContentVisualState(
+ _ segment: SpaceLaneSegmentLayers,
+ isLocked: Bool,
+ usesLightActiveFill: Bool
+ ) {
+ let primaryTextColor: NSColor = isLocked
+ ? .white
+ : usesLightActiveFill
+ ? NSColor.black.withAlphaComponent(0.82)
+ : themePalette.spaceLanePrimaryText
let secondaryTextColor: NSColor = isLocked
? .white
- : themePalette.spaceLaneSecondaryText
+ : usesLightActiveFill
+ ? NSColor.black.withAlphaComponent(0.58)
+ : themePalette.spaceLaneSecondaryText
+ let markerTextColor: NSColor = isLocked
+ ? .white
+ : usesLightActiveFill
+ ? NSColor.black.withAlphaComponent(0.62)
+ : themePalette.spaceLaneSecondaryText.withAlphaComponent(segment.space.isCurrent ? 0.72 : 0.54)
+ let blockColor: NSColor = isLocked
+ ? .white
+ : usesLightActiveFill
+ ? NSColor.black.withAlphaComponent(0.20)
+ : spaceLaneOccupiedColor.withAlphaComponent(segment.space.isCurrent ? 0.72 : 0.58)
segment.labelLayer.foregroundColor = primaryTextColor.cgColor
- segment.countLayer.foregroundColor = (isLocked ? NSColor.white : themePalette.spaceLaneSecondaryText).cgColor
+ segment.countLayer.foregroundColor = secondaryTextColor.cgColor
segment.appLayer.foregroundColor = (segment.space.type == .fullscreen
? primaryTextColor
: secondaryTextColor
@@ -4474,16 +4739,10 @@
}
for block in segment.windowBlocks {
- block.backgroundColor = (isLocked
- ? NSColor.white
- : spaceLaneOccupiedColor.withAlphaComponent(segment.space.isCurrent ? 0.72 : 0.58)
- ).cgColor
+ block.backgroundColor = blockColor.cgColor
}
- (segment.fullscreenMarkerLayer as? CAShapeLayer)?.strokeColor = (isLocked
- ? NSColor.white
- : themePalette.spaceLaneSecondaryText.withAlphaComponent(segment.space.isCurrent ? 0.72 : 0.54)
- ).cgColor
+ (segment.fullscreenMarkerLayer as? CAShapeLayer)?.strokeColor = markerTextColor.cgColor
}
private func shouldScrollSpaceLane(for event: NSEvent) -> Bool {
@@ -4611,42 +4870,90 @@
}
private func appShelfItem(at windowLocation: CGPoint) -> AppShelfItemLayers? {
- let locationInView = convert(windowLocation, from: nil)
- let locationInShelfContent = CGPoint(
- x: locationInView.x - glassLayer.frame.minX - shelfLayer.frame.minX - appShelfContentLayer.frame.minX,
- y: locationInView.y - glassLayer.frame.minY - shelfLayer.frame.minY - appShelfContentLayer.frame.minY
- )
+ let locationInShelfContent = appShelfContentLocation(at: windowLocation)
return appShelfItems.first { item in
- item.containerLayer.frame.contains(locationInShelfContent)
+ interactiveFrame(for: item.containerLayer).contains(locationInShelfContent)
}
+ }
+
+ private func appShelfIconItem(at windowLocation: CGPoint) -> AppShelfItemLayers? {
+ let locationInAppShelfContent = appShelfContentLocation(at: windowLocation)
+
+ return appShelfItems.first { item in
+ let itemFrame = interactiveFrame(for: item.containerLayer)
+ let locationInItem = CGPoint(
+ x: locationInAppShelfContent.x - itemFrame.minX,
+ y: locationInAppShelfContent.y - itemFrame.minY
+ )
+ return interactiveFrame(for: item.iconLayer).contains(locationInItem)
+ }
+ }
+
+ private func appShelfContentLocation(at windowLocation: CGPoint) -> CGPoint {
+ let locationInView = convert(windowLocation, from: nil)
+ let glassFrame = interactiveFrame(for: glassLayer)
+ let shelfFrame = interactiveFrame(for: shelfLayer)
+ let appShelfContentFrame = interactiveFrame(for: appShelfContentLayer)
+
+ return CGPoint(
+ x: locationInView.x - glassFrame.minX - shelfFrame.minX - appShelfContentFrame.minX,
+ y: locationInView.y - glassFrame.minY - shelfFrame.minY - appShelfContentFrame.minY
+ )
+ }
+
+ private func appShelfItemCenterWindowLocation(for appGroupIndex: Int) -> CGPoint? {
+ guard let item = appShelfItems.first(where: { $0.item.appGroupIndex == appGroupIndex }) else {
+ return nil
+ }
+
+ let pointInView = CGPoint(
+ x: glassLayer.frame.minX
+ + shelfLayer.frame.minX
+ + appShelfContentLayer.frame.minX
+ + item.containerLayer.frame.midX,
+ y: glassLayer.frame.minY
+ + shelfLayer.frame.minY
+ + appShelfContentLayer.frame.minY
+ + item.containerLayer.frame.midY
+ )
+ return convert(pointInView, to: nil)
}
private func waterfallCard(at windowLocation: CGPoint) -> WaterfallCardLayers? {
let locationInView = convert(windowLocation, from: nil)
+ let glassFrame = interactiveFrame(for: glassLayer)
+ let waterfallFrame = interactiveFrame(for: waterfallLayer)
+ let waterfallContentFrame = interactiveFrame(for: waterfallContentLayer)
let locationInWaterfallContent = CGPoint(
- x: locationInView.x - glassLayer.frame.minX - waterfallLayer.frame.minX - waterfallContentLayer.frame.minX,
- y: locationInView.y - glassLayer.frame.minY - waterfallLayer.frame.minY - waterfallContentLayer.frame.minY
+ x: locationInView.x - glassFrame.minX - waterfallFrame.minX - waterfallContentFrame.minX,
+ y: locationInView.y - glassFrame.minY - waterfallFrame.minY - waterfallContentFrame.minY
)
- for column in waterfallColumns where column.containerLayer.frame.contains(locationInWaterfallContent) {
+ for column in waterfallColumns where interactiveFrame(for: column.containerLayer).contains(locationInWaterfallContent) {
+ let columnFrame = interactiveFrame(for: column.containerLayer)
+ let cardsClipFrame = interactiveFrame(for: column.cardsClipLayer)
let locationInColumn = CGPoint(
- x: locationInWaterfallContent.x - column.containerLayer.frame.minX,
- y: locationInWaterfallContent.y - column.containerLayer.frame.minY
+ x: locationInWaterfallContent.x - columnFrame.minX,
+ y: locationInWaterfallContent.y - columnFrame.minY
)
- guard column.cardsClipLayer.frame.contains(locationInColumn) else {
+ guard cardsClipFrame.contains(locationInColumn) else {
continue
}
let locationInCardsClip = CGPoint(
- x: locationInColumn.x - column.cardsClipLayer.frame.minX,
- y: locationInColumn.y - column.cardsClipLayer.frame.minY
+ x: locationInColumn.x - cardsClipFrame.minX,
+ y: locationInColumn.y - cardsClipFrame.minY
)
- if let card = column.cards.first(where: { $0.containerLayer.frame.contains(locationInCardsClip) }) {
+ if let card = column.cards.first(where: { interactiveFrame(for: $0.containerLayer).contains(locationInCardsClip) }) {
return card
}
}
return nil
+ }
+
+ private func interactiveFrame(for layer: CALayer) -> CGRect {
+ layer.presentation()?.frame ?? layer.frame
}
private func waterfallCard(appGroupIndex: Int, windowIndex: Int) -> WaterfallCardLayers? {
@@ -4783,50 +5090,69 @@
let isHovered = item.item.appGroupIndex == effectiveHoveredAppGroupIndex
let showsSelectedVisual = shouldShowSelectedVisual(isSelected: isSelected, isHovered: isHovered)
let isSpaceFocused = spaceFocusWindowCount(for: item.item.appGroupIndex) > 0
+ let magneticState = appShelfMagneticState(for: item)
let visualIconSize = appShelfVisualIconSize(
forBaseIconSize: iconSize,
selected: showsSelectedVisual,
hovered: isHovered,
- spaceFocused: isSpaceFocused
+ spaceFocused: isSpaceFocused,
+ magneticState: magneticState
)
- let backgroundPadding: CGFloat = (showsSelectedVisual || isHovered)
- ? 4
- : isSpaceFocused
- ? 6
- : 2
+ let backgroundPadding: CGFloat = isSpaceFocused ? 6 : 2
let iconX = (bounds.width - visualIconSize) / 2
- let iconY = bounds.height - visualIconSize - 2
+ let iconY = bounds.height - visualIconSize - 2 + magneticState.lift
let badgeText = appShelfBadgeText(for: item)
let badgeWidth = max(18, CGFloat(badgeText.count) * 7 + 8)
+
+ let previousBackgroundFrame = item.backgroundLayer.presentation()?.frame ?? item.backgroundLayer.frame
+ let previousIconFrame = item.iconLayer.presentation()?.frame ?? item.iconLayer.frame
+ let previousIndexFrame = item.indexLayer.presentation()?.frame ?? item.indexLayer.frame
+ let previousBadgeFrame = item.badgeLayer.presentation()?.frame ?? item.badgeLayer.frame
+ let previousCloseFrame = item.closeButton.containerLayer.presentation()?.frame
+ ?? item.closeButton.containerLayer.frame
item.containerLayer.zPosition = appShelfZPosition(
selected: showsSelectedVisual,
hovered: isHovered,
- spaceFocused: isSpaceFocused
+ spaceFocused: isSpaceFocused,
+ magneticState: magneticState
)
item.backgroundLayer.backgroundColor = appShelfBackgroundColor(
selected: showsSelectedVisual,
hovered: isHovered,
- spaceFocused: isSpaceFocused
+ spaceFocused: isSpaceFocused,
+ magneticState: magneticState
).cgColor
- item.backgroundLayer.borderColor = (showsSelectedVisual
- ? NSColor.controlAccentColor.withAlphaComponent(0.40)
- : isHovered
- ? NSColor.controlAccentColor.withAlphaComponent(0.36)
- : NSColor.clear
- ).cgColor
- item.backgroundLayer.borderWidth = (showsSelectedVisual || isHovered) ? 1 : 0
+ item.backgroundLayer.borderColor = NSColor.clear.cgColor
+ item.backgroundLayer.borderWidth = 0
+ item.containerLayer.borderColor = NSColor.clear.cgColor
+ item.containerLayer.borderWidth = 0
+ item.iconLayer.borderColor = NSColor.clear.cgColor
+ item.iconLayer.borderWidth = 0
item.backgroundLayer.shadowColor = NSColor.black.cgColor
- item.backgroundLayer.shadowOpacity = showsSelectedVisual ? 0.11 : isHovered ? 0.07 : isSpaceFocused ? 0.18 : 0
- item.backgroundLayer.shadowRadius = showsSelectedVisual ? 10 : isHovered ? 8 : isSpaceFocused ? 18 : 0
- item.backgroundLayer.shadowOffset = CGSize(width: 0, height: isSpaceFocused ? -4 : -2)
+ item.backgroundLayer.shadowOpacity = appShelfShadowOpacity(
+ selected: showsSelectedVisual,
+ hovered: isHovered,
+ spaceFocused: isSpaceFocused,
+ magneticState: magneticState
+ )
+ item.backgroundLayer.shadowRadius = appShelfShadowRadius(
+ selected: showsSelectedVisual,
+ hovered: isHovered,
+ spaceFocused: isSpaceFocused,
+ magneticState: magneticState
+ )
+ item.backgroundLayer.shadowOffset = CGSize(
+ width: 0,
+ height: isSpaceFocused ? -4 : magneticState.isNeighbor ? -1 : -2
+ )
item.backgroundLayer.frame = CGRect(
x: iconX - backgroundPadding,
y: iconY - backgroundPadding,
width: visualIconSize + backgroundPadding * 2,
height: visualIconSize + backgroundPadding * 2
)
- item.backgroundLayer.shadowPath = (showsSelectedVisual || isHovered || isSpaceFocused)
+ item.backgroundLayer.shadowPath = isSpaceFocused
? CGPath(
roundedRect: item.backgroundLayer.bounds,
cornerWidth: item.backgroundLayer.cornerRadius,
@@ -4868,6 +5194,12 @@
)
item.selectedIndicatorLayer.frame = .zero
item.selectedIndicatorLayer.backgroundColor = NSColor.clear.cgColor
+
+ animateAppShelfLayerFrame(item.backgroundLayer, from: previousBackgroundFrame)
+ animateAppShelfLayerFrame(item.iconLayer, from: previousIconFrame)
+ animateAppShelfLayerFrame(item.indexLayer, from: previousIndexFrame)
+ animateAppShelfLayerFrame(item.badgeLayer, from: previousBadgeFrame)
+ animateAppShelfLayerFrame(item.closeButton.containerLayer, from: previousCloseFrame)
}
private var appShelfIndexColor: NSColor {
@@ -4950,6 +5282,75 @@
private var effectiveHoveredAppGroupIndex: Int? {
debugHoveredAppGroupIndex ?? hoveredAppGroupIndex
+ }
+
+ private var appShelfMagneticHoverEnabled: Bool {
+ !NSWorkspace.shared.accessibilityDisplayShouldReduceMotion
+ }
+
+ private func appShelfMagneticState(for item: AppShelfItemLayers) -> AppShelfMagneticState {
+ guard appShelfMagneticHoverEnabled,
+ let hoveredAppGroupIndex = effectiveHoveredAppGroupIndex,
+ item.item.appGroupIndex == hoveredAppGroupIndex
+ else {
+ return AppShelfMagneticState(influence: 0, lift: 0)
+ }
+
+ return AppShelfMagneticState(
+ influence: 1,
+ lift: AppShelfMetrics.magneticHoverLift
+ )
+ }
+
+ private func animateAppShelfLayerFrame(_ layer: CALayer, from previousFrame: CGRect) {
+ guard appShelfMagneticHoverEnabled,
+ previousFrame.width > 0,
+ previousFrame.height > 0,
+ appShelfFrameIsFinite(previousFrame),
+ appShelfFrameIsFinite(layer.frame)
+ else {
+ layer.removeAnimation(forKey: "appShelfMagneticPosition")
+ layer.removeAnimation(forKey: "appShelfMagneticBounds")
+ return
+ }
+
+ let previousPosition = CGPoint(x: previousFrame.midX, y: previousFrame.midY)
+ let previousBounds = CGRect(origin: .zero, size: previousFrame.size)
+ let nextPosition = layer.position
+ let nextBounds = layer.bounds
+ let moved = abs(previousPosition.x - nextPosition.x) > 0.25
+ || abs(previousPosition.y - nextPosition.y) > 0.25
+ let resized = abs(previousBounds.width - nextBounds.width) > 0.25
+ || abs(previousBounds.height - nextBounds.height) > 0.25
+
+ guard moved || resized else { return }
+
+ let timing = CAMediaTimingFunction(name: AppShelfMetrics.magneticAnimationTimingName)
+ if moved {
+ let animation = CABasicAnimation(keyPath: "position")
+ animation.fromValue = previousPosition
+ animation.toValue = nextPosition
+ animation.duration = AppShelfMetrics.magneticAnimationDuration
+ animation.timingFunction = timing
+ animation.isRemovedOnCompletion = true
+ layer.add(animation, forKey: "appShelfMagneticPosition")
+ }
+ if resized {
+ let animation = CABasicAnimation(keyPath: "bounds")
+ animation.fromValue = previousBounds
+ animation.toValue = nextBounds
+ animation.duration = AppShelfMetrics.magneticAnimationDuration
+ animation.timingFunction = timing
+ animation.isRemovedOnCompletion = true
+ layer.add(animation, forKey: "appShelfMagneticBounds")
+ }
+ }
+
+ private func appShelfFrameIsFinite(_ frame: CGRect) -> Bool {
+ frame.origin.x.isFinite
+ && frame.origin.y.isFinite
+ && frame.size.width.isFinite
+ && frame.size.height.isFinite
}
private var activeSpaceFocusID: UInt64? {
@@ -5072,7 +5473,8 @@
forBaseIconSize iconSize: CGFloat,
selected: Bool,
hovered: Bool,
- spaceFocused: Bool
+ spaceFocused: Bool,
+ magneticState: AppShelfMagneticState
) -> CGFloat {
if selected || hovered {
return AppShelfMetrics.selectedIconSize
@@ -5080,10 +5482,19 @@
if spaceFocused {
return min(AppShelfMetrics.selectedIconSize, iconSize + 8)
}
- return iconSize
+ guard magneticState.isNeighbor else {
+ return iconSize
+ }
+ let growth = AppShelfMetrics.hoverIconSize - iconSize
+ return iconSize + growth * magneticState.influence
}
- private func appShelfZPosition(selected: Bool, hovered: Bool, spaceFocused: Bool) -> CGFloat {
+ private func appShelfZPosition(
+ selected: Bool,
+ hovered: Bool,
+ spaceFocused: Bool,
+ magneticState: AppShelfMagneticState
+ ) -> CGFloat {
switch (selected, hovered, spaceFocused) {
case (true, true, _):
return 30
@@ -5094,21 +5505,44 @@
case (false, false, true):
return 12
case (false, false, false):
- return 0
+ return magneticState.isNeighbor ? 6 + magneticState.influence : 0
}
}
- private func appShelfBackgroundColor(selected: Bool, hovered: Bool, spaceFocused: Bool) -> NSColor {
- if selected {
- return themePalette.appShelfBackgroundSelected
- }
- if hovered {
- return themePalette.appShelfBackgroundHovered
- }
+ private func appShelfBackgroundColor(
+ selected: Bool,
+ hovered: Bool,
+ spaceFocused: Bool,
+ magneticState: AppShelfMagneticState
+ ) -> NSColor {
if spaceFocused {
return themePalette.appShelfBackgroundSpaceFocused
}
return .clear
+ }
+
+ private func appShelfShadowOpacity(
+ selected: Bool,
+ hovered: Bool,
+ spaceFocused: Bool,
+ magneticState: AppShelfMagneticState
+ ) -> Float {
+ if spaceFocused {
+ return 0.18
+ }
+ return 0
+ }
+
+ private func appShelfShadowRadius(
+ selected: Bool,
+ hovered: Bool,
+ spaceFocused: Bool,
+ magneticState: AppShelfMagneticState
+ ) -> CGFloat {
+ if spaceFocused {
+ return 18
+ }
+ return 0
}
private func appShelfBadgeText(for item: AppShelfItemLayers) -> String {
@@ -5433,13 +5867,15 @@
let isKeyboardFocused = card.item.window.id == keyboardFocusedWindowID
let isHorizontalAppDefaultFocused = isHorizontalAppDefaultCard(card)
let isAppLinked = isWaterfallCardAppLinked(card)
+ let shortcutFilterState = windowShortcutFilterState(for: card)
applyWaterfallCardVisualState(
card,
selected: shouldShowSelectedVisual(isSelected: isSelected, isHovered: isHovered)
|| isKeyboardFocused
|| isHorizontalAppDefaultFocused,
hovered: isHovered,
- appLinked: isAppLinked
+ appLinked: isAppLinked,
+ shortcutFilterState: shortcutFilterState
)
let outerInset: CGFloat = 0
@@ -5494,7 +5930,7 @@
windowIndex: card.item.windowIndex,
windowID: card.item.window.id
),
- visible: isHovered,
+ visible: isHovered && shortcutFilterState != .dimmed,
anchorTopRight: CGPoint(x: bounds.maxX - 12, y: bounds.maxY - 12)
)
card.shineLayer.frame = CGRect(
@@ -5514,9 +5950,11 @@
_ card: WaterfallCardLayers,
selected: Bool,
hovered: Bool,
- appLinked: Bool
+ appLinked: Bool,
+ shortcutFilterState: WindowShortcutFilterState
) {
let isSpaceFocused = isWaterfallCardSpaceFocused(card)
+ let isShortcutDimmed = shortcutFilterState == .dimmed
card.containerLayer.backgroundColor = (selected
? themePalette.cardSelectedBackground
: hovered
@@ -5527,6 +5965,7 @@
? accentTintedWindowBackground(fraction: 0.10, alpha: 0.94)
: themePalette.cardBackground
).cgColor
+ card.containerLayer.opacity = isShortcutDimmed ? windowShortcutFilterDimOpacity : 1
card.containerLayer.borderColor = (selected
? NSColor.controlAccentColor.withAlphaComponent(0.52)
: hovered
@@ -5540,7 +5979,7 @@
card.containerLayer.borderWidth = (selected || hovered || appLinked || isSpaceFocused) ? 1.5 : 1
card.containerLayer.shadowColor = NSColor.black.cgColor
let darkShadowBoost: Float = resolvedTheme == .dark ? 0.08 : 0
- card.containerLayer.shadowOpacity = selected
+ let baseShadowOpacity: Float = selected
? 0.24 + darkShadowBoost
: hovered
? 0.14 + darkShadowBoost
@@ -5549,6 +5988,7 @@
: isSpaceFocused
? 0.20 + darkShadowBoost
: 0
+ card.containerLayer.shadowOpacity = isShortcutDimmed ? min(baseShadowOpacity, 0.03) : baseShadowOpacity
card.containerLayer.shadowRadius = selected ? 22 : hovered ? 17 : appLinked ? 18 : isSpaceFocused ? 24 : 0
card.containerLayer.shadowOffset = selected
? CGSize(width: 0, height: -6)
@@ -5561,10 +6001,10 @@
: .zero
card.containerLayer.zPosition = selected ? 20 : hovered ? 12 : appLinked ? 10 : isSpaceFocused ? 8 : 0
let focusedScale: CGFloat = selected ? WaterfallMetrics.selectedCardScale : isSpaceFocused ? 1.012 : 1.008
- card.containerLayer.transform = (selected || hovered || isSpaceFocused)
+ card.containerLayer.transform = (!isShortcutDimmed && (selected || hovered || isSpaceFocused))
? CATransform3DMakeScale(focusedScale, focusedScale, 1)
: CATransform3DIdentity
- card.containerLayer.shadowPath = (selected || hovered || appLinked || isSpaceFocused)
+ card.containerLayer.shadowPath = (!isShortcutDimmed && (selected || hovered || appLinked || isSpaceFocused))
? CGPath(
roundedRect: card.containerLayer.bounds,
cornerWidth: card.containerLayer.cornerRadius,
@@ -5580,7 +6020,7 @@
).cgColor
card.titleBarLayer.borderColor = NSColor.clear.cgColor
card.titleBarLayer.borderWidth = 0
- card.shineLayer.opacity = selected ? 1 : 0
+ card.shineLayer.opacity = (!isShortcutDimmed && selected) ? 1 : 0
}
private func layoutCloseButton(
@@ -6021,11 +6461,7 @@
}
private func appShelfCloseButtonTarget(at windowLocation: NSPoint) -> CloseTarget? {
- let locationInView = convert(windowLocation, from: nil)
- let locationInAppShelfContent = CGPoint(
- x: locationInView.x - glassLayer.frame.minX - shelfLayer.frame.minX - appShelfContentLayer.frame.minX,
- y: locationInView.y - glassLayer.frame.minY - shelfLayer.frame.minY - appShelfContentLayer.frame.minY
- )
+ let locationInAppShelfContent = appShelfContentLocation(at: windowLocation)
for item in appShelfItems {
let target = CloseTarget.app(appGroupIndex: item.item.appGroupIndex)
@@ -6033,43 +6469,59 @@
canClose(app: item.item.app)
else { continue }
+ let itemFrame = interactiveFrame(for: item.containerLayer)
+ let closeFrame = interactiveFrame(for: item.closeButton.containerLayer)
let locationInItem = CGPoint(
- x: locationInAppShelfContent.x - item.containerLayer.frame.minX,
- y: locationInAppShelfContent.y - item.containerLayer.frame.minY
+ x: locationInAppShelfContent.x - itemFrame.minX,
+ y: locationInAppShelfContent.y - itemFrame.minY
)
- if item.closeButton.containerLayer.frame.insetBy(dx: -8, dy: -8).contains(locationInItem) {
+ if appShelfCloseHitFrame(for: closeFrame).contains(locationInItem) {
return target
}
}
return nil
}
+ private func appShelfCloseHitFrame(for closeFrame: CGRect) -> CGRect {
+ closeFrame.insetBy(
+ dx: -AppShelfMetrics.closeButtonHitOutset,
+ dy: -AppShelfMetrics.closeButtonHitOutset
+ )
+ }
+
private func waterfallCloseButtonTarget(at windowLocation: NSPoint) -> CloseTarget? {
let locationInView = convert(windowLocation, from: nil)
+ let glassFrame = interactiveFrame(for: glassLayer)
+ let waterfallFrame = interactiveFrame(for: waterfallLayer)
+ let waterfallContentFrame = interactiveFrame(for: waterfallContentLayer)
let locationInWaterfallContent = CGPoint(
- x: locationInView.x - glassLayer.frame.minX - waterfallLayer.frame.minX - waterfallContentLayer.frame.minX,
- y: locationInView.y - glassLayer.frame.minY - waterfallLayer.frame.minY - waterfallContentLayer.frame.minY
+ x: locationInView.x - glassFrame.minX - waterfallFrame.minX - waterfallContentFrame.minX,
+ y: locationInView.y - glassFrame.minY - waterfallFrame.minY - waterfallContentFrame.minY
)
- for column in waterfallColumns where column.containerLayer.frame.contains(locationInWaterfallContent) {
+ for column in waterfallColumns where interactiveFrame(for: column.containerLayer).contains(locationInWaterfallContent) {
+ let columnFrame = interactiveFrame(for: column.containerLayer)
+ let cardsClipFrame = interactiveFrame(for: column.cardsClipLayer)
let locationInColumn = CGPoint(
- x: locationInWaterfallContent.x - column.containerLayer.frame.minX,
- y: locationInWaterfallContent.y - column.containerLayer.frame.minY
+ x: locationInWaterfallContent.x - columnFrame.minX,
+ y: locationInWaterfallContent.y - columnFrame.minY
)
- guard column.cardsClipLayer.frame.contains(locationInColumn) else {
+ guard cardsClipFrame.contains(locationInColumn) else {
continue
}
let locationInCardsClip = CGPoint(
- x: locationInColumn.x - column.cardsClipLayer.frame.minX,
- y: locationInColumn.y - column.cardsClipLayer.frame.minY
+ x: locationInColumn.x - cardsClipFrame.minX,
+ y: locationInColumn.y - cardsClipFrame.minY
)
- for card in column.cards where card.containerLayer.frame.contains(locationInCardsClip) {
+ for card in column.cards where interactiveFrame(for: card.containerLayer).contains(locationInCardsClip) {
guard card.closeButton.containerLayer.opacity > 0 else { continue }
+ let cardFrame = interactiveFrame(for: card.containerLayer)
+ let closeFrame = interactiveFrame(for: card.closeButton.containerLayer)
let locationInCard = CGPoint(
- x: locationInCardsClip.x - card.containerLayer.frame.minX,
- y: locationInCardsClip.y - card.containerLayer.frame.minY
+ x: locationInCardsClip.x - cardFrame.minX,
+ y: locationInCardsClip.y - cardFrame.minY
)
- if card.closeButton.containerLayer.frame.insetBy(dx: -8, dy: -8).contains(locationInCard) {
+ if closeFrame.insetBy(dx: -8, dy: -8).contains(locationInCard) {
return .window(
appGroupIndex: card.item.appGroupIndex,
windowIndex: card.item.windowIndex,
@@ -6318,6 +6770,110 @@
return nil
}
return Self.appShelfIndexSymbols[ordinal]
+ }
+
+ private var visibleWaterfallCards: [WaterfallCardLayers] {
+ waterfallColumns.flatMap(\.cards)
+ }
+
+ private func singleVisibleWaterfallCard(appGroupIndex: Int) -> WaterfallCardLayers? {
+ let cards = visibleWaterfallCards.filter { $0.item.appGroupIndex == appGroupIndex }
+ return cards.count == 1 ? cards[0] : nil
+ }
+
+ private var windowShortcutFilterDimOpacity: Float {
+ resolvedTheme == .dark ? 0.44 : 0.38
+ }
+
+ private func windowShortcutFilterState(for card: WaterfallCardLayers) -> WindowShortcutFilterState {
+ switch windowShortcutFilterPhase {
+ case .appPending:
+ guard let pending = windowIndexKeyPending else { return .none }
+ return card.item.appGroupIndex == pending.appGroupIndex ? .matched : .dimmed
+ case .targetPreCommit:
+ guard let snapshot = lastWindowShortcutPreCommitFilterSnapshot else { return .none }
+ if card.item.window.id == snapshot.targetWindowID {
+ return .target
+ }
+ if snapshot.dimmedWindowIDs.contains(card.item.window.id) {
+ return .dimmed
+ }
+ if snapshot.matchedWindowIDs.contains(card.item.window.id) {
+ return .matched
+ }
+ return .none
+ case .none, .invalid, .expired:
+ return .none
+ }
+ }
+
+ private func makeWindowShortcutPreCommitFilterSnapshot(
+ target card: WaterfallCardLayers,
+ code: String
+ ) -> WindowShortcutPreCommitFilterSnapshot {
+ let targetWindowID = card.item.window.id
+ let allWindowIDs = visibleWaterfallCards.map { $0.item.window.id }
+ return WindowShortcutPreCommitFilterSnapshot(
+ targetCode: code,
+ targetWindowID: targetWindowID,
+ matchedWindowIDs: [targetWindowID],
+ dimmedWindowIDs: allWindowIDs.filter { $0 != targetWindowID }.sorted()
+ )
+ }
+
+ private func makeWindowShortcutFilterReport() -> WindowShortcutFilterReport {
+ switch windowShortcutFilterPhase {
+ case .appPending:
+ guard let pending = windowIndexKeyPending else {
+ return emptyWindowShortcutFilterReport(phase: .none)
+ }
+ let cards = visibleWaterfallCards
+ let matched = cards
+ .filter { $0.item.appGroupIndex == pending.appGroupIndex }
+ .map { $0.item.window.id }
+ .sorted()
+ let dimmed = cards
+ .filter { $0.item.appGroupIndex != pending.appGroupIndex }
+ .map { $0.item.window.id }
+ .sorted()
+ return WindowShortcutFilterReport(
+ active: true,
+ phase: .appPending,
+ pendingAppGroupIndex: pending.appGroupIndex,
+ prefix: pending.appSymbol,
+ matchedWindowIDs: matched,
+ dimmedWindowIDs: dimmed
+ )
+ case .targetPreCommit:
+ guard let snapshot = lastWindowShortcutPreCommitFilterSnapshot else {
+ return emptyWindowShortcutFilterReport(phase: .none)
+ }
+ return WindowShortcutFilterReport(
+ active: true,
+ phase: .targetPreCommit,
+ pendingAppGroupIndex: nil,
+ prefix: snapshot.targetCode,
+ matchedWindowIDs: snapshot.matchedWindowIDs,
+ dimmedWindowIDs: snapshot.dimmedWindowIDs
+ )
+ case .invalid, .expired:
+ return emptyWindowShortcutFilterReport(phase: windowShortcutFilterPhase)
+ case .none:
+ return emptyWindowShortcutFilterReport(phase: .none)
+ }
+ }
+
+ private func emptyWindowShortcutFilterReport(
+ phase: WindowShortcutFilterPhase
+ ) -> WindowShortcutFilterReport {
+ WindowShortcutFilterReport(
+ active: false,
+ phase: phase,
+ pendingAppGroupIndex: nil,
+ prefix: nil,
+ matchedWindowIDs: [],
+ dimmedWindowIDs: []
+ )
}
private func waterfallStateText(for card: QuickSwitchWindowCardViewModel) -> String {
@@ -6656,6 +7212,7 @@
private func appShelfItemReports() -> [[String: Any]] {
appShelfItems.enumerated().map { index, item in
let visibleFrame = item.containerLayer.frame.offsetBy(dx: appShelfContentLayer.frame.minX, dy: 0)
+ let magneticState = appShelfMagneticState(for: item)
return [
"index": index,
"name": item.item.app.name,
@@ -6666,13 +7223,25 @@
"isSelected": item.item.appGroupIndex == effectiveSelection?.appGroupIndex,
"isHovered": item.item.appGroupIndex == effectiveHoveredAppGroupIndex,
"isSpaceFocused": spaceFocusWindowCount(for: item.item.appGroupIndex) > 0,
+ "isMagneticNeighbor": magneticState.isNeighbor,
+ "magneticInfluence": Double(magneticState.influence),
+ "magneticLift": Double(magneticState.lift),
"visualStates": appShelfVisualStates(for: item),
"zPosition": Double(item.containerLayer.zPosition),
"hasMinimizedWindows": item.item.hasMinimizedWindows,
"hasFullscreenWindows": item.item.hasFullscreenWindows,
"frame": dictionary(from: item.containerLayer.frame),
"visibleFrame": dictionary(from: visibleFrame),
+ "containerBorderWidth": Double(item.containerLayer.borderWidth),
+ "containerBorderColor": colorDictionary(from: item.containerLayer.borderColor),
"iconFrame": dictionary(from: item.iconLayer.frame),
+ "iconBorderWidth": Double(item.iconLayer.borderWidth),
+ "iconBorderColor": colorDictionary(from: item.iconLayer.borderColor),
+ "backgroundFrame": dictionary(from: item.backgroundLayer.frame),
+ "backgroundColor": colorDictionary(from: item.backgroundLayer.backgroundColor),
+ "backgroundBorderWidth": Double(item.backgroundLayer.borderWidth),
+ "backgroundShadowOpacity": Double(item.backgroundLayer.shadowOpacity),
+ "backgroundShadowRadius": Double(item.backgroundLayer.shadowRadius),
"indexText": item.indexLayer.string ?? "",
"indexFrame": dictionary(from: item.indexLayer.frame),
"indexVisible": !item.indexLayer.isHidden && item.indexLayer.opacity > 0,
@@ -6685,6 +7254,7 @@
"badgeText": item.badgeLayer.string ?? "",
"closeButtonVisible": item.closeButton.containerLayer.opacity > 0,
"closeButtonFrame": dictionary(from: item.closeButton.containerLayer.frame),
+ "closeButtonHitFrame": dictionary(from: appShelfCloseHitFrame(for: item.closeButton.containerLayer.frame)),
"closeButtonSize": Double(item.closeButton.containerLayer.bounds.width),
"closeButtonFillColor": colorDictionary(from: item.closeButton.containerLayer.backgroundColor),
"closeButtonGlyphColor": colorDictionary(from: item.closeButton.glyphLayer.strokeColor),
@@ -6697,6 +7267,7 @@
var states: [String] = []
let isSelected = item.item.appGroupIndex == effectiveSelection?.appGroupIndex
let isHovered = item.item.appGroupIndex == effectiveHoveredAppGroupIndex
+ let magneticState = appShelfMagneticState(for: item)
if shouldShowSelectedVisual(isSelected: isSelected, isHovered: isHovered) {
states.append("selected")
} else if isSelected {
@@ -6704,6 +7275,9 @@
}
if isHovered {
states.append("hover")
+ }
+ if magneticState.isNeighbor {
+ states.append("magneticNeighbor")
}
if spaceFocusWindowCount(for: item.item.appGroupIndex) > 0 {
states.append("spaceFocused")
@@ -6826,6 +7400,10 @@
dy: column.containerLayer.frame.minY + column.cardsClipLayer.frame.minY
)
let screenshotSource = screenshotSourcesByWindowID[card.item.window.id]
+ let shortcutFilterState = windowShortcutFilterState(for: card)
+ let shortcutFilterOpacity = shortcutFilterState == .dimmed
+ ? windowShortcutFilterDimOpacity
+ : Float(1)
var report = [
"appGroupIndex": card.item.appGroupIndex,
@@ -6844,6 +7422,8 @@
"isSelected": card.item.window.id == effectiveSelection?.windowID,
"isKeyboardFocused": card.item.window.id == keyboardFocusedWindowID,
"isHorizontalAppDefault": isHorizontalAppDefaultCard(card),
+ "windowShortcutFilterState": shortcutFilterState.rawValue,
+ "windowShortcutFilterOpacity": Double(shortcutFilterOpacity),
"visualStates": waterfallCardVisualStates(for: card),
"thumbnailStrategy": thumbnailStrategyString(for: card.item.window),
"screenshotSource": screenshotSourceString(screenshotSource, for: card.item.window),
@@ -6988,6 +7568,16 @@
if isWaterfallCardSpaceFocused(card) {
states.append("spaceFocused")
}
+ switch windowShortcutFilterState(for: card) {
+ case .matched:
+ states.append("shortcutMatched")
+ case .dimmed:
+ states.append("shortcutDimmed")
+ case .target:
+ states.append("shortcutTarget")
+ case .none:
+ break
+ }
if card.item.window.isMinimized {
states.append("minimized")
}
@@ -7035,6 +7625,10 @@
}
let isAppAssociated = appHoverAssociatedSpaceIDs.contains(space.id)
let isWindowAssociated = space.id == windowHoverAssociatedSpaceID
+ let isLocked = space.id == currentViewModel?.lockedSpaceID
+ let isActive = space.id == activeSpaceFocusID || isLocked
+ let isAssociated = (isAppAssociated || isWindowAssociated) && !isActive
+ let usesLightActiveFill = resolvedTheme == .dark && space.windowCount > 0 && !isLocked && (isActive || isAssociated)
let group = spaceLaneDisplayGroup(containingSpaceID: space.id)
let visibleFrame = segment.containerLayer.frame.offsetBy(
dx: (group?.containerLayer.frame.minX ?? 0) + spaceLaneContentLayer.frame.minX,
@@ -7053,6 +7647,8 @@
"label": space.label,
"type": spaceTypeName(space.type),
"visualStates": visualStates(for: space),
+ "usesLightActiveFill": usesLightActiveFill,
+ "foregroundContrastStyle": usesLightActiveFill ? "darkOnLight" : "themeDefault",
"fullscreenMarkerVisible": segment.fullscreenMarkerLayer != nil,
"fullscreenMarkerKind": fullscreenMarkerKind(
markerLayer: segment.fullscreenMarkerLayer,
--
Gitblit v1.9.3