Skip to content

Commit 788b197

Browse files
committed
Fix that widget window was mistakenly hidden is some cases
1 parent fe8e82a commit 788b197

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

Core/Sources/SuggestionWidget/SuggestionWidgetController.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,7 @@ extension SuggestionWidgetController {
515515
}
516516
}
517517

518-
/// Update the window location.
519-
///
520-
/// - note: It's possible to get the scroll view's position by getting position on the focus
521-
/// element.
518+
/// Update the window location and opacity.
522519
private func updateWindowLocation(animated: Bool = false) {
523520
let detachChat = chatWindowViewModel.chatPanelInASeparateWindow
524521

@@ -582,10 +579,11 @@ extension SuggestionWidgetController {
582579
app.bundleIdentifier == Bundle.main.bundleIdentifier
583580
{
584581
let noFocus = {
585-
guard let xcode = ActiveApplicationMonitor.latestXcode else { return true }
586-
let application = AXUIElementCreateApplication(xcode.processIdentifier)
587-
return application
588-
.focusedWindow == nil || (application.focusedWindow?.role == "AXWindow")
582+
guard let xcode = XcodeInspector.shared.latestActiveXcode else { return true }
583+
if let window = xcode.appElement.focusedWindow, window.role == "AXWindow" {
584+
return false
585+
}
586+
return true
589587
}()
590588

591589
panelWindow.alphaValue = noFocus ? 0 : 1

0 commit comments

Comments
 (0)