fix: wrong focus after active app becomes windowless (closes #2065)
This commit is contained in:
1 parent
8b2d659000
commit
281b3ed45b
1 file changed
+5
-2
@@ -19,7 +19,7 @@ fileprivate func handleEvent(_ type: String, _ element: AXUIElement) throws {
|
|||||||
case kAXWindowCreatedNotification: try windowCreated(element, pid)
|
case kAXWindowCreatedNotification: try windowCreated(element, pid)
|
||||||
case kAXMainWindowChangedNotification,
|
case kAXMainWindowChangedNotification,
|
||||||
kAXFocusedWindowChangedNotification: try focusedWindowChanged(element, pid)
|
kAXFocusedWindowChangedNotification: try focusedWindowChanged(element, pid)
|
||||||
case kAXUIElementDestroyedNotification: try windowDestroyed(element)
|
case kAXUIElementDestroyedNotification: try windowDestroyed(element, pid)
|
||||||
case kAXWindowMiniaturizedNotification,
|
case kAXWindowMiniaturizedNotification,
|
||||||
kAXWindowDeminiaturizedNotification: try windowMiniaturizedOrDeminiaturized(element, type)
|
kAXWindowDeminiaturizedNotification: try windowMiniaturizedOrDeminiaturized(element, type)
|
||||||
case kAXTitleChangedNotification: try windowTitleChanged(element, pid)
|
case kAXTitleChangedNotification: try windowTitleChanged(element, pid)
|
||||||
@@ -130,13 +130,16 @@ fileprivate func focusedWindowChanged(_ element: AXUIElement, _ pid: pid_t) thro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func windowDestroyed(_ element: AXUIElement) throws {
|
fileprivate func windowDestroyed(_ element: AXUIElement, _ pid: pid_t) throws {
|
||||||
let wid = try element.cgWindowId()
|
let wid = try element.cgWindowId()
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if let index = (Windows.list.firstIndex { $0.isEqualRobust(element, wid) }) {
|
if let index = (Windows.list.firstIndex { $0.isEqualRobust(element, wid) }) {
|
||||||
let window = Windows.list[index]
|
let window = Windows.list[index]
|
||||||
Windows.removeAndUpdateFocus(window)
|
Windows.removeAndUpdateFocus(window)
|
||||||
let windowlessApp = window.application.addWindowslessAppsIfNeeded()
|
let windowlessApp = window.application.addWindowslessAppsIfNeeded()
|
||||||
|
if windowlessApp != nil {
|
||||||
|
Applications.find(pid)?.focusedWindow = nil
|
||||||
|
}
|
||||||
if Windows.list.count > 0 {
|
if Windows.list.count > 0 {
|
||||||
Windows.moveFocusedWindowIndexAfterWindowDestroyedInBackground(index)
|
Windows.moveFocusedWindowIndexAfterWindowDestroyedInBackground(index)
|
||||||
App.app.refreshOpenUi(windowlessApp)
|
App.app.refreshOpenUi(windowlessApp)
|
||||||
|
|||||||
Reference in new issue
Block a user