Skip to content

Commit

Permalink
feat: Window Switcher brings back the current window when pressing Co…
Browse files Browse the repository at this point in the history
…mmand + Tab twice option

closes #363
  • Loading branch information
ejbills committed Dec 22, 2024
1 parent 586bf0e commit 75adec7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
6 changes: 6 additions & 0 deletions DockDoor/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -29859,6 +29859,9 @@
}
}
}
},
"Use classic window ordering" : {

},
"Use default MacOS keybind ⌘ + ⇥" : {
"extractionState" : "stale",
Expand Down Expand Up @@ -31286,6 +31289,9 @@
}
}
}
},
"When enabled, shows the last active window first instead of the current window" : {

},
"When hovering over the preview" : {
"comment" : "Window title visibility option",
Expand Down
19 changes: 7 additions & 12 deletions DockDoor/Utilities/Window Management/WindowUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -482,24 +482,19 @@ enum WindowUtil {
var windows = desktopSpaceWindowCacheManager.getAllWindows()

if !Defaults[.includeHiddenWindowsInSwitcher] {
var windowsCopy: [WindowInfo] = []
for window in windows {
if !window.isHidden, !window.isMinimized {
windowsCopy.append(window)
}
}

windows = windowsCopy
windows = windows.filter { !$0.isHidden && !$0.isMinimized }
}

// If there are at least two windows, swap the first and second
if windows.count >= 2, Defaults[.sortWindowsByDate] {
// If classic ordering is enabled and there are at least two windows,
// swap the first and second windows
if Defaults[.useClassicWindowOrdering], windows.count >= 2 {
var modifiedWindows = windows
modifiedWindows.swapAt(0, 1)
return modifiedWindows
} else {
return windows
}

// Otherwise return natural date-based ordering
return windows
}

static func getActiveWindows(of app: NSRunningApplication) async throws -> [WindowInfo] {
Expand Down
10 changes: 10 additions & 0 deletions DockDoor/Views/Settings/MainSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct MainSettingsView: View {
@Default(.sortWindowsByDate) var sortWindowsByDate
@Default(.lateralMovement) var lateralMovement
@Default(.preventDockHide) var preventDockHide
@Default(.useClassicWindowOrdering) private var useClassicWindowOrdering

var body: some View {
VStack(alignment: .leading, spacing: 10) {
Expand Down Expand Up @@ -121,6 +122,15 @@ struct MainSettingsView: View {
Text("Sort Window Previews by Date")
})

VStack(alignment: .leading) {
Toggle(isOn: $useClassicWindowOrdering) {
Text("Use classic window ordering")
}
Text("When enabled, shows the last active window first instead of the current window")
.font(.footnote)
.foregroundColor(.gray)
}

Picker("Preview Hover Action", selection: $previewHoverAction) {
ForEach(PreviewHoverAction.allCases, id: \.self) { action in
Text(action.localizedName).tag(action)
Expand Down
1 change: 1 addition & 0 deletions DockDoor/consts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extension Defaults.Keys {
static let gradientColorPalette = Key<GradientColorPaletteSettings>("gradientColorPalette", default: .init())
static let enableWindowSwitcher = Key<Bool>("enableWindowSwitcher", default: true)
static let sortWindowsByDate = Key<Bool>("sortWindowsByDate", default: true)
static let useClassicWindowOrdering = Key<Bool>("useClassicWindowOrdering", default: false)
static let includeHiddenWindowsInSwitcher = Key<Bool>("includeHiddenWindowsInSwitcher", default: true)
static let ignoreAppsWithSingleWindow = Key<Bool>("ignoreAppsWithSingleWindow", default: false)
static let showMenuBarIcon = Key<Bool>("showMenuBarIcon", default: true)
Expand Down

0 comments on commit 75adec7

Please sign in to comment.