Skip to content

Commit

Permalink
fix: workaround a quick in photoshop (closes #571)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Sep 4, 2020
1 parent 0c0c2d7 commit 7218418
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/logic/events/AccessibilityEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ private func windowCreated(_ element: AXUIElement, _ pid: pid_t) throws {
}

private func focusedWindowChanged(_ element: AXUIElement, _ pid: pid_t) throws {
if let wid = try element.cgWindowId() {
if let wid = try element.cgWindowId(),
let runningApp = NSRunningApplication(processIdentifier: pid),
// photoshop will focus a window *after* you focus another app
// we check that a focused window happens within an active app
runningApp.isActive {
let axTitle = try element.title()
let subrole = try element.subrole()
let role = try element.role()
Expand All @@ -135,9 +139,8 @@ private func focusedWindowChanged(_ element: AXUIElement, _ pid: pid_t) throws {
Windows.list.insertAndScaleRecycledPool(Windows.list.remove(at: existingIndex), at: 0)
App.app.refreshOpenUi([Windows.list[0], Windows.list[existingIndex]])
}
} else if let runningApp = NSRunningApplication(processIdentifier: pid),
element.isActualWindow(runningApp, wid, isOnNormalLevel, axTitle, subrole, role),
let app = (Applications.list.first { $0.pid == pid }) {
} else if element.isActualWindow(runningApp, wid, isOnNormalLevel, axTitle, subrole, role),
let app = (Applications.list.first { $0.pid == pid }) {
Windows.list.insertAndScaleRecycledPool(Window(element, app, wid, axTitle, isFullscreen, isMinimized, position), at: 0)
App.app.refreshOpenUi([Windows.list[0]])
}
Expand Down

0 comments on commit 7218418

Please sign in to comment.