From 783f87b5c6e05c965279bcb26f827f71125cc8af Mon Sep 17 00:00:00 2001
From: ShiinaRinne <45081750+ShiinaRinne@users.noreply.github.com>
Date: Wed, 29 Jan 2025 23:30:02 +0800
Subject: [PATCH] [macOS] amend: Child window visibility handling

https://github.com/2dust/v2rayN/pull/6596

When the main window is hidden, open child windows are mistakenly hidden as well.
This prevents reopening child windows after the main window is shown again.
---
 v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs
index 9f11041e..1c01db38 100644
--- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs
+++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs
@@ -390,7 +390,6 @@ namespace v2rayN.Desktop.Views
             StorageUI();
 
 	        await ViewModel?.MyAppExitAsync(false);
-	        Close();
         }
 
         #endregion Event
@@ -414,6 +413,10 @@ namespace v2rayN.Desktop.Views
 	        {
 		        if (Utils.IsOSX() || _config.UiItem.Hide2TrayWhenClose)
 		        {
+			        foreach (var ownedWindow in this.OwnedWindows)
+			        {
+				        ownedWindow.Close();
+			        }
 			        this.Hide();
 		        }
 		        else
@@ -492,4 +495,4 @@ namespace v2rayN.Desktop.Views
 
         #endregion UI
     }
-}
\ No newline at end of file
+}