Skip to content

Commit d6d957a

Browse files
committed
Fix window position on space change
1 parent a1e4df8 commit d6d957a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Core/Sources/SuggestionWidget/WidgetWindowsController.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ extension WidgetWindowsController {
419419
0
420420
} else if previousAppIsXcode {
421421
if windows.chatPanelWindow.isFullscreen,
422-
windows.chatPanelWindow.isOnActiveSpace {
422+
windows.chatPanelWindow.isOnActiveSpace
423+
{
423424
0
424425
} else {
425426
1
@@ -513,7 +514,7 @@ extension WidgetWindowsController {
513514
)
514515

515516
updateWindowLocationTask = Task {
516-
try await Task.sleep(nanoseconds: UInt64(delay * 1_000_000_000))
517+
try await Task.sleep(nanoseconds: UInt64(delay * 500_000_000))
517518
try Task.checkCancellation()
518519
await update()
519520
}
@@ -580,9 +581,8 @@ extension WidgetWindowsController {
580581
func handleXcodeFullscreenChange() async {
581582
let activeXcode = await XcodeInspector.shared.safe.activeXcode
582583

583-
let isFullscreen = if let xcode = activeXcode?.appElement,
584-
let xcodeWindow = xcode.focusedWindow
585-
{
584+
let xcode = activeXcode?.appElement
585+
let isFullscreen = if let xcode, let xcodeWindow = xcode.focusedWindow {
586586
xcodeWindow.isFullScreen && xcode.isFrontmost
587587
} else {
588588
false
@@ -598,7 +598,7 @@ extension WidgetWindowsController {
598598
$0.send(.didChangeActiveSpace(fullscreen: isFullscreen))
599599
}
600600

601-
if windows.fullscreenDetector.isOnActiveSpace, isFullscreen {
601+
if windows.fullscreenDetector.isOnActiveSpace, xcode?.focusedWindow != nil {
602602
windows.orderFront()
603603
}
604604
}
@@ -819,7 +819,9 @@ public final class WidgetWindows {
819819
toastWindow.orderFrontRegardless()
820820
sharedPanelWindow.orderFrontRegardless()
821821
suggestionPanelWindow.orderFrontRegardless()
822-
if chatPanelWindow.level.rawValue > NSWindow.Level.normal.rawValue {
822+
if chatPanelWindow.level.rawValue > NSWindow.Level.normal.rawValue,
823+
store.withState({ !$0.chatPanelState.isDetached })
824+
{
823825
chatPanelWindow.orderFrontRegardless()
824826
}
825827
}

0 commit comments

Comments
 (0)