Skip to content

Commit

Permalink
fix: dispatch work item misconfiguration
Browse files Browse the repository at this point in the history
closes #307
  • Loading branch information
ejbills committed Sep 16, 2024
1 parent a56c83e commit 610146e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions DockDoor/Utilities/WindowManipulationObservers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,19 @@ func axObserverCallback(observer: AXObserver, element: AXUIElement, notification
}

private func handleWindowEvent(element: AXUIElement, app: NSRunningApplication, updateDateTime: Bool = false) {
guard !WindowManipulationObservers.trackedElements.contains(element) else { return }
WindowManipulationObservers.trackedElements.insert(element)
WindowManipulationObservers.debounceWorkItem?.cancel()
WindowManipulationObservers.debounceWorkItem = DispatchWorkItem {

let workItem = DispatchWorkItem {
if updateDateTime {
WindowUtil.updateWindowDateTime(for: app)
}
WindowUtil.updateWindowCache(for: app) { windowSet in
windowSet = windowSet.filter { WindowUtil.isValidElement($0.axElement) }
}
WindowManipulationObservers.trackedElements.remove(element)
}
DispatchQueue.main.asyncAfter(deadline: .now() + windowProcessingDebounceInterval, execute: WindowManipulationObservers.debounceWorkItem!)

WindowManipulationObservers.debounceWorkItem = workItem
DispatchQueue.main.asyncAfter(deadline: .now() + windowProcessingDebounceInterval, execute: workItem)
}

private func handleFocusedUIElementChanged(element: AXUIElement, app: NSRunningApplication, pid: pid_t) {
Expand Down

0 comments on commit 610146e

Please sign in to comment.