Skip to content

Commit ddefe94

Browse files
committed
Adjust window properties so they can stay on top on full screen apps without the order front hack
1 parent 3f91cdd commit ddefe94

2 files changed

Lines changed: 6 additions & 25 deletions

File tree

Core/Sources/SuggestionWidget/SuggestionWidgetController.swift

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public final class SuggestionWidgetController: NSObject {
2020
it.isReleasedWhenClosed = false
2121
it.isOpaque = false
2222
it.backgroundColor = .clear
23-
it.level = .init(NSWindow.Level.floating.rawValue + 1)
23+
it.level = .init(19)
24+
it.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
2425
it.hasShadow = true
2526
it.contentView = NSHostingView(
2627
rootView: WidgetView(
@@ -50,7 +51,8 @@ public final class SuggestionWidgetController: NSObject {
5051
it.isReleasedWhenClosed = false
5152
it.isOpaque = false
5253
it.backgroundColor = .clear
53-
it.level = .init(NSWindow.Level.floating.rawValue + 1)
54+
it.level = .init(19)
55+
it.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
5456
it.hasShadow = true
5557
it.contentView = NSHostingView(
5658
rootView: TabView(chatWindowViewModel: chatWindowViewModel)
@@ -71,6 +73,7 @@ public final class SuggestionWidgetController: NSObject {
7173
it.isOpaque = false
7274
it.backgroundColor = .clear
7375
it.level = .init(NSWindow.Level.floating.rawValue + 1)
76+
it.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
7477
it.hasShadow = true
7578
it.contentView = NSHostingView(
7679
rootView: SuggestionPanelView(viewModel: suggestionPanelViewModel)
@@ -94,6 +97,7 @@ public final class SuggestionWidgetController: NSObject {
9497
it.isOpaque = false
9598
it.backgroundColor = .clear
9699
it.level = .floating
100+
it.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
97101
it.hasShadow = true
98102
it.contentView = NSHostingView(
99103
rootView: ChatWindowView(viewModel: chatWindowViewModel)
@@ -231,7 +235,6 @@ public extension SuggestionWidgetController {
231235
if let suggestion = await dataSource?.suggestionForFile(at: fileURL) {
232236
suggestionPanelViewModel.content = .suggestion(suggestion)
233237
suggestionPanelViewModel.isPanelDisplayed = true
234-
panelWindow.orderFront(nil)
235238
}
236239
}
237240
}
@@ -251,7 +254,6 @@ public extension SuggestionWidgetController {
251254
suggestionPanelViewModel.content = .error(errorDescription)
252255
suggestionPanelViewModel.isPanelDisplayed = true
253256
widgetViewModel.isProcessing = false
254-
panelWindow.orderFront(nil)
255257
}
256258

257259
func presentChatRoom(fileURL: URL) {
@@ -269,7 +271,6 @@ public extension SuggestionWidgetController {
269271
// looks like we need a delay.
270272
try await Task.sleep(nanoseconds: 150_000_000)
271273
NSApplication.shared.activate(ignoringOtherApps: true)
272-
panelWindow.orderFront(nil)
273274
}
274275
}
275276
}
@@ -334,16 +335,6 @@ extension SuggestionWidgetController {
334335

335336
self.updateWindowLocation(animated: false)
336337

337-
if UserDefaults.shared.value(for: \.forceOrderWidgetToFront)
338-
|| notification.name == kAXWindowMovedNotification
339-
{
340-
// We need to bring them front when the app enters fullscreen.
341-
widgetWindow.orderFront(nil)
342-
tabWindow.orderFront(nil)
343-
chatWindow.orderFront(nil)
344-
panelWindow.orderFront(nil)
345-
}
346-
347338
if [
348339
kAXFocusedUIElementChangedNotification,
349340
kAXApplicationActivatedNotification,

Core/Sources/SuggestionWidget/WidgetView.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ struct WidgetContextMenu: View {
113113
@AppStorage(\.realtimeSuggestionToggle) var realtimeSuggestionToggle
114114
@AppStorage(\.acceptSuggestionWithAccessibilityAPI) var acceptSuggestionWithAccessibilityAPI
115115
@AppStorage(\.hideCommonPrecedingSpacesInSuggestion) var hideCommonPrecedingSpacesInSuggestion
116-
@AppStorage(\.forceOrderWidgetToFront) var forceOrderWidgetToFront
117116
@AppStorage(\.disableSuggestionFeatureGlobally) var disableSuggestionFeatureGlobally
118117
@AppStorage(\.suggestionFeatureEnabledProjectList) var suggestionFeatureEnabledProjectList
119118
@AppStorage(\.customCommands) var customCommands
@@ -186,15 +185,6 @@ struct WidgetContextMenu: View {
186185
}
187186
})
188187

189-
Button(action: {
190-
forceOrderWidgetToFront.toggle()
191-
}, label: {
192-
Text("Force Order Widget to Front")
193-
if forceOrderWidgetToFront {
194-
Image(systemName: "checkmark")
195-
}
196-
})
197-
198188
if let projectPath, disableSuggestionFeatureGlobally {
199189
let matchedPath = suggestionFeatureEnabledProjectList.first { path in
200190
projectPath.hasPrefix(path)

0 commit comments

Comments
 (0)