Skip to content

Commit

Permalink
feat: support 3 or 4 finger swipes to use the app (closes #730)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaswatB authored and lwouis committed Dec 9, 2024
1 parent 9b85f00 commit 903e758
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 34 deletions.
4 changes: 4 additions & 0 deletions alt-tab-macos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
442E26DB1F7DA80AF794CCB6 /* Pods_unit_tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C7E6F409CA442F83B7BE71AD /* Pods_unit_tests.framework */; };
4807A6C623A9CD190052A53E /* SkyLight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4807A6C523A9CD190052A53E /* SkyLight.framework */; };
48F3E16224EC0D8800A1C64B /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D04BABDA79F8EF76E3ACDD5F /* Localizable.strings */; };
5883F0A829A5182C0071DB65 /* TrackpadEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5883F0A729A5182C0071DB65 /* TrackpadEvents.swift */; };
5F21C9E02C6E94240091F72F /* ShortcutsWhenActiveSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F21C9DF2C6E94240091F72F /* ShortcutsWhenActiveSheet.swift */; };
5F21C9E22C6E94410091F72F /* AdditionalControlsSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F21C9E12C6E94410091F72F /* AdditionalControlsSheet.swift */; };
5F21C9E42C6E94700091F72F /* CustomizeStyleSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F21C9E32C6E94700091F72F /* CustomizeStyleSheet.swift */; };
Expand Down Expand Up @@ -324,6 +325,7 @@
1C961FB3DCF4906FEEF4A23D /* TableGroupView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableGroupView.swift; sourceTree = "<group>"; };
4807A6C523A9CD190052A53E /* SkyLight.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SkyLight.framework; path = ../../../../System/Library/PrivateFrameworks/SkyLight.framework; sourceTree = "<group>"; };
481FE54624D2D387001032F1 /* alt-tab-macos-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "alt-tab-macos-Bridging-Header.h"; sourceTree = "<group>"; };
5883F0A729A5182C0071DB65 /* TrackpadEvents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackpadEvents.swift; sourceTree = "<group>"; };
59DD4BE63D42EEFF1182BA7F /* Pods-alt-tab-macos.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-alt-tab-macos.release.xcconfig"; path = "Target Support Files/Pods-alt-tab-macos/Pods-alt-tab-macos.release.xcconfig"; sourceTree = "<group>"; };
5F21C9DF2C6E94240091F72F /* ShortcutsWhenActiveSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutsWhenActiveSheet.swift; sourceTree = "<group>"; };
5F21C9E12C6E94410091F72F /* AdditionalControlsSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdditionalControlsSheet.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1709,6 +1711,7 @@
D04BA76AEE37D6656EB80126 /* RunningApplicationsEvents.swift */,
D04BA5D9B4EBEB9E4333AE39 /* UserDefaultsEvents.swift */,
D04BAF320F4D43F0DDFE063E /* MouseEvents.swift */,
5883F0A729A5182C0071DB65 /* TrackpadEvents.swift */,
BF0C870C14C20C936BA4AF40 /* DockEvents.swift */,
BF0C8DF008F1EB5F23291A13 /* SpacesEvents.swift */,
BF0C822D3BEDAB1F1C9F775E /* ScreensEvents.swift */,
Expand Down Expand Up @@ -2226,6 +2229,7 @@
D04BA8757C9F20F25EB50785 /* TextField.swift in Sources */,
5F21C9E02C6E94240091F72F /* ShortcutsWhenActiveSheet.swift in Sources */,
D04BAE8B16A06A10E2FA94DE /* AccessibilityEvents.swift in Sources */,
5883F0A829A5182C0071DB65 /* TrackpadEvents.swift in Sources */,
D04BAAAF5CFA991D3B078DB8 /* KeyboardEvents.swift in Sources */,
D04BA1766FBCB2E941D081A5 /* RunningApplicationsEvents.swift in Sources */,
D04BA0AE9865276FF8EF5DEB /* UserDefaultsEvents.swift in Sources */,
Expand Down
18 changes: 18 additions & 0 deletions resources/l10n/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@
/* No comment provided by engineer. */
"Dark" = "Dark";

/* No comment provided by engineer. */
"Disabled" = "Disabled";

/* No comment provided by engineer. */
"Do nothing" = "Do nothing";

Expand Down Expand Up @@ -193,6 +196,9 @@
/* No comment provided by engineer. */
"General" = "General";

/* No comment provided by engineer. */
"Gesture" = "Gesture";

/* Menubar callout button */
"Grant permission" = "Grant permission";

Expand Down Expand Up @@ -289,6 +295,9 @@
/* No comment provided by engineer. */
"Open Screen Recording Preferences…" = "Open Screen Recording Preferences…";

/* No comment provided by engineer. */
"Open Trackpad Preferences…" = "Open Trackpad Preferences…";

/* No comment provided by engineer. */
"Optional: email (if you want a reply)" = "Optional: email (if you want a reply)";

Expand Down Expand Up @@ -475,6 +484,12 @@
/* Menubar option */
"Support this project ❤️" = "Support this project ❤️";

/* No comment provided by engineer. */
"Swipe with Four Fingers" = "Swipe with Four Fingers";

/* No comment provided by engineer. */
"Swipe with Three Fingers" = "Swipe with Three Fingers";

/* No comment provided by engineer. */
"Switch between 3 different styles. You can customize them." = "Switch between 3 different styles. You can customize them.";

Expand Down Expand Up @@ -564,3 +579,6 @@

/* No comment provided by engineer. */
"You didn’t write your email, thus can’t receive any response." = "You didn’t write your email, thus can’t receive any response.";

/* No comment provided by engineer. */
"You may need to disable some conflicting system gestures" = "You may need to disable some conflicting system gestures";
40 changes: 32 additions & 8 deletions src/logic/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Preferences {
"nextWindowShortcut3": "",
"nextWindowShortcut4": "",
"nextWindowShortcut5": "",
"nextWindowGesture": GesturePreference.disabled.indexAsString,
"focusWindowShortcut": "Space",
"previousWindowShortcut": "",
"cancelShortcut": "",
Expand All @@ -32,21 +33,25 @@ class Preferences {
"showMinimizedWindows3": ShowHowPreference.show.indexAsString,
"showMinimizedWindows4": ShowHowPreference.show.indexAsString,
"showMinimizedWindows5": ShowHowPreference.show.indexAsString,
"showMinimizedWindows6": ShowHowPreference.show.indexAsString,
"showHiddenWindows": ShowHowPreference.show.indexAsString,
"showHiddenWindows2": ShowHowPreference.show.indexAsString,
"showHiddenWindows3": ShowHowPreference.show.indexAsString,
"showHiddenWindows4": ShowHowPreference.show.indexAsString,
"showHiddenWindows5": ShowHowPreference.show.indexAsString,
"showHiddenWindows6": ShowHowPreference.show.indexAsString,
"showFullscreenWindows": ShowHowPreference.show.indexAsString,
"showFullscreenWindows2": ShowHowPreference.show.indexAsString,
"showFullscreenWindows3": ShowHowPreference.show.indexAsString,
"showFullscreenWindows4": ShowHowPreference.show.indexAsString,
"showFullscreenWindows5": ShowHowPreference.show.indexAsString,
"showFullscreenWindows6": ShowHowPreference.show.indexAsString,
"windowOrder": WindowOrderPreference.recentlyFocused.indexAsString,
"windowOrder2": WindowOrderPreference.recentlyFocused.indexAsString,
"windowOrder3": WindowOrderPreference.recentlyFocused.indexAsString,
"windowOrder4": WindowOrderPreference.recentlyFocused.indexAsString,
"windowOrder5": WindowOrderPreference.recentlyFocused.indexAsString,
"windowOrder6": WindowOrderPreference.recentlyFocused.indexAsString,
"showTabsAsWindows": "false",
"hideColoredCircles": "false",
"windowDisplayDelay": "100",
Expand All @@ -65,16 +70,19 @@ class Preferences {
"appsToShow3": AppsToShowPreference.all.indexAsString,
"appsToShow4": AppsToShowPreference.all.indexAsString,
"appsToShow5": AppsToShowPreference.all.indexAsString,
"appsToShow6": AppsToShowPreference.all.indexAsString,
"spacesToShow": SpacesToShowPreference.all.indexAsString,
"spacesToShow2": SpacesToShowPreference.all.indexAsString,
"spacesToShow3": SpacesToShowPreference.all.indexAsString,
"spacesToShow4": SpacesToShowPreference.all.indexAsString,
"spacesToShow5": SpacesToShowPreference.all.indexAsString,
"spacesToShow6": SpacesToShowPreference.all.indexAsString,
"screensToShow": ScreensToShowPreference.all.indexAsString,
"screensToShow2": ScreensToShowPreference.all.indexAsString,
"screensToShow3": ScreensToShowPreference.all.indexAsString,
"screensToShow4": ScreensToShowPreference.all.indexAsString,
"screensToShow5": ScreensToShowPreference.all.indexAsString,
"screensToShow6": ScreensToShowPreference.all.indexAsString,
"fadeOutAnimation": "false",
"hideSpaceNumberLabels": "false",
"hideStatusIcons": "false",
Expand All @@ -90,6 +98,7 @@ class Preferences {
"shortcutStyle3": ShortcutStylePreference.focusOnRelease.indexAsString,
"shortcutStyle4": ShortcutStylePreference.focusOnRelease.indexAsString,
"shortcutStyle5": ShortcutStylePreference.focusOnRelease.indexAsString,
"shortcutStyle6": ShortcutStylePreference.focusOnRelease.indexAsString,
"hideAppBadges": "false",
"hideWindowlessApps": "false",
"hideThumbnails": "false",
Expand All @@ -106,6 +115,7 @@ class Preferences {
// persisted values
static var holdShortcut: [String] { ["holdShortcut", "holdShortcut2", "holdShortcut3", "holdShortcut4", "holdShortcut5"].map { UserDefaults.standard.string($0) } }
static var nextWindowShortcut: [String] { ["nextWindowShortcut", "nextWindowShortcut2", "nextWindowShortcut3", "nextWindowShortcut4", "nextWindowShortcut5"].map { UserDefaults.standard.string($0) } }
static var nextWindowGesture: GesturePreference { UserDefaults.standard.macroPref("nextWindowGesture", GesturePreference.allCases) }
static var focusWindowShortcut: String { UserDefaults.standard.string("focusWindowShortcut") }
static var previousWindowShortcut: String { UserDefaults.standard.string("previousWindowShortcut") }
static var cancelShortcut: String { UserDefaults.standard.string("cancelShortcut") }
Expand Down Expand Up @@ -148,14 +158,14 @@ class Preferences {
static var showTitles: ShowTitlesPreference { UserDefaults.standard.macroPref("showTitles", ShowTitlesPreference.allCases) }
static var updatePolicy: UpdatePolicyPreference { UserDefaults.standard.macroPref("updatePolicy", UpdatePolicyPreference.allCases) }
static var crashPolicy: CrashPolicyPreference { UserDefaults.standard.macroPref("crashPolicy", CrashPolicyPreference.allCases) }
static var appsToShow: [AppsToShowPreference] { ["appsToShow", "appsToShow2", "appsToShow3", "appsToShow4", "appsToShow5"].map { UserDefaults.standard.macroPref($0, AppsToShowPreference.allCases) } }
static var spacesToShow: [SpacesToShowPreference] { ["spacesToShow", "spacesToShow2", "spacesToShow3", "spacesToShow4", "spacesToShow5"].map { UserDefaults.standard.macroPref($0, SpacesToShowPreference.allCases) } }
static var screensToShow: [ScreensToShowPreference] { ["screensToShow", "screensToShow2", "screensToShow3", "screensToShow4", "screensToShow5"].map { UserDefaults.standard.macroPref($0, ScreensToShowPreference.allCases) } }
static var showMinimizedWindows: [ShowHowPreference] { ["showMinimizedWindows", "showMinimizedWindows2", "showMinimizedWindows3", "showMinimizedWindows4", "showMinimizedWindows5"].map { UserDefaults.standard.macroPref($0, ShowHowPreference.allCases) } }
static var showHiddenWindows: [ShowHowPreference] { ["showHiddenWindows", "showHiddenWindows2", "showHiddenWindows3", "showHiddenWindows4", "showHiddenWindows5"].map { UserDefaults.standard.macroPref($0, ShowHowPreference.allCases) } }
static var showFullscreenWindows: [ShowHowPreference] { ["showFullscreenWindows", "showFullscreenWindows2", "showFullscreenWindows3", "showFullscreenWindows4", "showFullscreenWindows5"].map { UserDefaults.standard.macroPref($0, ShowHowPreference.allCases) } }
static var windowOrder: [WindowOrderPreference] { ["windowOrder", "windowOrder2", "windowOrder3", "windowOrder4", "windowOrder5"].map { UserDefaults.standard.macroPref($0, WindowOrderPreference.allCases) } }
static var shortcutStyle: [ShortcutStylePreference] { ["shortcutStyle", "shortcutStyle2", "shortcutStyle3", "shortcutStyle4", "shortcutStyle5"].map { UserDefaults.standard.macroPref($0, ShortcutStylePreference.allCases) } }
static var appsToShow: [AppsToShowPreference] { ["appsToShow", "appsToShow2", "appsToShow3", "appsToShow4", "appsToShow5", "appsToShow6"].map { UserDefaults.standard.macroPref($0, AppsToShowPreference.allCases) } }
static var spacesToShow: [SpacesToShowPreference] { ["spacesToShow", "spacesToShow2", "spacesToShow3", "spacesToShow4", "spacesToShow5", "spacesToShow6"].map { UserDefaults.standard.macroPref($0, SpacesToShowPreference.allCases) } }
static var screensToShow: [ScreensToShowPreference] { ["screensToShow", "screensToShow2", "screensToShow3", "screensToShow4", "screensToShow5", "screensToShow6"].map { UserDefaults.standard.macroPref($0, ScreensToShowPreference.allCases) } }
static var showMinimizedWindows: [ShowHowPreference] { ["showMinimizedWindows", "showMinimizedWindows2", "showMinimizedWindows3", "showMinimizedWindows4", "showMinimizedWindows5", "showMinimizedWindows6"].map { UserDefaults.standard.macroPref($0, ShowHowPreference.allCases) } }
static var showHiddenWindows: [ShowHowPreference] { ["showHiddenWindows", "showHiddenWindows2", "showHiddenWindows3", "showHiddenWindows4", "showHiddenWindows5", "showHiddenWindows6"].map { UserDefaults.standard.macroPref($0, ShowHowPreference.allCases) } }
static var showFullscreenWindows: [ShowHowPreference] { ["showFullscreenWindows", "showFullscreenWindows2", "showFullscreenWindows3", "showFullscreenWindows4", "showFullscreenWindows5", "showFullscreenWindows6"].map { UserDefaults.standard.macroPref($0, ShowHowPreference.allCases) } }
static var windowOrder: [WindowOrderPreference] { ["windowOrder", "windowOrder2", "windowOrder3", "windowOrder4", "windowOrder5", "windowOrder6"].map { UserDefaults.standard.macroPref($0, WindowOrderPreference.allCases) } }
static var shortcutStyle: [ShortcutStylePreference] { ["shortcutStyle", "shortcutStyle2", "shortcutStyle3", "shortcutStyle4", "shortcutStyle5", "shortcutStyle6"].map { UserDefaults.standard.macroPref($0, ShortcutStylePreference.allCases) } }
static var menubarIcon: MenubarIconPreference { UserDefaults.standard.macroPref("menubarIcon", MenubarIconPreference.allCases) }
static var menubarIconShown: Bool { UserDefaults.standard.bool("menubarIconShown") }
static var language: LanguagePreference { UserDefaults.standard.macroPref("language", LanguagePreference.allCases) }
Expand Down Expand Up @@ -512,6 +522,20 @@ enum MenubarIconPreference: CaseIterable, MacroPreference {
}
}

enum GesturePreference: CaseIterable, MacroPreference {
case disabled
case threeFingerSwipe
case fourFingerSwipe

var localizedString: LocalizedString {
switch self {
case .disabled: return NSLocalizedString("Disabled", comment: "")
case .threeFingerSwipe: return NSLocalizedString("Swipe with Three Fingers", comment: "")
case .fourFingerSwipe: return NSLocalizedString("Swipe with Four Fingers", comment: "")
}
}
}

enum LanguagePreference: CaseIterable, MacroPreference {
case systemDefault
case indonesian
Expand Down
4 changes: 2 additions & 2 deletions src/logic/Windows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ class Windows {
return list.count > focusedWindowIndex ? list[focusedWindowIndex] : nil
}

static func cycleFocusedWindowIndex(_ step: Int) {
static func cycleFocusedWindowIndex(_ step: Int, allowWrap: Bool = true) {
let nextIndex = windowIndexAfterCycling(step)
if ((step > 0 && nextIndex < focusedWindowIndex) || (step < 0 && nextIndex > focusedWindowIndex)) &&
(ATShortcut.lastEventIsARepeat || KeyRepeatTimer.timer?.isValid ?? false) {
(!allowWrap || ATShortcut.lastEventIsARepeat || KeyRepeatTimer.timer?.isValid ?? false) {
return
}
updateFocusedAndHoveredWindowIndex(nextIndex)
Expand Down
Loading

0 comments on commit 903e758

Please sign in to comment.