mirror of
https://github.com/lwouis/alt-tab-macos.git
synced 2026-05-24 11:20:36 +00:00
fix: window order in the switcher might be incorrect (#5346)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user