Skip to content

Commit b0a740f

Browse files
committed
Fix that the active application can be incorrect after debouncing
1 parent cd4e807 commit b0a740f

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

Core/Sources/SuggestionWidget/FeatureReducers/WidgetFeature.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,7 @@ public struct WidgetFeature: ReducerProtocol {
261261
guard let windowsController,
262262
await windowsController.windows.fullscreenDetector.isOnActiveSpace
263263
else { continue }
264-
let app = AXUIElementCreateApplication(
265-
activeXcode.processIdentifier
266-
)
264+
let app = activeXcode.appElement
267265
if let _ = app.focusedWindow {
268266
await windowsController.windows.orderFront()
269267
}

Core/Sources/SuggestionWidget/WidgetWindowsController.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ actor WidgetWindowsController: NSObject {
9393
let shouldDebounce = !immediately &&
9494
!(Date().timeIntervalSince(lastUpdateWindowOpacityTime) > 5)
9595
lastUpdateWindowOpacityTime = Date()
96-
let activeApp = xcodeInspector.activeApplication
97-
9896
updateWindowOpacityTask?.cancel()
9997

10098
let task = Task {
@@ -103,11 +101,10 @@ actor WidgetWindowsController: NSObject {
103101
}
104102
try Task.checkCancellation()
105103
let xcodeInspector = self.xcodeInspector
104+
let activeApp = xcodeInspector.activeApplication
106105
await MainActor.run {
107106
if let activeApp, activeApp.isXcode {
108-
let application = AXUIElementCreateApplication(
109-
activeApp.processIdentifier
110-
)
107+
let application = activeApp.appElement
111108
/// We need this to hide the windows when Xcode is minimized.
112109
let noFocus = application.focusedWindow == nil
113110
windows.sharedPanelWindow.alphaValue = noFocus ? 0 : 1

0 commit comments

Comments
 (0)