55// Created by Kai Azim on 2026-01-30.
66//
77
8- import Subsurface
98import Scribe
9+ import Subsurface
1010import SwiftUI
1111
1212@Loggable
@@ -27,7 +27,7 @@ final class MultitouchTrigger {
2727 private var maxTouchesInCurrentGesture: Int = 0
2828 private var isCurrentGestureRejected = false
2929 private var didOpenLoopWithThisGesture = false
30-
30+
3131 private var lastTriggeredActionIndex: Int?
3232 private var lastTriggeredDistance: CGFloat = 0
3333 private var lastTriggeredZoomDistance: CGFloat = 0
@@ -40,7 +40,7 @@ final class MultitouchTrigger {
4040 }
4141
4242 private var positionHistory: [PositionHistoryEntry] = []
43- private let maxHistoryEntries = 5 // Track last 5 positions for smoothing
43+ private let maxHistoryEntries = 5 // Track last 5 positions for smoothing
4444
4545 private let initialGestureThreshold: CGFloat = 0.025
4646 private let gestureRepeatThreshold: CGFloat = 0.25
@@ -122,7 +122,7 @@ final class MultitouchTrigger {
122122 guard let originInfo = originGestureInfo, let lastInfo = lastGestureInfo else {
123123 // Check if cursor is over a titlebar before activating
124124 guard isCursorOverTitlebar() else {
125- isCurrentGestureRejected = true // Mark as rejected to skip future events
125+ isCurrentGestureRejected = true // Mark as rejected to skip future events
126126 return
127127 }
128128
@@ -132,7 +132,7 @@ final class MultitouchTrigger {
132132 lastGestureInfo = info
133133 lastTriggeredActionIndex = nil
134134 lastTriggeredDistance = 0
135- lastTriggeredZoomDistance = info.distance // Initialize to current finger distance
135+ lastTriggeredZoomDistance = info.distance // Initialize to current finger distance
136136 gestureBlocker.start()
137137
138138 // Reset position history for new gesture
@@ -179,7 +179,7 @@ final class MultitouchTrigger {
179179 if let oldFingerDistance = fingerDistanceFromHistory() {
180180 // Use position history for stable detection
181181 let distanceChange = fingerDistance - oldFingerDistance
182- isZooming = distanceChange > initialGestureThreshold // Use initial threshold for sensitive detection
182+ isZooming = distanceChange > initialGestureThreshold // Use initial threshold for sensitive detection
183183 } else if positionHistory.count >= 1 {
184184 // Use last frame's distance if history is building up
185185 let lastFingerDistance = lastInfo.distance
@@ -206,7 +206,7 @@ final class MultitouchTrigger {
206206 lastTriggeredActionIndex = centerActionIndex
207207 lastTriggeredDistance = fingerDistance
208208 triggerAction(at: centerActionIndex, from: actions[...])
209- return // Don't process directional actions while zooming
209+ return // Don't process directional actions while zooming
210210 }
211211
212212 // Process directional actions (swiping)
@@ -238,13 +238,13 @@ final class MultitouchTrigger {
238238 magFromOrigin > 0 {
239239 let magMovement = hypot(movementDirection.width, movementDirection.height)
240240
241- if magMovement >= initialGestureThreshold { // Only if meaningful movement occurred
241+ if magMovement >= initialGestureThreshold { // Only if meaningful movement occurred
242242 let dotProduct = movementDirection.width * vectorFromOrigin.width +
243243 movementDirection.height * vectorFromOrigin.height
244244 let cosAngle = dotProduct / (magFromOrigin * magMovement)
245245
246246 // Negative dot product means moving toward origin (opposite direction)
247- if cosAngle < -0.5 { // ~120 degree threshold
247+ if cosAngle < -0.5 { // ~120 degree threshold
248248 originGestureInfo = info
249249 lastTriggeredActionIndex = nil
250250 lastTriggeredDistance = 0
@@ -325,7 +325,7 @@ final class MultitouchTrigger {
325325 lastGestureInfo = nil
326326 maxTouchesInCurrentGesture = 0
327327 didOpenLoopWithThisGesture = false
328- positionHistory.removeAll() // Clear history on gesture end
328+ positionHistory.removeAll() // Clear history on gesture end
329329 }
330330
331331 private func averagePosition(of touches: [MTContact]) -> CGPoint {
@@ -382,7 +382,7 @@ final class MultitouchTrigger {
382382 /// - Parameter cardinalBias: How much larger cardinals are relative to diagonals.
383383 /// A value of 0.1 makes cardinal zones 10% wider and diagonal zones 10% narrower than uniform (0.0 = equal sizes, 1.0 = diagonals disappear).
384384 private func indexWithCardinalBias(angle: CGFloat, actionCount: Int, cardinalBias: CGFloat = 0.1) -> Int {
385- let baseAngleSpan = (.pi * 2) / CGFloat(actionCount) // 45° for 8 actions
385+ let baseAngleSpan = (.pi * 2) / CGFloat(actionCount) // 45° for 8 actions
386386 let halfAngleSpan = baseAngleSpan / 2.0
387387
388388 // Match the original centered mapping (boundaries at ±22.5° for 8 actions)
0 commit comments