From f71125d8f355a4bba1cc4e0cd4974d1740e2c4d8 Mon Sep 17 00:00:00 2001 From: ShiinaRinne <45081750+ShiinaRinne@users.noreply.github.com> Date: Wed, 29 Jan 2025 19:26:40 +0800 Subject: [PATCH] =?UTF-8?q?macOS=20=E4=B8=80=E4=BA=9B=E4=BC=98=E5=8C=96=20?= =?UTF-8?q?(#6596)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [macOS] hide icon in Dock * [macOS] fix: close button not work * [macOS] fix: cant directly show window when click `Show or hide the main window` on minimized --- v2rayN/v2rayN.Desktop/Program.cs | 3 +- .../v2rayN.Desktop/Views/MainWindow.axaml.cs | 47 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/Program.cs b/v2rayN/v2rayN.Desktop/Program.cs index 5d1c6493..3039895c 100644 --- a/v2rayN/v2rayN.Desktop/Program.cs +++ b/v2rayN/v2rayN.Desktop/Program.cs @@ -52,5 +52,6 @@ internal class Program //.WithInterFont() .WithFontByDefault() .LogToTrace() - .UseReactiveUI(); + .UseReactiveUI() + .With(new MacOSPlatformOptions { ShowInDock = false}); } \ No newline at end of file diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index 9071145c..9f11041e 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -389,7 +389,8 @@ namespace v2rayN.Desktop.Views _blCloseByUser = true; StorageUI(); - await ViewModel?.MyAppExitAsync(false); + await ViewModel?.MyAppExitAsync(false); + Close(); } #endregion Event @@ -398,28 +399,28 @@ namespace v2rayN.Desktop.Views public void ShowHideWindow(bool? blShow) { - var bl = blShow ?? !_config.UiItem.ShowInTaskbar; - if (bl) - { - this.Show(); - if (this.WindowState == WindowState.Minimized) - { - this.WindowState = WindowState.Normal; - } - this.Activate(); - this.Focus(); - } - else - { - if (_config.UiItem.Hide2TrayWhenClose) - { - this.Hide(); - } - else - { - this.WindowState = WindowState.Minimized; - } - } + var bl = blShow ?? (!_config.UiItem.ShowInTaskbar ^ (WindowState==WindowState.Minimized)); + if (bl) + { + this.Show(); + if (this.WindowState == WindowState.Minimized) + { + this.WindowState = WindowState.Normal; + } + this.Activate(); + this.Focus(); + } + else + { + if (Utils.IsOSX() || _config.UiItem.Hide2TrayWhenClose) + { + this.Hide(); + } + else + { + this.WindowState = WindowState.Minimized; + } + } _config.UiItem.ShowInTaskbar = bl; }