From 7f97c164c1258ec5a263dd664395a8049378e4df Mon Sep 17 00:00:00 2001 From: GabrielDuf Date: Fri, 17 Jul 2026 16:34:28 -0400 Subject: [PATCH 1/2] Fix maximized window content not filling the work area at fractional DPI --- .../Views/MainWindow.axaml.cs | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs b/src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs index 9591e0564c..86ea04b6b4 100644 --- a/src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs +++ b/src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs @@ -935,25 +935,19 @@ private static nint OnWindowsWndProc(nint hWnd, uint msg, nint wParam, nint lPar // the top inset, leaving the WS_THICKFRAME left/right/bottom resize border as glass. if (msg == WM_NCCALCSIZE && wParam.ToInt64() != 0) { - // When maximized, Windows places the window so its resize border sits offscreen - // (top-left near (-frame, -frame)). Claiming the whole window rect as client then - // pushes the title bar's top few pixels off the monitor, clipping the search box - // so it hugs the top edge (#5013). While maximized, inset the client rect by the - // frame thickness so it fills exactly the visible monitor; keep the full-rect - // (borderless, extended) client otherwise. + // Maximized: client = work area (the window already equals it), not a phantom frame inset (#5117/#5013). if (NativeMethods.IsZoomed(hWnd)) { - uint dpi = NativeMethods.GetDpiForWindow(hWnd); - if (dpi == 0) dpi = 96; - var border = default(NativeMethods.RECT); - if (NativeMethods.AdjustWindowRectExForDpi(ref border, WS_THICKFRAME, false, 0, dpi)) + nint monitor = NativeMethods.MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); + if (monitor != 0) { - var p = Marshal.PtrToStructure(lParam); - p.rgrc0.Left -= border.Left; - p.rgrc0.Top -= border.Top; - p.rgrc0.Right -= border.Right; - p.rgrc0.Bottom -= border.Bottom; - Marshal.StructureToPtr(p, lParam, false); + var mi = new NativeMethods.MONITORINFO { cbSize = Marshal.SizeOf() }; + if (NativeMethods.GetMonitorInfo(monitor, ref mi)) + { + var p = Marshal.PtrToStructure(lParam); + p.rgrc0 = mi.rcWork; + Marshal.StructureToPtr(p, lParam, false); + } } } handled = true; From 050d9a3cc5fa5ee1c7b4078881489d0523cd26d6 Mon Sep 17 00:00:00 2001 From: GabrielDuf Date: Mon, 20 Jul 2026 08:27:48 -0400 Subject: [PATCH 2/2] Preserve maximized state when restoring from the system tray --- src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs b/src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs index 86ea04b6b4..ec08fd7805 100644 --- a/src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs +++ b/src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs @@ -1343,9 +1343,14 @@ public void ShowRuntimeNotification(string title, string message, RuntimeNotific // ─── BackgroundAPI integration ──────────────────────────────────────────── public void ShowFromTray() { + // Show() restores a hidden window to its pre-maximize size, so re-apply Maximized if it was: + // a native maximize (Snap Layouts / Win+Up) never updates Avalonia's _showWindowState. + bool restoreMaximized = !IsVisible && WindowState == WindowState.Maximized; if (!IsVisible) Show(); - if (WindowState == WindowState.Minimized) + if (restoreMaximized) + WindowState = WindowState.Maximized; + else if (WindowState == WindowState.Minimized) WindowState = WindowState.Normal; Activate(); }