Windows 0.3.1 clean monitor source delta; no private history or other platform changes

This commit is contained in:
2026-10-27 02:00:33 +00:00
parent 366b3c5c9a
commit 1cf54a46e4
40 changed files with 983 additions and 206 deletions
+36 -2
View File
@@ -93,9 +93,13 @@ internal static class WindowChromeSelfTest
// Synthetic close-to-tray contract. The real MainForm branch is
// exercised separately by existing StartupSelfTest --uiOnly mode.
form.FormClosing += (_, e) => { closeEvents++; e.Cancel = true; form.Hide(); };
FitFixtureHeaderToDpi(form, header);
form.Show();
var initiallyReady = WaitForState(form, FormWindowState.Normal, "initial_show");
chrome.LayoutButtons();
var blankHeaderPoint = BlankFixtureHeaderPoint(form, header);
geometry["fixture_dpi_and_caption"] = $"dpi={form.DeviceDpi}; header={header.ClientRectangle}; button={chrome.MinimizeButton.Bounds}; blank={blankHeaderPoint}";
checks["fixture_header_contains_entire_dpi_scaled_caption"] = header.ClientRectangle.Contains(chrome.MinimizeButton.Bounds);
checks["client_canvas_replaces_entire_caption"] = initiallyReady && form.RectangleToScreen(form.ClientRectangle) == form.Bounds;
checks["native_sizable_style_preserved"] = (ChromeNative.GetWindowLongPtr(form.Handle, ChromeNative.GwlStyle).ToInt64() & ChromeNative.NativeFrameStyles) == ChromeNative.NativeFrameStyles;
checks["native_caption_style_absent"] = NativeCaptionAbsent(form);
@@ -105,7 +109,7 @@ internal static class WindowChromeSelfTest
ChromeNative.SetWindowLongPtr(form.Handle, ChromeNative.GwlStyle, (IntPtr)(initialStyle | ChromeNative.WsCaption));
checks["native_caption_cannot_return_on_style_refresh"] = NativeCaptionAbsent(form);
checks["system_menu_available_for_alt_space"] = ChromeNative.GetSystemMenu(form.Handle, false) != IntPtr.Zero;
checks["caption_blank_native_drag"] = Hit(form, header.PointToScreen(new Point(240, 20))) == ChromeNative.HtCaption;
checks["caption_blank_native_drag"] = Hit(form, header.PointToScreen(blankHeaderPoint)) == ChromeNative.HtCaption;
checks["caption_label_native_drag"] = Hit(form, title.PointToScreen(new Point(8, 8))) == ChromeNative.HtCaption;
checks["label_forwards_hit_to_form"] = Hit(title, title.PointToScreen(new Point(8, 8))) == ChromeNative.HtTransparent;
checks["combo_keeps_client_input"] = Hit(form, combo.PointToScreen(new Point(10, 10))) == ChromeNative.HtClient && Hit(combo, combo.PointToScreen(new Point(10, 10))) != ChromeNative.HtTransparent;
@@ -183,7 +187,7 @@ internal static class WindowChromeSelfTest
ChromeNative.SendMessage(form.Handle, ChromeNative.WmSysCommand, (IntPtr)ChromeNative.ScMaximize, IntPtr.Zero);
checks["system_maximize_blocked"] = WaitForState(form, FormWindowState.Normal, "blocked_maximize", restoreBounds);
ChromeNative.SendMessage(form.Handle, 0xa3 /* WM_NCLBUTTONDBLCLK */, (IntPtr)ChromeNative.HtCaption,
Pack(header.PointToScreen(new Point(240, 20))));
Pack(header.PointToScreen(blankHeaderPoint)));
checks["caption_double_click_does_not_maximize"] = WaitForState(form, FormWindowState.Normal, "blocked_double_click", restoreBounds);
chrome.MinimizeButton.PerformClick();
var minimized = WaitForState(form, FormWindowState.Minimized, "minimize_button");
@@ -248,10 +252,12 @@ internal static class WindowChromeSelfTest
var closeEvents = 0;
form.FormClosing += (_, e) => { closeEvents++; e.Cancel = true; };
using var chrome = new WindowChrome(form, header, () => exitRequests++);
FitFixtureHeaderToDpi(form, header);
form.Show();
var bounds = form.Bounds;
checks["mode_fixture_initially_ready"] = waitForState(form, FormWindowState.Normal, "mode_initial", bounds);
var button = chrome.MinimizeButton;
checks["login_fixture_header_contains_entire_dpi_scaled_caption"] = header.ClientRectangle.Contains(button.Bounds);
var buttonBounds = button.Bounds;
string ToolTipText() => ((ToolTip)typeof(WindowChrome).GetField("_toolTip",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.GetValue(chrome)!).GetToolTip(button) ?? "";
@@ -343,6 +349,34 @@ internal static class WindowChromeSelfTest
checks["dashboard_explicit_menu_exit_preserved"] = exitRequests == 5 && closeEvents == 0;
}
private static void FitFixtureHeaderToDpi(Form form, Panel header)
{
// Get the actual owned HWND's monitor DPI before sizing its synthetic
// header. At 350%, the real caption is 105px high plus a 21px inset;
// the old fixed 80/100px fixture clipped its background, not the app.
_ = form.Handle;
var minimum = (int)Math.Ceiling((WindowChrome.CaptionHeight + 12) * form.DeviceDpi / 96.0);
header.Height = Math.Max(header.Height, minimum);
form.PerformLayout();
}
private static Point BlankFixtureHeaderPoint(Form form, Panel header)
{
var border = Math.Max(1, (int)Math.Round(6 * form.DeviceDpi / 96.0));
// Choose an actually empty client point outside the resize band. A
// fixed y=20 becomes HTTOP when the current monitor DPI reaches 336.
for (var y = border + 2; y < header.ClientSize.Height - border; y++)
for (var x = border + 2; x < header.ClientSize.Width - border; x++)
{
var point = new Point(x, y);
if (header.GetChildAtPoint(point, GetChildAtPointSkip.Invisible) is not null) continue;
var inForm = form.PointToClient(header.PointToScreen(point));
if (ChromeGeometry.ResizeHitTest(form.ClientSize, inForm, border, true) == ChromeNative.HtClient)
return point;
}
throw new InvalidOperationException("Owned fixture has no blank header point outside its resize band.");
}
private static int Distance(Color a, Color b) => Math.Abs(a.R - b.R) + Math.Abs(a.G - b.G) + Math.Abs(a.B - b.B);
internal sealed record MinimizeInputProbe(bool Mouse, bool PointTargetsButton, bool CapturedAfterDown,
int Clicks, bool CapturedDuringClick, bool ManagedMinimized, bool NativeMinimized, bool Visible,