fix: better filtering of "actual" windows (closes 102)
This commit is contained in:
1 parent
c69123b3d4
commit
fcdce9cbac
2 files changed
+16
-7
No files matched your search
@@ -8,6 +8,7 @@ enum AXAttributeKey: String {
|
|||||||
case windows = "AXWindows"
|
case windows = "AXWindows"
|
||||||
case minimized = "AXMinimized"
|
case minimized = "AXMinimized"
|
||||||
case focusedWindow = "AXFocusedWindow"
|
case focusedWindow = "AXFocusedWindow"
|
||||||
|
case subrole = "AXSubrole"
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AXUIElement {
|
extension AXUIElement {
|
||||||
@@ -39,6 +40,11 @@ extension AXUIElement {
|
|||||||
return attribute(.focusedWindow, AXUIElement.self)
|
return attribute(.focusedWindow, AXUIElement.self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isActualWindow() -> Bool {
|
||||||
|
let subrole = self.attribute(.subrole, String.self)
|
||||||
|
return subrole != nil && subrole != "AXUnknown"
|
||||||
|
}
|
||||||
|
|
||||||
func windows() -> [AXUIElement]? {
|
func windows() -> [AXUIElement]? {
|
||||||
return attribute(.windows, [AXUIElement].self)
|
return attribute(.windows, [AXUIElement].self)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class TrackedWindows {
|
|||||||
Spaces.windowsInSpaces(spaces.map { $0.0 }).enumerated().forEach {
|
Spaces.windowsInSpaces(spaces.map { $0.0 }).enumerated().forEach {
|
||||||
windowSpaceMap[$0.element]!.2 = $0.offset
|
windowSpaceMap[$0.element]!.2 = $0.offset
|
||||||
}
|
}
|
||||||
return windowSpaceMap as! [CGWindowID : (CGSSpaceID, SpaceIndex, WindowRank)]
|
return windowSpaceMap as! [CGWindowID: (CGSSpaceID, SpaceIndex, WindowRank)]
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func sortList() {
|
private static func sortList() {
|
||||||
@@ -69,15 +69,18 @@ class TrackedWindows {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
let (spaceId, spaceIndex, rank) = windowsMap[cgId] ?? (nil, nil, nil)
|
let (spaceId, spaceIndex, rank) = windowsMap[cgId] ?? (nil, nil, nil)
|
||||||
if let axWindow = cgId.AXUIElement(ownerPid) {
|
if let axWindow = cgId.AXUIElement(ownerPid), axWindow.isActualWindow() {
|
||||||
|
// window is in the current space
|
||||||
if spaceId != nil {
|
if spaceId != nil {
|
||||||
list.append(TrackedWindow(cgWindow, cgId, ownerPid, false, axWindow, spaceId, spaceIndex, rank))
|
list.append(TrackedWindow(cgWindow, cgId, ownerPid, false, axWindow, spaceId, spaceIndex, rank))
|
||||||
} else if axWindow.isMinimized() {
|
|
||||||
list.append(TrackedWindow(cgWindow, cgId, ownerPid, true, axWindow, spaceId, spaceIndex, rank))
|
|
||||||
}
|
}
|
||||||
} else {
|
// window is minimized
|
||||||
// window is on another space
|
else if axWindow.isMinimized() {
|
||||||
guard spaceId != nil else { continue }
|
list.append(TrackedWindow(cgWindow, cgId, ownerPid, true, axWindow, nil, nil, rank))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// window is on another space
|
||||||
|
else if spaceId != nil && spaceId != Spaces.currentSpaceId {
|
||||||
list.append(TrackedWindow(cgWindow, cgId, ownerPid, false, nil, spaceId, spaceIndex, rank))
|
list.append(TrackedWindow(cgWindow, cgId, ownerPid, false, nil, spaceId, spaceIndex, rank))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user