Skip to content

Commit

Permalink
fix: alt-tab would show on the wrong screen (closes #2003)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Oct 14, 2022
1 parent 5830958 commit b72c4db
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/logic/events/AccessibilityEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ fileprivate func focusedWindowChanged(_ element: AXUIElement, _ pid: pid_t) thro
let level = try wid.level()
let position = try element.position()
let size = try element.size()
let parent = try element.parent()
let parentWid = try parent?.cgWindowId()
DispatchQueue.main.async {
if let windows = Windows.updateLastFocus(element, wid) {
App.app.refreshOpenUi(windows)
Expand All @@ -106,6 +108,11 @@ fileprivate func focusedWindowChanged(_ element: AXUIElement, _ pid: pid_t) thro
Windows.appendAndUpdateFocus(window)
App.app.refreshOpenUi([window])
}
// if the window is shown by alt-tab, we mark her as focused for this app
// this avoids issues with dialogs, quicklook, etc (see scenarios from #1044 and #2003)
if let w = (Windows.list.first { $0.isEqualRobust(element, wid) }) {
Applications.find(pid)?.focusedWindow = w
}
}
}
DispatchQueue.main.async {
Expand All @@ -118,9 +125,6 @@ fileprivate func focusedWindowChanged(_ element: AXUIElement, _ pid: pid_t) thro
}
}
}
DispatchQueue.main.async {
Applications.find(pid)?.focusedWindow = Windows.list.first { $0.isEqualRobust(element, wid) }
}
} else {
DispatchQueue.main.async {
Applications.find(pid)?.focusedWindow = nil
Expand Down

0 comments on commit b72c4db

Please sign in to comment.