Skip to content

Commit

Permalink
fix: app badges would sometimes not be up-to-date
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Aug 25, 2020
1 parent a7ef4c7 commit 8ad03a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/logic/Applications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class Applications {
}

static func refreshBadges() {
retryAxCallUntilTimeout {
let group = DispatchGroup()
retryAxCallUntilTimeout(group) {
if let dockPid = (Applications.list.first { $0.runningApplication.bundleIdentifier == "com.apple.dock" }?.runningApplication.processIdentifier),
let axList = (try AXUIElementCreateApplication(dockPid).children()?.first { try $0.role() == "AXList" }),
let axAppDockItem = (try axList.children()?.filter { try $0.subrole() == "AXApplicationDockItem" && ($0.appIsRunning() ?? false) }) {
Expand All @@ -87,6 +88,7 @@ class Applications {
}
}
}
_ = group.wait(wallTimeout: .now() + .seconds(1))
}

private static func isActualApplication(_ app: NSRunningApplication) -> Bool {
Expand Down
3 changes: 1 addition & 2 deletions src/ui/main-window/ThumbnailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class ThumbnailView: NSStackView {

private func addDockLabelIcon() {
appIcon.addSubview(dockLabelIcon, positioned: .above, relativeTo: nil)
dockLabelIcon.topAnchor.constraint(equalTo: appIcon.topAnchor, constant: -4).isActive = true
dockLabelIcon.rightAnchor.constraint(equalTo: appIcon.rightAnchor, constant: 1).isActive = true
}

private func addWindowControls() {
Expand Down Expand Up @@ -139,6 +137,7 @@ class ThumbnailView: NSStackView {
} else {
view.setNumber(dockLabel, true)
}
dockLabelIcon.setFrameOrigin(NSPoint(x: appIcon.frame.maxX - dockLabelIcon.fittingSize.width - 1, y: appIcon.frame.maxY - dockLabelIcon.fittingSize.height + 4))
}
assignIfDifferent(&frame.size.width, max(thumbnail.frame.size.width + Preferences.intraCellPadding * 2, ThumbnailView.widthMin(screen)))
assignIfDifferent(&frame.size.height, newHeight)
Expand Down

0 comments on commit 8ad03a5

Please sign in to comment.