@@ -72,7 +72,21 @@ struct MenuBarView: View {
7272 hasAccessibilityPermission = AccessibilityService . shared. isAccessibilityEnabled
7373 }
7474 . onReceive ( NotificationCenter . default. publisher ( for: . showLanguageRestartDialog) ) { _ in
75- showRestartDialog = true
75+ // Check if main window is open - if so, let it handle the dialog
76+ // If main window is closed, show dialog in menu bar
77+ let hasMainWindow = NSApp . windows. contains { window in
78+ let className = window. className
79+ return !className. contains ( " NSPopover " ) &&
80+ !className. contains ( " NSStatusBarWindow " ) &&
81+ !className. contains ( " NSPanel " ) &&
82+ window. canBecomeKey &&
83+ window. isVisible
84+ }
85+
86+ // Only show dialog if no main window is visible
87+ if !hasMainWindow {
88+ showRestartDialog = true
89+ }
7690 }
7791 . alert ( String ( localized: " Restart Required " ) , isPresented: $showRestartDialog) {
7892 Button ( String ( localized: " Restart Now " ) ) {
@@ -230,9 +244,14 @@ struct MenuBarView: View {
230244 settings. targetScreenID = screen. id
231245 } label: {
232246 HStack ( spacing: 10 ) {
233- Image ( systemName: settings. targetScreenID == screen. id ? " checkmark " : " " )
234- . font ( . system( size: 12 ) )
235- . frame ( width: 16 )
247+ if settings. targetScreenID == screen. id {
248+ Image ( systemName: " checkmark " )
249+ . font ( . system( size: 12 ) )
250+ . frame ( width: 16 )
251+ } else {
252+ Spacer ( )
253+ . frame ( width: 16 )
254+ }
236255
237256 Text ( screen. name)
238257 . font ( . system( size: 13 ) )
@@ -258,9 +277,14 @@ struct MenuBarView: View {
258277 settings. dockPosition = position
259278 } label: {
260279 HStack ( spacing: 10 ) {
261- Image ( systemName: settings. dockPosition == position ? " checkmark " : " " )
262- . font ( . system( size: 12 ) )
263- . frame ( width: 16 )
280+ if settings. dockPosition == position {
281+ Image ( systemName: " checkmark " )
282+ . font ( . system( size: 12 ) )
283+ . frame ( width: 16 )
284+ } else {
285+ Spacer ( )
286+ . frame ( width: 16 )
287+ }
264288
265289 Text ( position. localizedName)
266290 . font ( . system( size: 13 ) )
@@ -305,9 +329,14 @@ struct MenuBarView: View {
305329 settings. appLanguage = language
306330 } label: {
307331 HStack ( spacing: 10 ) {
308- Image ( systemName: settings. appLanguage == language ? " checkmark " : " " )
309- . font ( . system( size: 12 ) )
310- . frame ( width: 16 )
332+ if settings. appLanguage == language {
333+ Image ( systemName: " checkmark " )
334+ . font ( . system( size: 12 ) )
335+ . frame ( width: 16 )
336+ } else {
337+ Spacer ( )
338+ . frame ( width: 16 )
339+ }
311340
312341 Text ( language. displayNameForPicker)
313342 . font ( . system( size: 13 ) )
@@ -371,23 +400,12 @@ struct MenuBarView: View {
371400 }
372401
373402 private func openMainWindow( ) {
374- // Activate app and bring window to front
375- NSApp . activate ( ignoringOtherApps: true )
376-
377- // Open or focus the main window
378- if let window = NSApp . windows. first ( where: {
379- $0. title. contains ( " DockCleat " ) || $0. isVisible == false
380- } ) {
381- window. makeKeyAndOrderFront ( nil )
382- } else {
383- // If no window exists, create one
384- for window in NSApp . windows {
385- if window. contentView != nil {
386- window. makeKeyAndOrderFront ( nil )
387- break
388- }
389- }
390- }
403+ // Close popover if open
404+ dismiss ( )
405+
406+ // Send notification to AppDelegate to handle window creation
407+ // AppDelegate has the proper context to create SwiftUI windows
408+ NotificationCenter . default. post ( name: NSNotification . Name ( " RequestMainWindow " ) , object: nil )
391409 }
392410}
393411
0 commit comments