fix: window order in the switcher might be incorrect (#5346)

This commit is contained in:
lwouis
2026-03-17 19:56:23 +01:00
parent 3b1c7c76a9
commit 545d81d872
2 changed files with 9 additions and 8 deletions
+6 -2
View File
@@ -321,8 +321,9 @@ class Window {
return nil
}
/// some apps will not trigger AXApplicationActivated, where we usually update application.focusedWindow
/// workaround: we check and possibly do it here
/// Scenarios addressed by this:
/// * Some apps will not trigger AXApplicationActivated, where we usually update application.focusedWindow
/// * Sometimes, we subscribe to an app after it has emitted the focusedWindow / applicationActivated events, so we never receive these
private func checkIfFocused() {
let app = application
guard let appAxUiElement = app.axUiElement else { return }
@@ -332,6 +333,9 @@ class Window {
DispatchQueue.main.async {
guard let window = (Windows.list.first { $0.isEqualRobust(focusedWindow, focusedWid) }) else { return }
app.focusedWindow = window
if let windows = Windows.updateLastFocusOrder(window) {
App.refreshOpenUiAfterExternalEvent(windows)
}
}
}
}
+3 -6
View File
@@ -243,9 +243,8 @@ class Windows {
hoveredWindowIndex = nil
TilesView.highlight(oldIndex)
}
if let frontmostPid = Applications.frontmostPid,
let frontmostApp = Applications.findOrCreate(frontmostPid, false),
(frontmostApp.focusedWindow == nil || Preferences.windowOrder[App.shortcutIndex] != .recentlyFocused),
if Applications.frontmostPid != nil,
Preferences.windowOrder[App.shortcutIndex] != .recentlyFocused,
let lastFocusedOrderWindowIndex = getLastFocusedOrderWindowIndex() {
updateSelectedAndHoveredWindowIndex(lastFocusedOrderWindowIndex)
} else {
@@ -511,9 +510,7 @@ class Windows {
}
static func appendWindow(_ window: Window) {
list.forEach {
$0.lastFocusOrder += 1
}
window.lastFocusOrder = list.count
list.append(window)
if list.count > TilesView.recycledViews.count {
TilesView.recycledViews.append(TileView())