Skip to content

Commit

Permalink
feat: enhance window switching by focusing on second preview
Browse files Browse the repository at this point in the history
- When classic ordering is enabled and there are at least two windows,
  set the initial focus on the second window preview instead of the first.
- This improves switching speed and provides a more intuitive experience,
  similar to Windows OS behavior.

- Fixes ejbills#455 ejbills#439 ejbills#431
  • Loading branch information
bestbandari committed Feb 14, 2025
1 parent f6c7c62 commit c7f7891
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 9 additions & 0 deletions DockDoor/Utilities/KeybindHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ class KeybindHelper {
currentMouseLocation: CGPoint,
targetScreen: NSScreen)
{
// If classic window ordering is enabled and there are at least two windows,
// set the initial focus on the second window preview (instead of the first).
//
// This behavior improves window switching speed and mimics the Windows OS
// experience, making it easier for users to switch between recent windows quickly.
if Defaults[.useClassicWindowOrdering], windows.count >= 2 {
SharedPreviewWindowCoordinator.shared.windowSwitcherCoordinator.setIndex(to: 1)
}

let showWindow = { (mouseLocation: NSPoint?, mouseScreen: NSScreen?) in
SharedPreviewWindowCoordinator.shared.showWindow(
appName: "Window Switcher",
Expand Down
9 changes: 0 additions & 9 deletions DockDoor/Utilities/Window Management/WindowUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,6 @@ enum WindowUtil {
windows = windows.filter { !$0.isHidden && !$0.isMinimized }
}

// 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
}

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

Expand Down

0 comments on commit c7f7891

Please sign in to comment.