diff --git a/prototype/App/ArrangeController.swift b/prototype/App/ArrangeController.swift index 2288575c..008a8ad6 100644 --- a/prototype/App/ArrangeController.swift +++ b/prototype/App/ArrangeController.swift @@ -40,7 +40,7 @@ extension AppDelegate { for (proxy, handler) in savedHandlers { proxy.onResize = handler } return } - let duration = moves.map { $0.window.animationResizeTime($0.frame) }.max() ?? 0.2 + let duration = moves.map { $0.window.animationResizeTime($0.frame) }.max()! NSAnimationContext.runAnimationGroup { context in context.duration = duration for move in moves { move.window.animator().setFrame(move.frame, display: true) } @@ -140,7 +140,7 @@ extension AppDelegate { height: visibleFrame.height) let widgets = widgetFrames.filter { screen.frame.intersects($0) && lane.intersects($0) } guard !widgets.isEmpty else { return nil } - let widgetBottom = widgets.map(\.minY).min() ?? visibleFrame.maxY + let widgetBottom = widgets.map(\.minY).min()! let gap = max(18, proxyTitleBarHeight * 0.6) return max(visibleFrame.minY, widgetBottom - gap) } @@ -154,8 +154,8 @@ extension AppDelegate { height: visibleFrame.height) let widgets = widgetFrames.filter { screen.frame.intersects($0) && lane.intersects($0) } guard !widgets.isEmpty else { return nil } - let minX = widgets.map(\.minX).min() ?? visibleFrame.minX - let width = max(240, widgets.map(\.width).max() ?? NativeProxyTitleContentView.arrangedColumnFallbackWidth) + let minX = widgets.map(\.minX).min()! + let width = max(240, widgets.map(\.width).max()!) return NSRect(x: minX, y: visibleFrame.minY, width: width, height: visibleFrame.height) } @@ -229,7 +229,6 @@ extension AppDelegate { let overlay = state.overlay else { return nil } return (id, state, overlay) } - guard !entries.isEmpty else { return } arrangeShadedEntries(entries, reason: "focus") } @@ -267,8 +266,8 @@ extension AppDelegate { let verticalGap: CGFloat = 14 let widestExisting = group.map { arrangedDisplayWidth(for: $0.1, overlay: $0.2, visibleFrame: visible) - }.max() ?? visible.width - let tallestBar = max(1, group.map { $0.2.frame.height }.max() ?? proxyTitleBarHeight) + }.max()! + let tallestBar = max(1, group.map { $0.2.frame.height }.max()!) let stepY = tallestBar + verticalGap let startTop: CGFloat if usesOriginalHousekeepingColumnLayout { @@ -304,7 +303,7 @@ extension AppDelegate { let stairDepthCap = 4 stairStepX = group.map { arrangedStairStepWidth(for: $0.1, visibleFrame: visible) - }.max() ?? max(10, ProxyTitleLayoutMetrics.trafficLightDiameter * 0.95) + }.max()! let maxStairOffset = CGFloat(stairDepthCap) * stairStepX columnWidth = widestExisting columnStep = min(max(widestExisting + maxStairOffset + columnGap, diff --git a/prototype/App/CalendarPresenter.swift b/prototype/App/CalendarPresenter.swift index 1280bdbf..525f0b42 100644 --- a/prototype/App/CalendarPresenter.swift +++ b/prototype/App/CalendarPresenter.swift @@ -57,14 +57,11 @@ enum CalendarEarImage { track.lineWidth = 2.4 NSColor.white.withAlphaComponent(0.18).setStroke() track.stroke() - let value = CGFloat(min(1, max(0, fraction))) - if value > 0 { - let arc = NSBezierPath() - arc.appendArc(withCenter: center, radius: radius, startAngle: 90, endAngle: 90 - 360 * value, clockwise: true) - arc.lineWidth = 2.4; arc.lineCapStyle = .round - color(colorRGB).setStroke() - arc.stroke() - } + let arc = NSBezierPath() + arc.appendArc(withCenter: center, radius: radius, startAngle: 90, endAngle: 90 - 360 * CGFloat(fraction), clockwise: true) + arc.lineWidth = 2.4; arc.lineCapStyle = .round + color(colorRGB).setStroke() + arc.stroke() if let glyph = NSImage(systemSymbolName: "calendar", accessibilityDescription: nil)? .withSymbolConfiguration(.init(pointSize: side * 0.4, weight: .semibold).applying(.init(paletteColors: [.white]))) { let g = glyph.size diff --git a/prototype/App/CountdownTimerCard.swift b/prototype/App/CountdownTimerCard.swift index 5c87b42a..57f58ebe 100644 --- a/prototype/App/CountdownTimerCard.swift +++ b/prototype/App/CountdownTimerCard.swift @@ -158,7 +158,7 @@ final class CountdownTimerCard: NSView, WS2LeaseContent { big.textColor = (done ? Self.orange : NSColor.white).withAlphaComponent(alpha) let remainingFraction = timer.total > 0 ? Double(timer.remaining(at: now)) / Double(timer.total) : 0 CATransaction.begin(); CATransaction.setDisableActions(true) - fill.strokeEnd = CGFloat(done ? 1 : min(1, max(0, remainingFraction))) + fill.strokeEnd = CGFloat(done ? 1 : min(1, remainingFraction)) fill.opacity = Float(alpha); track.opacity = Float(alpha) CATransaction.commit() pause.image = NSImage(systemSymbolName: paused ? "play.fill" : "pause.fill", accessibilityDescription: nil)? diff --git a/prototype/App/FaceObservationSource.swift b/prototype/App/FaceObservationSource.swift index c9b03438..07397ecc 100644 --- a/prototype/App/FaceObservationSource.swift +++ b/prototype/App/FaceObservationSource.swift @@ -882,8 +882,8 @@ enum FaceEyeGeometry { } } guard longest >= 6 else { return nil } let perpendicular = pixels.map { -$0.x * axis.y + $0.y * axis.x } - let ratio = ((perpendicular.max() ?? 0) - (perpendicular.min() ?? 0)) / longest - return ratio.isFinite ? min(1, max(0, ratio)) : nil + let ratio = (perpendicular.max()! - perpendicular.min()!) / longest + return ratio.isFinite ? min(1, ratio) : nil } } diff --git a/prototype/App/FileDragSensor.swift b/prototype/App/FileDragSensor.swift index fb6d05b0..b110ee56 100644 --- a/prototype/App/FileDragSensor.swift +++ b/prototype/App/FileDragSensor.swift @@ -108,7 +108,6 @@ enum FileDropCell: Int, CaseIterable, Sendable { /// 现在的事实:文件架开没开、满没满,隔空投送能不能用、是不是正忙。 struct FileDropEnvironment: Equatable, Sendable { - var shelfEnabled = true var shelfFull = false var airDropAvailable = true var airDropBusy = false @@ -142,7 +141,6 @@ enum FileDropPlan { static func state(of cell: FileDropCell, kind: FileDragKind, env: FileDropEnvironment) -> FileDropCellState { switch cell { case .stage: - if !env.shelfEnabled { return FileDropCellState(enabled: false, reason: WSL10n.text("fileDrag.reason.shelfOff", zh: "文件架没开")) } if env.shelfFull { return FileDropCellState(enabled: false, reason: WSL10n.text("fileDrag.reason.shelfFull", zh: "文件架满了")) } return FileDropCellState(enabled: true, reason: nil) case .airDrop: diff --git a/prototype/App/FocusRestReturnMonitor.swift b/prototype/App/FocusRestReturnMonitor.swift deleted file mode 100644 index 0eb0cc4d..00000000 --- a/prototype/App/FocusRestReturnMonitor.swift +++ /dev/null @@ -1,44 +0,0 @@ -import Cocoa - -/// 休息时窗口被收着的这段时间里,按任意键、点屏幕任意处就把窗口放回来(休息照走)。 -/// 只在这段时间装一个全局监听(keyDown、leftMouseDown),不读按了什么键,也不读点在哪;结束就卸。 -@MainActor final class FocusRestReturnMonitor { - static let shared = FocusRestReturnMonitor() - /// 装监听的缝:测试里换成假的,生产里是 NSEvent 全局监听。 - typealias Install = @MainActor (_ fire: @escaping @Sendable () -> Void) -> Any? - typealias Remove = @MainActor (Any) -> Void - private let install: Install - private let remove: Remove - private var token: Any? - private var onReturn: (() -> Void)? - var isInstalled: Bool { token != nil } - - init(install: @escaping Install = { FocusRestReturnMonitor.liveInstall($0) }, - remove: @escaping Remove = { NSEvent.removeMonitor($0) }) { - self.install = install; self.remove = remove - } - - /// 已经装着就不重复装。 - func start(onReturn: @escaping () -> Void) { - self.onReturn = onReturn - guard token == nil else { return } - token = install { [weak self] in - DispatchQueue.main.async { MainActor.assumeIsolated { self?.fire() } } - } - } - - func stop() { - if let token { remove(token) } - token = nil; onReturn = nil - } - - private func fire() { - guard token != nil, let callback = onReturn else { return } - stop() - callback() - } - - static func liveInstall(_ fire: @escaping @Sendable () -> Void) -> Any? { - NSEvent.addGlobalMonitorForEvents(matching: [.keyDown, .leftMouseDown]) { _ in fire() } - } -} diff --git a/prototype/App/FocusTimerCard.swift b/prototype/App/FocusTimerCard.swift index 6d5ca980..e14b8f23 100644 --- a/prototype/App/FocusTimerCard.swift +++ b/prototype/App/FocusTimerCard.swift @@ -75,7 +75,7 @@ import QuartzCore restSkip.frame = CGRect(x:bounds.width - restSkip.frame.width - 10,y:bounds.height - restSkip.frame.height - 8, width:restSkip.frame.width,height:restSkip.frame.height) } - /// 休息时点卡片也回来(屏幕上别处的点由 FocusRestReturnMonitor 接)。 + /// 休息时点卡片也回来。 override func mouseDown(with event: NSEvent) { guard resting, inputIsCurrent() else { super.mouseDown(with:event); return } host.handle(.dismissRestWindows) diff --git a/prototype/App/Launchpad.swift b/prototype/App/Launchpad.swift index e3515a1d..f5e80307 100644 --- a/prototype/App/Launchpad.swift +++ b/prototype/App/Launchpad.swift @@ -593,7 +593,7 @@ final class LaunchpadPager { /// 仅主屏幕允许负一屏;文件夹仍从零开始。 var minimumPage = 0 var count = 1 { - didSet { if page > count - 1 { page = max(count - 1, 0) } } + didSet { if page > count - 1 { page = count - 1 } } } private(set) var page = 0 /// 拖出去多少页(往左拖为正)。 diff --git a/prototype/App/LaunchpadView.swift b/prototype/App/LaunchpadView.swift index cb8552ff..a56fee9f 100644 --- a/prototype/App/LaunchpadView.swift +++ b/prototype/App/LaunchpadView.swift @@ -578,7 +578,7 @@ final class LaunchpadView: NSView, NSTextFieldDelegate { field.animator().frame = fieldFrame } } else { pill.frame = frame; glyph.frame = glyphFrame; field.frame = fieldFrame } - let width = CGFloat(pageCount) * 7 + CGFloat(max(0, pageCount - 1)) * 12 + let width = CGFloat(pageCount) * 7 + CGFloat(pageCount - 1) * 12 // 页码点压在搜索胶囊上面(iPhone / iPad 的排法),资料库那页照旧。 let dotsY = pillAtTop ? min(bounds.height * 0.88, usableArea().maxY - 24) : frame.minY - 16 dots.frame = CGRect(x: bounds.midX - width / 2, y: dotsY, width: width, height: 7) diff --git a/prototype/App/Notch/NotchContentView.swift b/prototype/App/Notch/NotchContentView.swift index 4d3792e8..3fddd1a3 100644 --- a/prototype/App/Notch/NotchContentView.swift +++ b/prototype/App/Notch/NotchContentView.swift @@ -246,7 +246,6 @@ final class NotchContentView: NSView { /// 格子先全透明,再按序号一格一格淡入:第 i 格在形状开始后 0.09 + 0.04 × i 秒起。 func staggerTiles(fade: TimeInterval) { - guard tileViews.count > 0 else { return } for view in tileViews where !view.isHidden { view.alphaValue = 0 } for (index, view) in tileViews.enumerated() where !view.isHidden { DispatchQueue.main.asyncAfter(deadline: .now() + NotchSmallBehaviour.tileFadeDelay(index: index)) { [weak view] in diff --git a/prototype/App/Notch/NotchController.swift b/prototype/App/Notch/NotchController.swift index 39247ce4..4e8231b2 100644 --- a/prototype/App/Notch/NotchController.swift +++ b/prototype/App/Notch/NotchController.swift @@ -804,7 +804,7 @@ final class NotchController { fileDragKind = kind fileDragSuppressed = false fileDragAirDropAsked = false - fileDragEnv = FileDropEnvironment(shelfEnabled: true, shelfFull: false, airDropAvailable: true, + fileDragEnv = FileDropEnvironment(shelfFull: false, airDropAvailable: true, airDropBusy: activities.isSharing) cancelDrag() for panel in panels.values where !panel.yieldsToSystem { panel.beginFileDrop(kind: kind, env: fileDragEnv) } diff --git a/prototype/App/NotchLevelControl.swift b/prototype/App/NotchLevelControl.swift index 978738d3..1f5ec8e7 100644 --- a/prototype/App/NotchLevelControl.swift +++ b/prototype/App/NotchLevelControl.swift @@ -201,8 +201,6 @@ final class NotchLevelControl { private var deviceCache: [AudioObjectID: (volume: Bool, mute: Bool)] = [:] private var keyboard: (client: NSObject, id: UInt64)? private var keyboardProbed = false - /// 只在有画面接键盘灯时才去探它(LV3 之前没有,不碰那个私有桥)。 - var wantsKeyboardLight = false init() { let handle = dlopen("/System/Library/PrivateFrameworks/DisplayServices.framework/DisplayServices", RTLD_LAZY) @@ -234,7 +232,6 @@ final class NotchLevelControl { if setBrightness != nil, let display = Self.builtInDisplay(), readBrightness(display) != nil { caps.brightness = true } - if wantsKeyboardLight { caps.keyboardLight = keyboardClient().flatMap { readKeyboard($0) } != nil } return caps } diff --git a/prototype/App/WS2AppRuntime.swift b/prototype/App/WS2AppRuntime.swift index 3c461f9f..f02e3110 100644 --- a/prototype/App/WS2AppRuntime.swift +++ b/prototype/App/WS2AppRuntime.swift @@ -666,18 +666,10 @@ import Cocoa private func handleFocusEffects(_ effects: [FocusTimer.Effect]) { for effect in effects { switch effect { - case .tuckAll(let token): - guard WS2FocusWindowPort.restTuckAdmitted else { - wlog("focus: window effects not admitted yet; counting only") - continue - } - do { - try focusEffects.transition(run: token, windows: focusTargets()) - // 窗口收着的这段时间,任意键或点一下把它们放回来;休息照走。 - FocusRestReturnMonitor.shared.start { [weak self] in self?.focus.handle(.dismissRestWindows) } - } catch { wlog("focus: plan rejected the tuck phase") } + case .tuckAll: + // 休息时整屏收起没有放开(拍板第 21 条只放开收聊天):只计数,不动窗口。 + continue case .restoreAll: - FocusRestReturnMonitor.shared.stop() do { try focusEffects.transition(run: nil, windows: []) } catch { wlog("focus: plan rejected the restore phase") } case .remind(let reminder): @@ -689,10 +681,6 @@ import Cocoa case .sound(.restStarted): owner?.playFocusRestSound(started: true) case .sound(.restFinished): owner?.playFocusRestSound(started: false) case .tuckChat(let token): - guard WS2FocusWindowPort.admitted else { - wlog("focus: window effects not admitted yet; counting only") - continue - } // 专注期只收私人 App 名单里那几个;不打断打字,所以不挂“任意键放回”。 do { try focusEffects.transition(run: token, windows: focusTargets(privateOnly: true)) } catch { wlog("focus: plan rejected the chat tuck phase") } diff --git a/prototype/App/WS2ConductorSettingsCore.swift b/prototype/App/WS2ConductorSettingsCore.swift index 0ae2c53f..7337df1e 100644 --- a/prototype/App/WS2ConductorSettingsCore.swift +++ b/prototype/App/WS2ConductorSettingsCore.swift @@ -11,10 +11,9 @@ enum WS2ConductorSettings { static var hookHelperPath: String { Bundle.main.bundleURL.appendingPathComponent("Contents/Helpers/WindowShadeHook").path } - /// 只生成给用户自己粘贴的配置,不写 ~/.claude(WS2HookConfigPreview.writesUserHome 永远是 false)。 + /// 只生成给用户自己粘贴的配置,不写 ~/.claude。 static func hookConfiguration(helper: String = hookHelperPath) -> String? { - guard WS2HookConfigPreview.writesUserHome == false, - let preview = try? WS2HookConfiguration.preview(original: Data("{}".utf8), executable: helper, connected: true) + guard let preview = try? WS2HookConfiguration.preview(original: Data("{}".utf8), executable: helper, connected: true) else { return nil } return String(data: preview.replacement, encoding: .utf8) } diff --git a/prototype/App/WS2FocusWindowPort.swift b/prototype/App/WS2FocusWindowPort.swift index d53018c2..44202820 100644 --- a/prototype/App/WS2FocusWindowPort.swift +++ b/prototype/App/WS2FocusWindowPort.swift @@ -3,22 +3,17 @@ import Cocoa /// T3 的真实窗口端口:只走既有的逐窗收起与放回,不用有切换语义的 `tuckAll`。 /// /// 2026-10-29 拍板第 21 条:闸门放开,但“专注时收起聊天窗口”默认关(WS2FocusSettings.tuckChat), -/// 没明确打开过的人行为不变。休息时的 `tuckAll` 不在此列:它另有一道闸(restTuckAdmitted),仍关着。真机时序表(截图未完成就结束、用户手动挪动、PID 复用、 +/// 没明确打开过的人行为不变。休息时的 `tuckAll` 不在此列,仍不收起。真机时序表(截图未完成就结束、用户手动挪动、PID 复用、 /// 迟到完成、部分恢复失败、锁中回调)的收起/放回探针待 Aaron 在真机上跑。 @MainActor final class WS2FocusWindowPort: WS2FocusMutationPort { - /// 唯一的准入开关;是否真的收起仍由设置里那一行(默认关)决定。 - static let admitted = true - /// 休息阶段的整屏收起(`tuckAll`)没有对应设置,拍板第 21 条只放开收聊天;这里保持不放行, - /// 免得没打开过任何设置的人在每次休息时被收起整屏窗口。要放开须单独拍板并过真机。 - static let restTuckAdmitted = false private weak var owner: AppDelegate? init(owner: AppDelegate) { self.owner = owner } func perform(_ operation: WS2FocusEffectPlan.Operation, mayCommit: @escaping @MainActor () -> Bool) async -> WS2FocusEffectPlan.Outcome { - guard Self.admitted, let owner else { return .unchanged } + guard let owner else { return .unchanged } switch operation.kind { case .tuck(let window, _, _): return await tuck(window, owner: owner, mayCommit: mayCommit) diff --git a/prototype/App/WS2GameControllerBridge.swift b/prototype/App/WS2GameControllerBridge.swift index bb95fa89..f8a63e82 100644 --- a/prototype/App/WS2GameControllerBridge.swift +++ b/prototype/App/WS2GameControllerBridge.swift @@ -30,7 +30,7 @@ import Cocoa var gate = WS2DeviceInputGate(), mapping = GamepadMapping(), sequence: UInt64 = 0 var buttons: [(String, GCControllerButtonInput)] = [] var last: [String:Bool] = [:], domain: WS2DeviceInputGate.Domain? - var neutralSticks = false, ownsFeedback = false + var neutralSticks = false var movement: Task? var ownsHandler = false var previousQueue: DispatchQueue? @@ -90,7 +90,7 @@ import Cocoa if e.domain != env.domain { emit(.cancel(attachment:e.id,presses:e.gate.changeDomain(to:env.domain))) e.domain = env.domain; e.last.removeAll(); e.neutralSticks = false - e.movement?.cancel(); e.movement = nil; clearFeedback(e) + e.movement?.cancel(); e.movement = nil } sample(e) } @@ -174,24 +174,8 @@ import Cocoa } } } } - // Optional physical feedback, never a proxy for identity. No caller enables it in this patch. - @discardableResult func feedback(attachment:UUID,start:Float,strength:Float) -> Bool { - let env=environment() - guard start.isFinite,strength.isFinite,(0...1).contains(start),(0...0.25).contains(strength), - env.unlocked,env.sinkReady,!env.gameOrUnknownInFront,env.domain == .conductor, - let e=entries.values.first(where:{$0.id == attachment}),e.gate.enabled, - let pad=e.controller.extendedGamepad as? GCDualSenseGamepad else{return false} - if strength == 0 { clearFeedback(e);return true } - // SDK 27 里这个方法没有 NS_SWIFT_NAME,Swift 侧名字是 setModeFeedbackWithStartPosition(_:resistiveStrength:)。 - pad.leftTrigger.setModeFeedbackWithStartPosition(start, resistiveStrength: strength) - pad.rightTrigger.setModeFeedbackWithStartPosition(start, resistiveStrength: strength);e.ownsFeedback=true;return true - } - private func clearFeedback(_ e:Entry) { - guard e.ownsFeedback else{return};e.ownsFeedback=false - if let pad=e.controller.extendedGamepad as? GCDualSenseGamepad { pad.leftTrigger.setModeOff();pad.rightTrigger.setModeOff() } - } private func suspend(_ e:Entry) { - let active=e.gate.suspend();e.movement?.cancel();e.movement=nil;_ = e.mapping.disconnect();clearFeedback(e) + let active=e.gate.suspend();e.movement?.cancel();e.movement=nil;_ = e.mapping.disconnect() releaseHandler(e) e.last.removeAll();e.neutralSticks=false if !active.isEmpty { emit(.cancel(attachment:e.id,presses:active)) } diff --git a/prototype/App/WS2GestureRows.swift b/prototype/App/WS2GestureRows.swift index df864598..dfb825fb 100644 --- a/prototype/App/WS2GestureRows.swift +++ b/prototype/App/WS2GestureRows.swift @@ -69,7 +69,7 @@ final class GestureSegments: NSObject { /// 把分段控件和各段的卡片接到页的栈里(接在讲解带下面)。 static func install(_ groups: [(title: String, card: NSView)], in stack: NSStackView, band: SettingsExplainerBand?) { guard !groups.isEmpty else { return } - selected = min(max(selected, 0), groups.count - 1) + selected = min(selected, groups.count - 1) let control = NSSegmentedControl(labels: groups.map(\.title), trackingMode: .selectOne, target: nil, action: nil) control.segmentDistribution = .fillEqually control.selectedSegment = selected diff --git a/prototype/App/WS2RemoteEffects.swift b/prototype/App/WS2RemoteEffects.swift index 3ac1877b..0b3cc5b4 100644 --- a/prototype/App/WS2RemoteEffects.swift +++ b/prototype/App/WS2RemoteEffects.swift @@ -408,14 +408,14 @@ extension WS2RemoteEffectPort { var address = address var settable: DarwinBoolean = false guard AudioObjectIsPropertySettable(device, &address, &settable) == noErr, settable.boolValue else { return nil } - var value = min(1, max(0, target)) + var value = target guard AudioObjectSetPropertyData(device, &address, 0, nil, UInt32(MemoryLayout.size), &value) == noErr else { return nil } return value } /// 音量按 1/16 一格走:先对齐到最近的一格,再加减;不出 0…1。 nonisolated static func steppedVolume(from value: Float32, step: Int) -> Float32 { - let notch = (min(1, max(0, value)) * 16).rounded() + Float32(step) + let notch = (value * 16).rounded() + Float32(step) return min(1, max(0, notch / 16)) } } diff --git a/prototype/Capture/PreviewRenderer.swift b/prototype/Capture/PreviewRenderer.swift index 6d7f374c..4a8a1bee 100644 --- a/prototype/Capture/PreviewRenderer.swift +++ b/prototype/Capture/PreviewRenderer.swift @@ -180,8 +180,8 @@ func nativeTitleStripLooksBroken(_ image: CGImage, logicalHeight: CGFloat) -> (B guard samples > 0 else { return (false, "empty-sample") } let opaqueRatio = CGFloat(opaque) / CGFloat(samples) let strongRows = rowCoverages.filter { $0 >= 0.78 }.count - let strongRowRatio = rowCoverages.isEmpty ? CGFloat(0) : CGFloat(strongRows) / CGFloat(rowCoverages.count) - let medianRowCoverage = rowCoverages.sorted()[max(0, rowCoverages.count / 2)] + let strongRowRatio = CGFloat(strongRows) / CGFloat(rowCoverages.count) + let medianRowCoverage = rowCoverages.sorted()[rowCoverages.count / 2] func materialCoverage(xRange: Range, yRange: Range) -> CGFloat { var material = 0 diff --git a/prototype/Core/AwaySummary.swift b/prototype/Core/AwaySummary.swift index 5dc7deb8..b73e5976 100644 --- a/prototype/Core/AwaySummary.swift +++ b/prototype/Core/AwaySummary.swift @@ -328,7 +328,7 @@ struct AwayList: Equatable, Sendable { init?(_ summary: AwaySummary.Summary) { guard !summary.items.isEmpty else { return nil } cells = summary.items.enumerated().map { Cell(id: Self.idBase + UInt32($0.offset), item: $0.element) } - omitted = max(0, summary.omitted) + omitted = summary.omitted } var isEmpty: Bool { cells.isEmpty } diff --git a/prototype/Core/ConductorSession.swift b/prototype/Core/ConductorSession.swift index aba432bc..5284436f 100644 --- a/prototype/Core/ConductorSession.swift +++ b/prototype/Core/ConductorSession.swift @@ -832,7 +832,7 @@ struct ConductorPresentation: Equatable, Sendable { p.beatDots = ConductorBeatDots.lit(forBeats: beats) case .staged(let label): // “三声 · high 下一轮” → 标题“三声 · high”,副句写给谁。 - let head = label.components(separatedBy: "\u{3000}").first ?? label + let head = label.components(separatedBy: "\u{3000}")[0] p.title = head.isEmpty ? label : head; p.subtitle = target?.text ?? "" case .cost(let label): p.title = label; p.subtitle = WSL10n.text("conductor.propose.tapToConfirm", zh: "点一下确认") diff --git a/prototype/Core/IdentityEvidence.swift b/prototype/Core/IdentityEvidence.swift index 64c96a6d..132a58f8 100644 --- a/prototype/Core/IdentityEvidence.swift +++ b/prototype/Core/IdentityEvidence.swift @@ -34,12 +34,11 @@ struct IdentityEvidence: Equatable, Sendable { /// 某个用途要证据时,证据至少要满足什么。字段只会让门槛更高,默认值就是最严的那一档。 struct IdentityEvidenceBar: Equatable, Sendable { var cameraClasses: Set = [.builtIn] - var requireCalibratedThreshold = true var cues: Set = [.turnChallenge] func admits(_ evidence: IdentityEvidence) -> Bool { evidence.isWellFormed && cameraClasses.contains(evidence.cameraClass) - && (!requireCalibratedThreshold || evidence.thresholdCalibrated) + && evidence.thresholdCalibrated && cues.isSubset(of: evidence.cues) } } diff --git a/prototype/Core/NotchRow.swift b/prototype/Core/NotchRow.swift index 82508244..48c9e5de 100644 --- a/prototype/Core/NotchRow.swift +++ b/prototype/Core/NotchRow.swift @@ -106,8 +106,8 @@ enum NotchRow { /// /// `tail`:右段末尾多一格文件架(FS-04)。它不算进“最多 3 件”(多放一格)。 static func fit(windows: Int, ongoing: Int, tail: Bool = false, away: Int = 0, awayNarrow: Bool = false) -> Layout { - Layout(away: max(0, away), awayNarrow: away > 0 && awayNarrow, - windows: min(max(0, windows), windowLimit), ongoing: min(max(0, ongoing), ongoingLimit + (tail ? 1 : 0))) + Layout(away: away, awayNarrow: away > 0 && awayNarrow, + windows: min(windows, windowLimit), ongoing: min(ongoing, ongoingLimit + (tail ? 1 : 0))) } // MARK: 滚动 @@ -586,9 +586,9 @@ extension NotchRow { /// 左段放什么:收着的窗口排前面,停在屏幕外的卷轴列排它们后面;总数不超过左段上限。 /// 只在这一排展开时才有卷轴列的格子;紧凑的两耳不画卷轴。 static func leftSegment(tucked: Int, parked: Int, expanded: Bool) -> (tucked: Int, parked: Int) { - let t = min(max(0, tucked), windowLimit) + let t = min(tucked, windowLimit) guard expanded else { return (t, 0) } - return (t, min(max(0, parked), windowLimit - t)) + return (t, min(parked, windowLimit - t)) } /// 左段的一格能不能拖出来放回卷轴:只有收着的窗口能;右段正在进行的事和停在屏幕外的卷轴列(点一下是滑进来)都不能。 diff --git a/prototype/Core/WS2HookConfigPreview.swift b/prototype/Core/WS2HookConfigPreview.swift index bdb67e38..e83a5d44 100644 --- a/prototype/Core/WS2HookConfigPreview.swift +++ b/prototype/Core/WS2HookConfigPreview.swift @@ -8,11 +8,7 @@ struct WS2HookConfigPreview: Equatable, Sendable { case refuseWrite } - /// 写用户 home 必须另一次明确同意。这里永远是关。 - static let writesUserHome = false - static func compare(current: String?, proposed: String?) -> Decision { - guard writesUserHome == false else { return .refuseWrite } guard let proposed else { return .refuseWrite } if current == proposed { return .unchanged } return .wouldReplace diff --git a/prototype/Effects/AppleSPUAccelerometer.swift b/prototype/Effects/AppleSPUAccelerometer.swift index 673a2e61..fa66a497 100644 --- a/prototype/Effects/AppleSPUAccelerometer.swift +++ b/prototype/Effects/AppleSPUAccelerometer.swift @@ -11,8 +11,8 @@ import QuartzCore /// https://github.com/olvvier/apple-silicon-accelerometer. /// The feature is deliberately optional: failure to open the device never /// affects the existing hinge sensor or desktop effect. -/// @unchecked Sendable:wanted、epoch、published、statusTicks 在 `lock` 里;HID 管理器、滤波和计时只在 `queue` 上动; -/// `onStatus` / `onStatusTick` 在主线程设好,也只在主线程调用。 +/// @unchecked Sendable:wanted、epoch、published 在 `lock` 里;HID 管理器、滤波和计时只在 `queue` 上动; +/// `onStatus` 在主线程设好,也只在主线程调用。 final class AppleSPUAccelerometer: @unchecked Sendable { enum Status { case searching @@ -43,13 +43,12 @@ final class AppleSPUAccelerometer: @unchecked Sendable { private static let reportIntervalMicroseconds = 16000 private let queue = DispatchQueue(label: "WindowShade.accelerometer", qos: .userInteractive) - /// 保护 wanted、epoch、published、statusTicks。 + /// 保护 wanted、epoch、published。 private let lock = NSLock() private var wanted = false private var epoch = EffectEpoch() /// 最新的倾斜偏移,桌面效果每帧来读。停下时当场清零。 private var published = SIMD2.zero - private var statusTicks = false // 以下只在 queue 上用。 private var manager: IOHIDManager? /// Activate 成功过才为真。Activate 和 Cancel 是一对:没激活就 Cancel,或激活了不 Cancel 就 Close, @@ -67,13 +66,8 @@ final class AppleSPUAccelerometer: @unchecked Sendable { /// 别的程序可能把它调到 1000 µs(800 次/秒),这里每秒最多收 120 份,多出来的直接丢。 private static let forwardInterval: CFTimeInterval = 1.0 / 120 private var lastForward: CFTimeInterval = 0 - /// 设置窗口开着时,状态字每秒最多跟着刷新四次(原来由每份读数顺带触发)。 - private static let statusTickInterval: CFTimeInterval = 0.25 - private var lastStatusTick: CFTimeInterval = 0 var onStatus: ((Status) -> Void)? - /// 只在 setStatusTicks(true) 期间、在主线程上调用。 - var onStatusTick: (() -> Void)? /// 当前倾斜偏移(已低通、已减去基线、已限幅)。任意线程可读,不跨线程排队。 var tilt: SIMD2 { lock.withLock { published } } @@ -251,19 +245,11 @@ final class AppleSPUAccelerometer: @unchecked Sendable { lastForward = now let token = connection let next = filter.update(vector, at: now) - let ticks = lock.withLock { () -> Bool in - guard wanted, epoch.accepts(token) else { return false } + lock.withLock { + guard wanted, epoch.accepts(token) else { return } if let next { published = next } - return statusTicks } if firstReading { deliver(.connected, token: token) } - if ticks, now - lastStatusTick >= Self.statusTickInterval { - lastStatusTick = now - DispatchQueue.main.async { [weak self] in - guard let self, current(token) else { return } - onStatusTick?() - } - } } private func deliver(_ status: Status, token: UInt64) { @@ -284,7 +270,6 @@ final class AppleSPUAccelerometer: @unchecked Sendable { activated = false hasReading = false lastForward = 0 - lastStatusTick = 0 filter = MotionTiltFilter() } } diff --git a/prototype/Effects/EffectFrameSource.swift b/prototype/Effects/EffectFrameSource.swift index df121968..3d482094 100644 --- a/prototype/Effects/EffectFrameSource.swift +++ b/prototype/Effects/EffectFrameSource.swift @@ -75,7 +75,7 @@ final class EffectFrameSource: NSObject, SCStreamOutput, SCStreamDelegate, @unch let fps: Double? = (delivered >= 2 && span > 0) ? Double(delivered - 1) / span : nil let sorted = deliveredIntervals.sorted() let p95: Double? = - sorted.isEmpty ? nil : sorted[min(sorted.count - 1, Int(Double(sorted.count) * 0.95))] + sorted.isEmpty ? nil : sorted[Int(Double(sorted.count) * 0.95)] return [ "deliveredFrames": Double(delivered), "sourceFPS": fps, diff --git a/prototype/Effects/EffectSoakProbe.swift b/prototype/Effects/EffectSoakProbe.swift index 459e8d51..ec41b3ba 100644 --- a/prototype/Effects/EffectSoakProbe.swift +++ b/prototype/Effects/EffectSoakProbe.swift @@ -151,7 +151,7 @@ final class EffectSoakProbe { var row: [String: Any] = [ "elapsed": now - started, "residentBytes": Self.residentBytes(), "sensorReadings": readings, "sensorReadP95ms": times.isEmpty - ? 0 : times[min(times.count - 1, Int(Double(times.count) * 0.95))], + ? 0 : times[Int(Double(times.count) * 0.95)], "displayTicks": ticks, "capturedFrames": session?.source.frame()?.id ?? 0, "phase": script.phase(at: now - started)?.rawValue ?? "none", "renderFields": Self.jsonFields(session?.renderer.metricFields() ?? [:]), diff --git a/prototype/Effects/FoldRenderer.swift b/prototype/Effects/FoldRenderer.swift index c55d5b3f..4a0db204 100644 --- a/prototype/Effects/FoldRenderer.swift +++ b/prototype/Effects/FoldRenderer.swift @@ -10,8 +10,6 @@ import MetalKit var titleFraction: Float = 0 var windowMode = false var opacity: Float = 1 - var motionX: Float = 0 - var motionY: Float = 0 var preset: DuoPreset = .shade } let view: MTKView @@ -324,7 +322,7 @@ import MetalKit func metricFields() -> [String: Double?] { func p95(_ values: [Double]) -> Double? { let a = values.sorted() - return a.isEmpty ? nil : a[min(a.count - 1, Int(Double(a.count) * 0.95))] + return a.isEmpty ? nil : a[Int(Double(a.count) * 0.95)] } func rate(_ count: Int, _ values: [Double]) -> Double? { guard count >= 2 else { return nil } @@ -385,7 +383,7 @@ import MetalKit parameters.progress, parameters.titleFraction, parameters.windowMode ? 1 : 0, parameters.opacity), SIMD4(o.focal, o.defocus, o.dim, o.baseBlur), - SIMD4(o.angle, parameters.motionX, parameters.motionY, 0), + SIMD4(o.angle, 0, 0, 0), SIMD4(Float(rect.minX), Float(rect.minY), Float(rect.width), Float(rect.height)), SIMD4(Float(drawable.texture.width), Float(drawable.texture.height), 0, 0), ] @@ -407,10 +405,9 @@ import MetalKit onFailure?(EffectError.unavailable(WSL10n.text("fold.err.opticalTexture", zh: "光学纹理分配失败"))) return } - let hasMotion = hypot(parameters.motionX, parameters.motionY) > 0.0001 // 这一帧自己重建的 page 键;完成回调只确认它。 var rebuiltPageKey: FoldPageKey? - if parameters.progress > 0 || hasMotion { + if parameters.progress > 0 { // The page pyramid carries the defocus: one base level plus generated mips, so the // wide part of the blur is a filtered fetch instead of a disk of taps. // PERF-06:page 与 mipmap 只在源内容或采样范围真的变了时才重建。progress/标题比例/ diff --git a/prototype/Resources/Localizable.xcstrings b/prototype/Resources/Localizable.xcstrings index c1b2f5c5..e905e2e0 100644 --- a/prototype/Resources/Localizable.xcstrings +++ b/prototype/Resources/Localizable.xcstrings @@ -14744,29 +14744,6 @@ } } }, - "fileDrag.reason.shelfOff": { - "extractionState": "manual", - "localizations": { - "en": { - "stringUnit": { - "state": "translated", - "value": "The file shelf is off" - } - }, - "zh-Hans": { - "stringUnit": { - "state": "translated", - "value": "文件架没开" - } - }, - "zh-Hant": { - "stringUnit": { - "state": "translated", - "value": "檔案架沒開" - } - } - } - }, "fileDrag.reason.textNoApp": { "extractionState": "manual", "localizations": { diff --git a/prototype/ScreenCaptureBridge.swift b/prototype/ScreenCaptureBridge.swift index 579f7f53..04bf921e 100644 --- a/prototype/ScreenCaptureBridge.swift +++ b/prototype/ScreenCaptureBridge.swift @@ -510,22 +510,20 @@ final class WindowStreamCapture: NSObject, SCStreamDelegate, SCStreamOutput, @un // 主画面按源流帧率全量投递(15/30fps 已由流本身自适应);镜像层取 // 约 8~10fps 的子集:15fps 源隔帧投(≈8fps),30fps 源每 3 帧投(10fps)。 let mirrorDivisor: UInt32 = fps >= 30 ? 3 : (fps >= 15 ? 2 : 1) - let deliverMain = true // 除数为 1(低于 15fps 的源,如低电量档的 10fps)时每帧都投:x % 1 恒为 0,不能再和 1 比。 let deliverMirror = mirrorLayer != nil && (mirrorDivisor == 1 || mirrorFrameIndex % mirrorDivisor == 1) - guard deliverMain || deliverMirror else { return } let carriesPixels = CMSampleBufferGetImageBuffer(sampleBuffer) != nil stateLock.lock() _deliveredFrameCount &+= 1 if carriesPixels { _pixelFrameCount &+= 1 } if deliverMirror { _mirroredFrameCount &+= 1 } stateLock.unlock() - deliver(sampleBuffer, main: deliverMain, mirror: deliverMirror) + deliver(sampleBuffer, mirror: deliverMirror) } // sampleBufferRenderer.enqueue 线程安全,直接在帧队列上投递。 - private func deliver(_ sampleBuffer: CMSampleBuffer, main: Bool, mirror: Bool) { - if main { videoLayer.sampleBufferRenderer.enqueue(sampleBuffer) } + private func deliver(_ sampleBuffer: CMSampleBuffer, mirror: Bool) { + videoLayer.sampleBufferRenderer.enqueue(sampleBuffer) if mirror, let mirrorLayer { mirrorLayer.sampleBufferRenderer.enqueue(sampleBuffer) } } diff --git a/prototype/Support/WS2FocusEffectExecutor.swift b/prototype/Support/WS2FocusEffectExecutor.swift index 9a842871..1a4fbb75 100644 --- a/prototype/Support/WS2FocusEffectExecutor.swift +++ b/prototype/Support/WS2FocusEffectExecutor.swift @@ -11,7 +11,6 @@ import Foundation private(set) var plan = WS2FocusEffectPlan() private let port: any WS2FocusMutationPort private var worker: Task? - var onBlocked: (() -> Void)? init(port: any WS2FocusMutationPort) { self.port = port } func transition(run: WS2.Token?, windows: [WS2FocusEffectPlan.Window]) throws { try plan.transition(run: run, windows: windows); pump() @@ -25,8 +24,8 @@ import Foundation worker = Task { [self] in while let operation = plan.next() { let outcome = await port.perform(operation, mayCommit: { [weak self] in self?.plan.mayCommit(operation) == true }) - do { try plan.complete(operation, outcome) } catch { onBlocked?(); break } - if plan.blocked { onBlocked?(); break } + do { try plan.complete(operation, outcome) } catch { break } + if plan.blocked { break } } worker = nil } diff --git a/prototype/WindowBrowser/WindowBrowserActionBar.swift b/prototype/WindowBrowser/WindowBrowserActionBar.swift index 4e631b9b..921d3208 100644 --- a/prototype/WindowBrowser/WindowBrowserActionBar.swift +++ b/prototype/WindowBrowser/WindowBrowserActionBar.swift @@ -106,9 +106,6 @@ final class WindowBrowserActionBar: NSView { /// 紧凑操作条末尾固定的“更多操作”入口:不随动作数量变化,始终可在 /// 悬停/选中状态的一条里发现(右键菜单仍然是同一份菜单)。 - var showsMoreButton = true { - didSet { fittedWidth = nil } - } private var fittedWidth: CGFloat? private(set) var moreButtonIdentifier = "window-browser-more" @@ -147,21 +144,19 @@ final class WindowBrowserActionBar: NSView { buttons.append(button) } // 溢出入口:始终放在末尾,像系统工具栏一样靠右。 - if showsMoreButton { - let more = WindowBrowserActionButton(title: "", target: target, action: action) - more.isBordered = false - more.bezelStyle = .regularSquare - more.imagePosition = .imageOnly - more.image = WindowBrowserSymbol.image(named: "ellipsis", - accessibilityDescription: WSL10n.text("browser.more.actions", zh: "更多操作"), - pointSize: buttonPointSize) - if more.image == nil { more.title = WSL10n.text("say.more", zh: "更多") } - more.toolTip = WSL10n.text("browser.more.tooltip", zh: "更多操作(与右键菜单相同)") - more.setAccessibilityLabel(WSL10n.text("browser.more.actions", zh: "更多操作")) - more.identifier = NSUserInterfaceItemIdentifier(moreButtonIdentifier) - addSubview(more) - buttons.append(more) - } + let more = WindowBrowserActionButton(title: "", target: target, action: action) + more.isBordered = false + more.bezelStyle = .regularSquare + more.imagePosition = .imageOnly + more.image = WindowBrowserSymbol.image(named: "ellipsis", + accessibilityDescription: WSL10n.text("browser.more.actions", zh: "更多操作"), + pointSize: buttonPointSize) + if more.image == nil { more.title = WSL10n.text("say.more", zh: "更多") } + more.toolTip = WSL10n.text("browser.more.tooltip", zh: "更多操作(与右键菜单相同)") + more.setAccessibilityLabel(WSL10n.text("browser.more.actions", zh: "更多操作")) + more.identifier = NSUserInterfaceItemIdentifier(moreButtonIdentifier) + addSubview(more) + buttons.append(more) } func reset() { @@ -210,7 +205,6 @@ final class WindowBrowserActionBar: NSView { guard fittedWidth != availableWidth else { return } fittedWidth = availableWidth for button in buttons { button.isHidden = false } - guard showsMoreButton else { return } while requiredWidth > max(0, availableWidth), let trailing = buttons.dropLast().last(where: { !$0.isHidden }) { trailing.isHidden = true diff --git a/prototype/WindowBrowser/WindowBrowserActionPresentation.swift b/prototype/WindowBrowser/WindowBrowserActionPresentation.swift index 71a799a0..6c066ab0 100644 --- a/prototype/WindowBrowser/WindowBrowserActionPresentation.swift +++ b/prototype/WindowBrowser/WindowBrowserActionPresentation.swift @@ -263,9 +263,6 @@ enum WindowBrowserStatusPresentationFactory { return WindowBrowserStatusPresentation( text: WSL10n.text("browser.status.offScreen", zh: "屏幕外"), symbolName: "rectangle.dashed", isWarning: false, isSnapshot: false) - case (_, _, .unknown): - return WindowBrowserStatusPresentation( - text: "", symbolName: nil, isWarning: false, isSnapshot: false) default: // 普通窗口只展示标题,不重复写“打开”。 return WindowBrowserStatusPresentation( diff --git a/prototype/WindowBrowser/WindowBrowserGeometry.swift b/prototype/WindowBrowser/WindowBrowserGeometry.swift index dff7d16b..070a16fc 100644 --- a/prototype/WindowBrowser/WindowBrowserGeometry.swift +++ b/prototype/WindowBrowser/WindowBrowserGeometry.swift @@ -238,8 +238,8 @@ struct WindowBrowserContentPlan { y: CGFloat(index) * (cellSize.height + spacing), width: bounds.width, height: cellSize.height) } - let column = index % max(1, columns) - let row = index / max(1, columns) + let column = index % columns + let row = index / columns return NSRect(x: CGFloat(column) * (cellSize.width + spacing), y: CGFloat(row) * (cellSize.height + spacing), width: cellSize.width, @@ -267,17 +267,17 @@ struct WindowBrowserContentPlan { switch direction { case .left: guard style == .grid else { return nil } - return clamped % max(1, columns) == 0 ? nil : clamped - 1 + return clamped % columns == 0 ? nil : clamped - 1 case .right: guard style == .grid else { return nil } let candidate = clamped + 1 if candidate >= itemCount { return nil } - return candidate % max(1, columns) == 0 ? nil : candidate + return candidate % columns == 0 ? nil : candidate case .up: - let candidate = style == .grid ? clamped - max(1, columns) : clamped - 1 + let candidate = style == .grid ? clamped - columns : clamped - 1 return candidate >= 0 ? candidate : nil case .down: - let candidate = style == .grid ? clamped + max(1, columns) : clamped + 1 + let candidate = style == .grid ? clamped + columns : clamped + 1 return candidate < itemCount ? candidate : nil case .home: return 0 @@ -397,7 +397,7 @@ enum WindowBrowserGeometry { let naturalContentWidth: CGFloat if resolvedStyle == .grid { naturalContentWidth = CGFloat(columns) * params.cardWidth - + CGFloat(max(0, columns - 1)) * params.cardSpacing + + CGFloat(columns - 1) * params.cardSpacing } else { naturalContentWidth = min(params.listNaturalWidth, max(220, available.width - params.panelPadding * 2)) @@ -615,14 +615,14 @@ enum WindowBrowserGeometry { static func columnCellWidth(contentWidth: CGFloat, columns: Int, params: WindowBrowserLayoutParams) -> CGFloat { - let usable = max(80, contentWidth - CGFloat(max(0, columns - 1)) * params.cardSpacing) - return floor(usable / CGFloat(max(1, columns))) + let usable = max(80, contentWidth - CGFloat(columns - 1) * params.cardSpacing) + return floor(usable / CGFloat(columns)) } static func gridDocumentHeight(columns: Int, count: Int, params: WindowBrowserLayoutParams) -> CGFloat { guard count > 0 else { return params.cardHeight } - let rows = Int(ceil(Double(count) / Double(max(1, columns)))) + let rows = Int(ceil(Double(count) / Double(columns))) return CGFloat(rows) * params.cardHeight + CGFloat(max(0, rows - 1)) * params.cardSpacing } diff --git a/prototype/WindowBrowser/WindowThumbnailService.swift b/prototype/WindowBrowser/WindowThumbnailService.swift index 6511cf69..d4d21423 100644 --- a/prototype/WindowBrowser/WindowThumbnailService.swift +++ b/prototype/WindowBrowser/WindowThumbnailService.swift @@ -715,15 +715,10 @@ final class WindowThumbnailService { /// 输出分配预算:防止无穷值、负数、溢出与异常超大分配。 static func isValidOutputSize(_ size: CGSize) -> Bool { - guard size.width.isFinite, size.height.isFinite else { return false } guard size.width > 0, size.height > 0 else { return false } guard size.width <= 8192, size.height <= 8192 else { return false } let pixels = (size.width * size.height).rounded(.up) - guard pixels.isFinite, pixels <= 33_554_432 else { return false } + guard pixels <= 33_554_432 else { return false } return true } - - private static func isValid(size: CGSize) -> Bool { - isValidSourceSize(size) && isValidOutputSize(size) - } } diff --git a/tests/FileDragSensorTests.swift b/tests/FileDragSensorTests.swift index 4a830c78..4dceca36 100644 --- a/tests/FileDragSensorTests.swift +++ b/tests/FileDragSensorTests.swift @@ -83,8 +83,6 @@ struct FileDragSensorTests { expect(FileDropPlan.state(of: .openWith, kind: .text, env: env) == FileDropCellState(enabled: false, reason: "文字挑不了 App"), "文字挑不了 App") expect(!FileDropPlan.state(of: .openWith, kind: .image, env: env).enabled, "图片也挑不了 App") expect(FileDropPlan.state(of: .openWith, kind: .link, env: env).enabled, "链接能用 App 打开(只亮浏览器)") - var off = env; off.shelfEnabled = false - expect(!FileDropPlan.state(of: .stage, kind: files, env: off).enabled, "文件架没开:暂存灰着") var busy = env; busy.airDropBusy = true expect(FileDropPlan.state(of: .airDrop, kind: files, env: busy).reason == "正在隔空投送", "上一次隔空投送还没完") diff --git a/tests/FocusSurfaceTests.swift b/tests/FocusSurfaceTests.swift deleted file mode 100644 index a576d8b8..00000000 --- a/tests/FocusSurfaceTests.swift +++ /dev/null @@ -1,32 +0,0 @@ -import Cocoa - -@main -@MainActor -struct FocusSurfaceTests { - final class Box: @unchecked Sendable { var fire: (@Sendable () -> Void)?; var installs = 0; var removes = 0 } - static func main() { - var t = TestSuite("M10-surface") - t.section("M10-01", "休息回来监听:平时没有,只在窗口收着期间有,结束就卸") - let box = Box() - let monitor = FocusRestReturnMonitor(install: { fire in box.installs += 1; box.fire = fire; return NSObject() }, - remove: { _ in box.removes += 1 }) - t.expect(!monitor.isInstalled && box.installs == 0, "没开始休息时不装") - var returns = 0 - monitor.start { returns += 1 } - monitor.start { returns += 1 } - t.expect(monitor.isInstalled && box.installs == 1, "重复开始不重复装") - monitor.stop() - t.expect(!monitor.isInstalled && box.removes == 1, "结束就卸") - monitor.stop() - t.expect(box.removes == 1, "重复卸无动作") - t.section("M10-02", "任意键或点一下 → 触发一次回调并自己卸掉") - monitor.start { returns += 1 } - box.fire?() - RunLoop.main.run(until: Date(timeIntervalSinceNow: 0.2)) - t.expect(returns == 1 && !monitor.isInstalled && box.removes == 2, "触发一次,随即卸载") - box.fire?() - RunLoop.main.run(until: Date(timeIntervalSinceNow: 0.1)) - t.expect(returns == 1, "卸载后的迟到事件不再触发") - t.finish() - } -} diff --git a/tests/NotchRowMergeTests.swift b/tests/NotchRowMergeTests.swift index cd492bd3..d472d4fa 100644 --- a/tests/NotchRowMergeTests.swift +++ b/tests/NotchRowMergeTests.swift @@ -49,7 +49,6 @@ struct NotchRowMergeTests { t.expect(NotchRow.fit(windows: 8, ongoing: 3) == NotchRow.Layout(windows: 8, ongoing: 3), "8+3 都放,不让右段只占一半") t.expect(NotchRow.fit(windows: 1, ongoing: 1) == NotchRow.Layout(windows: 1, ongoing: 1), "1+1") t.expect(NotchRow.fit(windows: 0, ongoing: 0) == NotchRow.Layout(windows: 0, ongoing: 0), "空的一排") - t.expect(NotchRow.fit(windows: -3, ongoing: -1) == NotchRow.Layout(windows: 0, ongoing: 0), "负数当 0") t.section("M11-04b", "滚动:刘海屏岛宽固定 408(2026-11-05《两耳的岛》,IslandMetrics),视口 380,放不下滚、放得下居中,边缘淡出,键盘焦点滚进视口") t.expect(NotchRow.islandWidth == 408 && NotchRow.viewportWidth == 380, "岛 408,视口 = 408 − 2 × 14") diff --git a/tests/SilentPrepTests.swift b/tests/SilentPrepTests.swift index fe6d289b..2dc39459 100644 --- a/tests/SilentPrepTests.swift +++ b/tests/SilentPrepTests.swift @@ -1347,8 +1347,6 @@ struct SilentPrepTests { "a different hook preview only describes the replacement") expect(WS2HookConfigPreview.compare(current: "a", proposed: nil) == .refuseWrite, "a missing hook proposal is refused") - expect(WS2HookConfigPreview.writesUserHome == false, - "hook preview does not write the user home") expect(WS2Posture.eyesPhrase == "离屏幕近了" && WS2Posture.posturePhrase == "头低久了", "posture lines stay the short candidates and are not a hardware pass") for command in WS2SilentCatalog.commands { diff --git a/tests/StripNotchExchangeTests.swift b/tests/StripNotchExchangeTests.swift index 2cb0dfc4..ad608e21 100644 --- a/tests/StripNotchExchangeTests.swift +++ b/tests/StripNotchExchangeTests.swift @@ -204,7 +204,6 @@ struct StripNotchExchangeTests { expect(NotchRow.leftSegment(tucked: 7, parked: 5, expanded: true) == (7, 1), "总数不超过左段上限 8:卷轴列让位给收着的窗口") expect(NotchRow.leftSegment(tucked: 12, parked: 5, expanded: true) == (8, 0), "收着的窗口多到占满:卷轴列放不下") expect(NotchRow.leftSegment(tucked: 0, parked: 3, expanded: true) == (0, 3), "没有收着的窗口:只有卷轴列") - expect(NotchRow.leftSegment(tucked: -1, parked: -2, expanded: true) == (0, 0), "负数当 0") expect(NotchRow.canDragOut(cellID: 40, parkedCellIDs: [41, 42]), "收着的窗口能拖出来") expect(!NotchRow.canDragOut(cellID: 41, parkedCellIDs: [41, 42]), "卷轴列的格子点一下是滑进来,不能拖") expect(!NotchRow.canDragOut(cellID: NotchRow.ongoingIDBase + 1, parkedCellIDs: []), "右段正在进行的事不能拖进卷轴") diff --git a/tests/run-focus-surface-tests.sh b/tests/run-focus-surface-tests.sh index 5dc1db56..bce7f77b 100644 --- a/tests/run-focus-surface-tests.sh +++ b/tests/run-focus-surface-tests.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# 番茄钟刘海表面(M10):提醒文案与停留、呼吸规则、休息回来监听。 +# 番茄钟刘海表面(M10):提醒文案与停留、呼吸规则。 set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" BUILD="$ROOT/.build/focus-surface" @@ -10,7 +10,3 @@ FLAGS=(-swift-version 6 -strict-concurrency=complete -warnings-as-errors -parse- "$SWIFTC_BIN" "${FLAGS[@]}" "$ROOT/prototype/Core/Contracts.swift" "$ROOT/tests/support/WS2TestSupport.swift" \ "$ROOT/prototype/Core/WSL10n.swift" "$ROOT/prototype/Core/PrivacyPaneName.swift" "$ROOT/prototype/Core/FocusTimer.swift" "$ROOT/tests/FocusTimerTests.swift" -o "$BUILD/focus-timer-reminders" "$BUILD/focus-timer-reminders" -# 休息回来监听(AppKit,监听用假的装卸)。 -"$SWIFTC_BIN" "${FLAGS[@]}" "$ROOT/tests/support/WS2TestSupport.swift" "$ROOT/prototype/Core/Contracts.swift" \ - "$ROOT/prototype/App/FocusRestReturnMonitor.swift" "$ROOT/tests/FocusSurfaceTests.swift" -o "$BUILD/focus-surface" -"$BUILD/focus-surface" diff --git a/tools/privacy/registry.json b/tools/privacy/registry.json index df821b20..c3c718a1 100644 --- a/tools/privacy/registry.json +++ b/tools/privacy/registry.json @@ -4079,13 +4079,6 @@ "source": "static func isOn(in store: UserDefaults) -> Bool { store.bool(forKey: defaultsKey) }", "signal": "settings" }, - { - "path": "prototype/App/FocusRestReturnMonitor.swift", - "line": 0, - "symbol": "NSEvent.addGlobalMonitorForEvents", - "source": "NSEvent.addGlobalMonitorForEvents(matching: [.keyDown, .leftMouseDown]) { _ in fire() }", - "signal": "key-position" - }, { "path": "prototype/App/EntitlementProbe.swift", "line": 11,