From 1ab975749833293beb483a92d16f2946519fb1db Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Tue, 14 Jul 2026 17:27:30 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20=E5=9C=A8=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=89=8D=E8=AE=BE=E7=BD=AE=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E5=B0=BA=E5=AF=B8=EF=BC=8C=E6=B6=88=E9=99=A4?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=97=B6=E5=81=8F=E5=8F=B3=E4=B8=8B=E5=81=8F?= =?UTF-8?q?=E7=A7=BB=20(#9498)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 8147b3972320b1c6ba13a1fe5450f3312e67baa7. https://github.com/2dust/v2rayN/issues/9740 --- v2rayN/v2rayN.Desktop/Base/WindowBase.cs | 26 +++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/Base/WindowBase.cs b/v2rayN/v2rayN.Desktop/Base/WindowBase.cs index 7f691da5..fe8c32e2 100644 --- a/v2rayN/v2rayN.Desktop/Base/WindowBase.cs +++ b/v2rayN/v2rayN.Desktop/Base/WindowBase.cs @@ -4,7 +4,6 @@ public class WindowBase : ReactiveWindow where TViewMode { public WindowBase() { - Initialized += OnWindowInitialized; Loaded += OnLoaded; Loaded += (s, e) => { @@ -20,7 +19,7 @@ public class WindowBase : ReactiveWindow where TViewMode throw new NotImplementedException(); } - private void OnWindowInitialized(object? sender, EventArgs e) + protected virtual void OnLoaded(object? sender, RoutedEventArgs e) { try { @@ -30,23 +29,22 @@ public class WindowBase : ReactiveWindow where TViewMode return; } - if (sizeItem.Width > 0 && !Width.Equals(sizeItem.Width)) - { - Width = sizeItem.Width; - } + var screen = Screens.ScreenFromWindow(this) ?? Screens.Primary; + var scaling = screen.Scaling > 0 ? screen.Scaling : 1.0; + var workingArea = screen.WorkingArea; - if (sizeItem.Height > 0 && !Height.Equals(sizeItem.Height)) - { - Height = sizeItem.Height; - } + var width = Math.Min(sizeItem.Width, workingArea.Width / scaling); + var height = Math.Min(sizeItem.Height, workingArea.Height / scaling); + var x = workingArea.X + ((workingArea.Width - (width * scaling)) / 2); + var y = workingArea.Y + ((workingArea.Height - (height * scaling)) / 2); + + Width = width; + Height = height; + Position = new PixelPoint((int)x, (int)y); } catch { } } - protected virtual void OnLoaded(object? sender, RoutedEventArgs e) - { - } - protected override void OnClosed(EventArgs e) { base.OnClosed(e);