Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions prototype/App/ArrangeController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}

Expand Down Expand Up @@ -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")
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 5 additions & 8 deletions prototype/App/CalendarPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion prototype/App/CountdownTimerCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)?
Expand Down
4 changes: 2 additions & 2 deletions prototype/App/FaceObservationSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
2 changes: 0 additions & 2 deletions prototype/App/FileDragSensor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
44 changes: 0 additions & 44 deletions prototype/App/FocusRestReturnMonitor.swift

This file was deleted.

2 changes: 1 addition & 1 deletion prototype/App/FocusTimerCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion prototype/App/Launchpad.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// 拖出去多少页(往左拖为正)。
Expand Down
2 changes: 1 addition & 1 deletion prototype/App/LaunchpadView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion prototype/App/Notch/NotchContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion prototype/App/Notch/NotchController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
3 changes: 0 additions & 3 deletions prototype/App/NotchLevelControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down
18 changes: 3 additions & 15 deletions prototype/App/WS2AppRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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") }
Expand Down
5 changes: 2 additions & 3 deletions prototype/App/WS2ConductorSettingsCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
9 changes: 2 additions & 7 deletions prototype/App/WS2FocusWindowPort.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 3 additions & 19 deletions prototype/App/WS2GameControllerBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void,Never>?
var ownsHandler = false
var previousQueue: DispatchQueue?
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)) }
Expand Down
2 changes: 1 addition & 1 deletion prototype/App/WS2GestureRows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading