Skip to content

Commit

Permalink
Fix window position on space change
Browse files Browse the repository at this point in the history
  • Loading branch information
intitni committed Aug 21, 2024
1 parent a1e4df8 commit d6d957a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Core/Sources/SuggestionWidget/WidgetWindowsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ extension WidgetWindowsController {
0
} else if previousAppIsXcode {
if windows.chatPanelWindow.isFullscreen,
windows.chatPanelWindow.isOnActiveSpace {
windows.chatPanelWindow.isOnActiveSpace
{
0
} else {
1
Expand Down Expand Up @@ -513,7 +514,7 @@ extension WidgetWindowsController {
)

updateWindowLocationTask = Task {
try await Task.sleep(nanoseconds: UInt64(delay * 1_000_000_000))
try await Task.sleep(nanoseconds: UInt64(delay * 500_000_000))
try Task.checkCancellation()
await update()
}
Expand Down Expand Up @@ -580,9 +581,8 @@ extension WidgetWindowsController {
func handleXcodeFullscreenChange() async {
let activeXcode = await XcodeInspector.shared.safe.activeXcode

let isFullscreen = if let xcode = activeXcode?.appElement,
let xcodeWindow = xcode.focusedWindow
{
let xcode = activeXcode?.appElement
let isFullscreen = if let xcode, let xcodeWindow = xcode.focusedWindow {
xcodeWindow.isFullScreen && xcode.isFrontmost
} else {
false
Expand All @@ -598,7 +598,7 @@ extension WidgetWindowsController {
$0.send(.didChangeActiveSpace(fullscreen: isFullscreen))
}

if windows.fullscreenDetector.isOnActiveSpace, isFullscreen {
if windows.fullscreenDetector.isOnActiveSpace, xcode?.focusedWindow != nil {
windows.orderFront()
}
}
Expand Down Expand Up @@ -819,7 +819,9 @@ public final class WidgetWindows {
toastWindow.orderFrontRegardless()
sharedPanelWindow.orderFrontRegardless()
suggestionPanelWindow.orderFrontRegardless()
if chatPanelWindow.level.rawValue > NSWindow.Level.normal.rawValue {
if chatPanelWindow.level.rawValue > NSWindow.Level.normal.rawValue,
store.withState({ !$0.chatPanelState.isDetached })
{
chatPanelWindow.orderFrontRegardless()
}
}
Expand Down

0 comments on commit d6d957a

Please sign in to comment.