Skip to content

Commit 8844266

Browse files
committed
✨ Unify gesture terminology across codebae
1 parent d0c3da8 commit 8844266

8 files changed

Lines changed: 239 additions & 231 deletions

File tree

Loop/Core/Observers/Helpers/SystemGestureManager.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,15 @@ final class SystemGestureManager {
195195
static func reconcile(
196196
enableGestures: Bool,
197197
disableConflicts: Bool,
198-
bindings: [GestureBinding]
198+
gestures: [Gesture]
199199
) {
200200
var backups = Defaults[.systemGesturePreferenceBackups]
201201
var managedValues = Defaults[.systemGestureManagedValues]
202202

203203
Self().reconcile(
204204
enableGestures: enableGestures,
205205
disableConflicts: disableConflicts,
206-
bindings: bindings,
206+
gestures: gestures,
207207
backups: &backups,
208208
managedValues: &managedValues
209209
)
@@ -215,7 +215,7 @@ final class SystemGestureManager {
215215
func reconcile(
216216
enableGestures: Bool,
217217
disableConflicts: Bool,
218-
bindings: [GestureBinding],
218+
gestures: [Gesture],
219219
backups: inout [String: SystemGesturePreferenceValue],
220220
managedValues: inout [String: SystemGesturePreferenceValue]
221221
) {
@@ -227,7 +227,7 @@ final class SystemGestureManager {
227227
return
228228
}
229229

230-
let desiredValues = desiredValues(for: bindings, backups: backups, managedValues: managedValues)
230+
let desiredValues = desiredValues(for: gestures, backups: backups, managedValues: managedValues)
231231
guard !desiredValues.isEmpty else {
232232
restoreAll(backups: &backups, managedValues: &managedValues)
233233
return
@@ -352,12 +352,12 @@ final class SystemGestureManager {
352352
}
353353

354354
private func desiredValues(
355-
for bindings: [GestureBinding],
355+
for gestures: [Gesture],
356356
backups: [String: SystemGesturePreferenceValue],
357357
managedValues: [String: SystemGesturePreferenceValue]
358358
) -> [SystemGesturePreferenceIdentifier: SystemGesturePreferenceValue] {
359-
let hasThreeFingerGesture = bindings.contains { $0.fingerCount == 3 }
360-
let hasFourFingerGesture = bindings.contains { $0.fingerCount == 4 }
359+
let hasThreeFingerGesture = gestures.contains { $0.fingerCount == 3 }
360+
let hasFourFingerGesture = gestures.contains { $0.fingerCount == 4 }
361361

362362
guard hasThreeFingerGesture || hasFourFingerGesture else { return [:] }
363363

Loop/Core/Observers/MultitouchTrigger.swift

Lines changed: 114 additions & 114 deletions
Large diffs are not rendered by default.

Loop/Extensions/Defaults+Extensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ extension Defaults.Keys {
7272

7373
// Gestures
7474
static let enableGestures = Key<Bool>("enableGestures", default: false, iCloud: true)
75-
static let gestureBindings = Key<[GestureBinding]>("gestureBindings", default: GestureBinding.defaultBindings, iCloud: true)
75+
static let gestures = Key<[Gesture]>("gestures", default: Gesture.defaults, iCloud: true)
7676
static let disableConflictingSystemGestures = Key<Bool>("disableConflictingSystemGestures", default: true, iCloud: true)
7777
static let systemGesturePreferenceBackups = Key<[String: SystemGesturePreferenceValue]>("systemGesturePreferenceBackups", default: [:], iCloud: false)
7878
static let systemGestureManagedValues = Key<[String: SystemGesturePreferenceValue]>("systemGestureManagedValues", default: [:], iCloud: false)
@@ -148,7 +148,7 @@ extension Defaults.Keys {
148148
/// Reset with `defaults delete com.MrKai77.Loop triggerKeyTimeout`
149149
static let triggerKeyTimeout = Key<Double>("triggerKeyTimeout", default: 0, iCloud: true)
150150

151-
/// Height of the titlebar activation zone for gesture bindings, defined in points.
151+
/// Height of the titlebar activation zone for gestures, defined in points.
152152
/// Gestures with the `.titlebar` activation zone will only trigger when the cursor is within this distance from the top of a window.
153153
/// Adjust with `defaults write com.MrKai77.Loop gestureTitlebarHeight -float x`
154154
/// Reset with `defaults delete com.MrKai77.Loop gestureTitlebarHeight`

Loop/Localizable.xcstrings

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,10 @@
624624
}
625625
}
626626
},
627+
"2-finger gestures are restricted to the titlebar to avoid conflicting with system gestures." : {
628+
"comment" : "A description of the restriction on 2-finger gestures.",
629+
"isCommentAutoGenerated" : true
630+
},
627631
"A single %@ action can only track one window. To stash\nmultiple windows, add additional %@ actions." : {
628632
"comment" : "Information in a popover displaying how a stash action can only keep track of a single window. Both %1$@ and %2$@ are replaced with the language's localization of the \"Stash\" action.",
629633
"localizations" : {
@@ -5059,8 +5063,8 @@
50595063
}
50605064
}
50615065
},
5062-
"Customize this gesture binding." : {
5063-
"comment" : "A button that opens a popover for configuring a gesture binding.",
5066+
"Customize this gesture." : {
5067+
"comment" : "A tooltip that appears when a user touches a gesture configuration button.",
50645068
"isCommentAutoGenerated" : true
50655069
},
50665070
"Customize this gesture's action." : {
@@ -8093,13 +8097,13 @@
80938097
}
80948098
}
80958099
},
8096-
"Gesture Bindings" : {
8097-
"comment" : "Section header shown in gestures settings"
8098-
},
80998100
"Gesture Type" : {
81008101
"comment" : "A label describing the type of gesture.",
81018102
"isCommentAutoGenerated" : true
81028103
},
8104+
"Gestures" : {
8105+
"comment" : "Section header shown in gestures settings"
8106+
},
81038107
"Go Back" : {
81048108
"comment" : "Section header in the action picker of the Keybinds tab",
81058109
"localizations" : {
@@ -18550,8 +18554,8 @@
1855018554
}
1855118555
}
1855218556
},
18553-
"No gesture bindings" : {
18554-
"comment" : "A message displayed when there are no gesture bindings configured.",
18557+
"No gestures" : {
18558+
"comment" : "A message displayed when there are no gestures.",
1855518559
"isCommentAutoGenerated" : true
1855618560
},
1855718561
"No keybinds" : {
@@ -24020,8 +24024,8 @@
2402024024
}
2402124025
}
2402224026
},
24023-
"Press \"Add\" to add a gesture binding" : {
24024-
"comment" : "A description displayed when there are no gesture bindings configured. It instructs the user to add one.",
24027+
"Press \"Add\" to add a gesture" : {
24028+
"comment" : "A description of the action to add a gesture.",
2402524029
"isCommentAutoGenerated" : true
2402624030
},
2402724031
"Press \"Add\" to add a keybind" : {
@@ -31118,6 +31122,10 @@
3111831122
}
3111931123
}
3112031124
},
31125+
"There are other gestures that conflict with this gesture." : {
31126+
"comment" : "A tooltip that appears when a gesture has a conflicting gesture.",
31127+
"isCommentAutoGenerated" : true
31128+
},
3112131129
"There are other keybinds that conflict with this key combination." : {
3112231130
"localizations" : {
3112331131
"ar" : {

Loop/Settings Window/Settings/Gestures/GestureConfigPopoverView.swift

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ import Luminare
99
import SwiftUI
1010

1111
struct GestureConfigPopoverView: View {
12-
@State private var binding: GestureBinding
13-
@Binding private var externalBinding: GestureBinding
12+
@State private var gesture: Gesture
13+
@Binding private var externalGesture: Gesture
1414

15-
init(binding: Binding<GestureBinding>) {
16-
self.binding = binding.wrappedValue
17-
self._externalBinding = binding
15+
init(gesture: Binding<Gesture>) {
16+
self.gesture = gesture.wrappedValue
17+
self._externalGesture = gesture
1818
}
1919

20-
private var gestureTypeBinding: Binding<GestureBinding.GestureType> {
20+
private var kindBinding: Binding<Gesture.Kind> {
2121
Binding(
22-
get: { binding.gestureType },
23-
set: { newType in
24-
let oldType = binding.gestureType
25-
binding.gestureType = newType
22+
get: { gesture.kind },
23+
set: { newKind in
24+
let oldKind = gesture.kind
25+
gesture.kind = newKind
2626

27-
if newType == .radialMenu {
28-
binding.action = .radialMenuActions
29-
} else if oldType == .radialMenu {
30-
binding.action = .singleAction(.custom(.init(.noAction)))
27+
if newKind == .radialMenu {
28+
gesture.action = .radialMenuActions
29+
} else if oldKind == .radialMenu {
30+
gesture.action = .singleAction(.custom(.init(.noAction)))
3131
}
3232
}
3333
)
@@ -36,46 +36,46 @@ struct GestureConfigPopoverView: View {
3636
var body: some View {
3737
LuminareSection {
3838
LuminareCompose("Gesture Type") {
39-
Picker("", selection: gestureTypeBinding) {
40-
ForEach(Array(GestureBinding.GestureType.allCases.enumerated()), id: \.element) { _, type in
39+
Picker("", selection: kindBinding) {
40+
ForEach(Array(Gesture.Kind.allCases.enumerated()), id: \.element) { _, kind in
4141
HStack {
42-
type.image
42+
kind.image
4343
.frame(width: 12)
4444

45-
Text(type.displayName)
45+
Text(kind.displayName)
4646
}
47-
.tag(type)
47+
.tag(kind)
4848
}
4949
}
5050
.labelsHidden()
5151
}
5252

5353
LuminareCompose("Fingers") {
5454
HStack {
55-
Text("\(binding.fingerCount)")
55+
Text("\(gesture.fingerCount)")
5656

57-
Stepper("", value: $binding.fingerCount, in: 2...5)
57+
Stepper("", value: $gesture.fingerCount, in: 2...5)
5858
.labelsHidden()
59-
.onChange(of: binding.fingerCount) { count in
60-
if count <= 2 { binding.activationZone = .titlebar }
59+
.onChange(of: gesture.fingerCount) { count in
60+
if count <= 2 { gesture.activationZone = .titlebar }
6161
}
6262
}
6363
}
6464

6565
LuminareCompose("Activation Zone") {
66-
Picker("", selection: $binding.activationZone) {
67-
ForEach(GestureBinding.ActivationZone.allCases, id: \.self) { zone in
66+
Picker("", selection: $gesture.activationZone) {
67+
ForEach(Gesture.ActivationZone.allCases, id: \.self) { zone in
6868
Label(zone.displayName, systemImage: zone.systemImage)
6969
.tag(zone)
7070
}
7171
}
7272
.labelsHidden()
73-
.disabled(binding.fingerCount <= 2)
73+
.disabled(gesture.fingerCount <= 2)
7474
}
75-
.help(binding.fingerCount <= 2 ? "2-finger gestures are restricted to the titlebar to avoid conflicting with system gestures." : "")
75+
.help(gesture.fingerCount <= 2 ? "2-finger gestures are restricted to the titlebar to avoid conflicting with system gestures." : "")
7676
}
7777
.frame(maxWidth: .infinity, alignment: .leading)
78-
.onChange(of: binding) { externalBinding = $0 }
78+
.onChange(of: gesture) { externalGesture = $0 }
7979
.luminareFilledStates(.none)
8080
.luminareBorderedStates(.none)
8181
.padding(8)

Loop/Settings Window/Settings/Gestures/GestureBindingItemView.swift renamed to Loop/Settings Window/Settings/Gestures/GestureItemView.swift

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// GestureBindingItemView.swift
2+
// GestureItemView.swift
33
// Loop
44
//
55
// Created by Kai Azim on 2026-04-16.
@@ -9,27 +9,27 @@ import Defaults
99
import Luminare
1010
import SwiftUI
1111

12-
struct GestureBindingItemView: View {
12+
struct GestureItemView: View {
1313
@Environment(\.luminareAnimation) var luminareAnimation
1414

1515
@Default(.keybinds) private var keybinds
16-
@Default(.gestureBindings) private var gestureBindings
16+
@Default(.gestures) private var gestures
1717

18-
@State private var binding: GestureBinding
19-
@Binding private var externalBinding: GestureBinding
18+
@State private var gesture: Gesture
19+
@Binding private var externalGesture: Gesture
2020

2121
@State private var isActionPickerPresented = false
2222
@State private var isGestureConfigPresented = false
2323
@State private var isConfiguringCustom = false
2424
@State private var isConfiguringCycle = false
2525

26-
init(_ binding: Binding<GestureBinding>) {
27-
self.binding = binding.wrappedValue
28-
self._externalBinding = binding
26+
init(_ gesture: Binding<Gesture>) {
27+
self.gesture = gesture.wrappedValue
28+
self._externalGesture = gesture
2929
}
3030

3131
private var hasConflict: Bool {
32-
GestureBinding.conflictingIDs(in: gestureBindings).contains(binding.id)
32+
Gesture.conflictingIDs(in: gestures).contains(gesture.id)
3333
}
3434

3535
var body: some View {
@@ -43,7 +43,7 @@ struct GestureBindingItemView: View {
4343
}
4444
}
4545
.luminareToolTip(attachedTo: .topLeading, hidden: !hasConflict) {
46-
Text("There are other gesture bindings that conflict with this gesture.")
46+
Text("There are other gestures that conflict with this gesture.")
4747
.padding(6)
4848
}
4949
.frame(maxWidth: .infinity, alignment: .leading)
@@ -60,7 +60,7 @@ struct GestureBindingItemView: View {
6060
isConfiguringCycle = true
6161
}
6262
}
63-
.onChange(of: binding) { externalBinding = $0 }
63+
.onChange(of: gesture) { externalGesture = $0 }
6464
}
6565

6666
private var gestureConfiguration: some View {
@@ -79,7 +79,7 @@ struct GestureBindingItemView: View {
7979
.luminareBorderedStates(.hovering)
8080
.luminareMinHeight(24)
8181
.opacity(hasConflict ? 0.5 : 1)
82-
.help("Customize this gesture binding.")
82+
.help("Customize this gesture.")
8383
.padding(.leading, -4)
8484
.luminarePopover(
8585
isPresented: $isGestureConfigPresented,
@@ -88,7 +88,7 @@ struct GestureBindingItemView: View {
8888
shouldHideAnchor: true,
8989
shouldAnimate: false
9090
) {
91-
GestureConfigPopoverView(binding: $binding)
91+
GestureConfigPopoverView(gesture: $gesture)
9292
.frame(width: 300)
9393
}
9494
}
@@ -114,7 +114,7 @@ struct GestureBindingItemView: View {
114114

115115
private var actionIndicator: some View {
116116
HStack(spacing: 2) {
117-
if case .radialMenuActions = binding.action {
117+
if case .radialMenuActions = gesture.action {
118118
HStack(spacing: 4) {
119119
Image(.loop)
120120
Text("Open Radial Menu")
@@ -208,16 +208,16 @@ struct GestureBindingItemView: View {
208208
}
209209

210210
private var gestureConfigurationText: String {
211-
switch binding.gestureType {
211+
switch gesture.kind {
212212
case .radialMenu:
213-
"\(binding.fingerCount)-finger Gesture"
213+
"\(gesture.fingerCount)-finger Gesture"
214214
default:
215-
"\(binding.fingerCount)-finger \(binding.gestureType.displayName)"
215+
"\(gesture.fingerCount)-finger \(gesture.kind.displayName)"
216216
}
217217
}
218218

219219
private var resolvedAction: WindowAction? {
220-
switch binding.action {
220+
switch gesture.action {
221221
case .radialMenuActions:
222222
nil
223223
case let .singleAction(actionType):
@@ -228,13 +228,13 @@ struct GestureBindingItemView: View {
228228
private var actionTypeBinding: Binding<RadialMenuAction.ActionType> {
229229
Binding(
230230
get: {
231-
if case let .singleAction(actionType) = binding.action {
231+
if case let .singleAction(actionType) = gesture.action {
232232
return actionType
233233
}
234234
return .custom(.init(.noAction))
235235
},
236236
set: { newValue in
237-
binding.action = .singleAction(newValue)
237+
gesture.action = .singleAction(newValue)
238238
}
239239
)
240240
}
@@ -245,10 +245,10 @@ struct GestureBindingItemView: View {
245245
resolvedAction ?? .init(.noAction)
246246
},
247247
set: { newAction in
248-
if case let .singleAction(actionType) = binding.action {
248+
if case let .singleAction(actionType) = gesture.action {
249249
switch actionType {
250250
case .custom:
251-
binding.action = .singleAction(.custom(newAction))
251+
gesture.action = .singleAction(.custom(newAction))
252252
case let .keybindReference(id):
253253
if let index = Defaults[.keybinds].firstIndex(where: { $0.id == id }) {
254254
keybinds[index] = newAction

0 commit comments

Comments
 (0)