From c56df24b5d6a39bccd00cd00c922c122aaf9d868 Mon Sep 17 00:00:00 2001 From: YsLtr Date: Wed, 25 Mar 2026 16:02:33 +0800 Subject: [PATCH] Apply Linux custom title bars to dialog windows --- v2rayN/v2rayN.Desktop/App.axaml | 18 +++++ v2rayN/v2rayN.Desktop/Base/WindowBase.cs | 75 +++++++++++++++++++ v2rayN/v2rayN.Desktop/Common/UI.cs | 13 +++- .../Views/AddGroupServerWindow.axaml | 36 ++++++++- .../Views/AddServer2Window.axaml | 35 ++++++++- .../Views/AddServerWindow.axaml | 35 ++++++++- .../Views/DNSSettingWindow.axaml | 35 ++++++++- .../Views/FullConfigTemplateWindow.axaml | 35 ++++++++- .../Views/GlobalHotkeySettingWindow.axaml | 35 ++++++++- v2rayN/v2rayN.Desktop/Views/MainWindow.axaml | 27 +------ .../v2rayN.Desktop/Views/MainWindow.axaml.cs | 24 +----- .../Views/OptionSettingWindow.axaml | 35 ++++++++- .../Views/ProfilesSelectWindow.axaml | 36 ++++++++- .../Views/RoutingRuleDetailsWindow.axaml | 35 ++++++++- .../Views/RoutingRuleSettingWindow.axaml | 35 ++++++++- .../Views/RoutingSettingWindow.axaml | 36 ++++++++- .../v2rayN.Desktop/Views/SubEditWindow.axaml | 35 ++++++++- .../Views/SubSettingWindow.axaml | 48 ++++++++++-- 18 files changed, 545 insertions(+), 83 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/App.axaml b/v2rayN/v2rayN.Desktop/App.axaml index 21204f60..fd648056 100644 --- a/v2rayN/v2rayN.Desktop/App.axaml +++ b/v2rayN/v2rayN.Desktop/App.axaml @@ -22,6 +22,24 @@ + + + diff --git a/v2rayN/v2rayN.Desktop/Base/WindowBase.cs b/v2rayN/v2rayN.Desktop/Base/WindowBase.cs index d1419b30..86ba979e 100644 --- a/v2rayN/v2rayN.Desktop/Base/WindowBase.cs +++ b/v2rayN/v2rayN.Desktop/Base/WindowBase.cs @@ -2,8 +2,17 @@ namespace v2rayN.Desktop.Base; public class WindowBase : ReactiveWindow where TViewModel : class { + private Border? _linuxTitleBar; + private Control? _linuxTitleBarDragRegion; + private Button? _linuxTitleBarCloseButton; + public WindowBase() { + if (Utils.IsLinux()) + { + SystemDecorations = SystemDecorations.BorderOnly; + } + Loaded += OnLoaded; } @@ -34,10 +43,13 @@ public class WindowBase : ReactiveWindow where TViewMode Position = new PixelPoint((int)x, (int)y); } catch { } + + ConfigureLinuxTitleBar(); } protected override void OnClosed(EventArgs e) { + ReleaseLinuxTitleBar(); base.OnClosed(e); try { @@ -45,4 +57,67 @@ public class WindowBase : ReactiveWindow where TViewMode } catch { } } + + protected virtual void HandleLinuxTitleBarClose() + { + Close(); + } + + private void ConfigureLinuxTitleBar() + { + if (!Utils.IsLinux()) + { + return; + } + + _linuxTitleBar ??= this.FindControl("linuxTitleBar"); + if (_linuxTitleBar == null) + { + return; + } + + _linuxTitleBar.IsVisible = true; + + _linuxTitleBarDragRegion ??= this.FindControl("linuxTitleBarDragRegion"); + if (_linuxTitleBarDragRegion != null) + { + _linuxTitleBarDragRegion.PointerPressed -= LinuxTitleBar_PointerPressed; + _linuxTitleBarDragRegion.PointerPressed += LinuxTitleBar_PointerPressed; + } + + _linuxTitleBarCloseButton ??= this.FindControl + + + + - + + diff --git a/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml b/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml index 0c9d89a4..b7517329 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml +++ b/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml @@ -13,7 +13,37 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - + + + + + + + + + + + + + + - + + diff --git a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml index 4dc378b4..f7712dc9 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml @@ -14,7 +14,37 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - + + + + + + + + + + + + + + - + + diff --git a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml index 3335785b..fda5aac2 100644 --- a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml @@ -14,7 +14,37 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - + + + + + + + + + + + + + + - + + diff --git a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml index 1a2b482c..ddd4b614 100644 --- a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml @@ -14,7 +14,37 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - + + + + + + + + + + + + + + - + + diff --git a/v2rayN/v2rayN.Desktop/Views/GlobalHotkeySettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/GlobalHotkeySettingWindow.axaml index 8eb3b473..ae67bc8f 100644 --- a/v2rayN/v2rayN.Desktop/Views/GlobalHotkeySettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/GlobalHotkeySettingWindow.axaml @@ -13,7 +13,37 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - + + + + + + + + + + + + + + - + + diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml index 24505c6c..74af4d43 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml @@ -18,26 +18,6 @@ ShowInTaskbar="True" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - - - - - + Background="Transparent" /> diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index ba73b8d6..9ab5ee3d 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -162,7 +162,6 @@ public partial class MainWindow : WindowBase else { Title = $"{Utils.GetVersion()}"; - ConfigureLinuxTitleBar(); } menuAddServerViaScan.IsVisible = false; @@ -396,28 +395,7 @@ public partial class MainWindow : WindowBase await AppManager.Instance.AppExitAsync(true); } - private void ConfigureLinuxTitleBar() - { - if (!Utils.IsLinux()) - { - return; - } - - linuxTitleBar.IsVisible = true; - SystemDecorations = SystemDecorations.BorderOnly; - } - - private void LinuxTitleBar_PointerPressed(object? sender, PointerPressedEventArgs e) - { - if (!Utils.IsLinux() || e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == false) - { - return; - } - - BeginMoveDrag(e); - } - - private void BtnLinuxClose_Click(object? sender, RoutedEventArgs e) + protected override void HandleLinuxTitleBarClose() { HideToTray(); } diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml index 7d80088a..0507c52c 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml @@ -13,7 +13,37 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - + + + + + + + + + + + + + + - + + diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesSelectWindow.axaml b/v2rayN/v2rayN.Desktop/Views/ProfilesSelectWindow.axaml index 2dd44b54..a467a12c 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesSelectWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesSelectWindow.axaml @@ -12,8 +12,37 @@ x:DataType="vms:ProfilesSelectViewModel" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - - + + + + + + + + + + + + + + - + + diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml index 30f74a14..b62ad64d 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml @@ -13,7 +13,37 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - + + + + + + + + + + + + + + - + + diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml index a770b3ed..e75fef56 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml @@ -13,7 +13,37 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - + + + + + + + + + + + + + + @@ -253,5 +283,6 @@ - + + diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml index a9155f7d..a39f6767 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml @@ -13,8 +13,37 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - - + + + + + + + + + + + + + + @@ -138,5 +167,6 @@ - + + diff --git a/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml b/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml index 79216921..b9089de4 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml @@ -12,7 +12,37 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - + + + + + + + + + + + + + + - + + diff --git a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml index 04870d4a..4b63fa2b 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml @@ -14,12 +14,43 @@ ShowInTaskbar="False" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> - - + + + + + + + + + + + + + + + @@ -75,6 +106,7 @@ Header="{x:Static resx:ResUI.LvSort}" /> - - + + +