@@ -8,6 +8,10 @@ import Foundation
8
8
import SwiftUI
9
9
import XcodeInspector
10
10
11
+ #warning("""
12
+ TODO: This part is too messy, consider break ing it up, let each window handle their own things
13
+ """ )
14
+
11
15
actor WidgetWindowsController: NSObject {
12
16
let userDefaultsObservers = WidgetUserDefaultsObservers()
13
17
var xcodeInspector: XcodeInspector { .shared }
@@ -419,7 +423,8 @@ extension WidgetWindowsController {
419
423
0
420
424
} else if previousAppIsXcode {
421
425
if windows. chatPanelWindow. isFullscreen,
422
- windows. chatPanelWindow. isOnActiveSpace {
426
+ windows. chatPanelWindow. isOnActiveSpace
427
+ {
423
428
0
424
429
} else {
425
430
1
@@ -513,7 +518,7 @@ extension WidgetWindowsController {
513
518
)
514
519
515
520
updateWindowLocationTask = Task {
516
- try await Task . sleep ( nanoseconds: UInt64 ( delay * 1_000_000_000 ) )
521
+ try await Task . sleep ( nanoseconds: UInt64 ( delay * 500_000_000 ) )
517
522
try Task . checkCancellation ( )
518
523
await update ( )
519
524
}
@@ -580,9 +585,8 @@ extension WidgetWindowsController {
580
585
func handleXcodeFullscreenChange( ) async {
581
586
let activeXcode = await XcodeInspector . shared. safe. activeXcode
582
587
583
- let isFullscreen = if let xcode = activeXcode? . appElement,
584
- let xcodeWindow = xcode. focusedWindow
585
- {
588
+ let xcode = activeXcode? . appElement
589
+ let isFullscreen = if let xcode, let xcodeWindow = xcode. focusedWindow {
586
590
xcodeWindow. isFullScreen && xcode. isFrontmost
587
591
} else {
588
592
false
@@ -598,7 +602,7 @@ extension WidgetWindowsController {
598
602
$0. send ( . didChangeActiveSpace( fullscreen: isFullscreen) )
599
603
}
600
604
601
- if windows. fullscreenDetector. isOnActiveSpace, isFullscreen {
605
+ if windows. fullscreenDetector. isOnActiveSpace, xcode ? . focusedWindow != nil {
602
606
windows. orderFront ( )
603
607
}
604
608
}
@@ -819,7 +823,9 @@ public final class WidgetWindows {
819
823
toastWindow. orderFrontRegardless ( )
820
824
sharedPanelWindow. orderFrontRegardless ( )
821
825
suggestionPanelWindow. orderFrontRegardless ( )
822
- if chatPanelWindow. level. rawValue > NSWindow . Level. normal. rawValue {
826
+ if chatPanelWindow. level. rawValue > NSWindow . Level. normal. rawValue,
827
+ store. withState ( { !$0. chatPanelState. isDetached } )
828
+ {
823
829
chatPanelWindow. orderFrontRegardless ( )
824
830
}
825
831
}
0 commit comments