Skip to content

Commit

Permalink
Add fallback for relative navigation if the frontmost application doe…
Browse files Browse the repository at this point in the history
…sn't have any open windows.

It will fallback to use the first window in the list
  • Loading branch information
zenangst committed Oct 23, 2024
1 parent abdef61 commit 4d8233b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ final class SystemWindowRelativeFocus {

let windows = indexWindowsInStage(getWindows())
let activeProcessIdentifier = Int(snapshot.frontmostApplication.ref.processIdentifier)
let firstFallback = windows.first

guard let activeWindow = windows.first(where: { $0.ownerPid == activeProcessIdentifier }) else { return }
guard let activeWindow = windows.first(where: { $0.ownerPid == activeProcessIdentifier }) ?? firstFallback else {
return
}

let previousWindow = activeWindow
let match = try await navigation.findNextWindow(activeWindow, windows: windows, direction: direction)
Expand Down

0 comments on commit 4d8233b

Please sign in to comment.