perf: improve badges retrieval
This commit is contained in:
1 parent
1ab419dd09
commit
edbbf2082c
1 file changed
+2
-2
@@ -124,8 +124,8 @@ class Applications {
|
|||||||
AXUIElement.retryAxCallUntilTimeout(callType: .updateDockBadgesFromShowingUi) {
|
AXUIElement.retryAxCallUntilTimeout(callType: .updateDockBadgesFromShowingUi) {
|
||||||
guard let dockPid = (list.first { $0.bundleIdentifier == "com.apple.dock" }?.pid),
|
guard let dockPid = (list.first { $0.bundleIdentifier == "com.apple.dock" }?.pid),
|
||||||
let axDockChildren = try AXUIElementCreateApplication(dockPid).attributes([kAXChildrenAttribute]).children,
|
let axDockChildren = try AXUIElementCreateApplication(dockPid).attributes([kAXChildrenAttribute]).children,
|
||||||
let axList = try (axDockChildren.first { try $0.attributes([kAXRoleAttribute]).role == kAXListRole }),
|
let axListAttrs = (axDockChildren.lazy.compactMap { try? $0.attributes([kAXRoleAttribute, kAXChildrenAttribute]) }.first { $0.role == kAXListRole }),
|
||||||
let axListChildren = try axList.attributes([kAXChildrenAttribute]).children else { return }
|
let axListChildren = axListAttrs.children else { return }
|
||||||
let axAppDockItemUrlAndLabel: [(URL?, String?)] = try axListChildren.compactMap {
|
let axAppDockItemUrlAndLabel: [(URL?, String?)] = try axListChildren.compactMap {
|
||||||
let a = try $0.attributes([kAXSubroleAttribute, kAXIsApplicationRunningAttribute, kAXURLAttribute, kAXStatusLabelAttribute])
|
let a = try $0.attributes([kAXSubroleAttribute, kAXIsApplicationRunningAttribute, kAXURLAttribute, kAXStatusLabelAttribute])
|
||||||
guard a.subrole == kAXApplicationDockItemSubrole && (a.appIsRunning ?? false) else { return nil }
|
guard a.subrole == kAXApplicationDockItemSubrole && (a.appIsRunning ?? false) else { return nil }
|
||||||
|
|||||||
Reference in new issue
Block a user