Launch upper-left with 75px padding; stop restoring window position
Creator ruling: open in the upper-left of the screen with ~75px padding. The restore path was placing the window below the fold. RestoreWindowGeometry now ignores the saved position and calls the pure TopLeftPlacement(workArea, w, h, padding): work-area origin + LaunchPadding (75, in DIPs so it scales with DPI), clamped so the window is never pushed off-screen. A window that fits stays wholly visible; one too big to fit falls back to the work-area origin. Size and maximized state are still persisted -- only position was dropped. The size clamp is unchanged (saved values clamp to [MinWidth, work.Width], which is why a saved 800x500 returns as 1366x768 per the XAML minimums). The old clamp tolerated Left as low as work.Left - width + 120 and Top up to work.Bottom - 80, ranges wide enough to leave the window almost entirely off-screen while still looking like a successful clamp. A clamp that permits the window to be unreachable is worse than none: it reads as a guarantee it does not keep. BroadcastPullOutTests is renamed ..._Window_Launches_TopLeft_... and now asserts the constructor applies the derived placement for both an on-screen and a -99999 saved position. Placement math is covered by WindowPlacementTests as a pure function needing no HWND. Suite 395/395, 0 warnings.
This commit is contained in:
@@ -23,7 +23,7 @@ public sealed class BroadcastPullOutTests
|
||||
private readonly RealAppHost _app;
|
||||
|
||||
[Fact]
|
||||
public void Metadata_Persists_WindowRestores_Clamped_And_UpdatePatchesRemote()
|
||||
public void Metadata_Persists_Window_Launches_TopLeft_And_UpdatePatchesRemote()
|
||||
{
|
||||
_app.Run(Run);
|
||||
}
|
||||
@@ -89,11 +89,16 @@ public sealed class BroadcastPullOutTests
|
||||
using (var writer = new LayoutStore(tempDb))
|
||||
writer.SaveWindowState(100, 50, 1500, 900, "Normal");
|
||||
|
||||
var work = System.Windows.SystemParameters.WorkArea;
|
||||
|
||||
window = new MainWindow();
|
||||
Assert.Equal(1500, window.Width);
|
||||
Assert.Equal(900, window.Height);
|
||||
Assert.Equal(100, window.Left);
|
||||
Assert.Equal(50, window.Top);
|
||||
// Launch POSITION is derived, never restored (2026-10-04). The 100,50 saved
|
||||
// above is deliberately ignored: restoring it is what let the window come
|
||||
// back below the fold, which is the whole reason this behaviour changed.
|
||||
Assert.Equal(Math.Min(work.Left + 75, work.Right - 1500), window.Left);
|
||||
Assert.Equal(Math.Min(work.Top + 75, work.Bottom - 900), window.Top);
|
||||
|
||||
window.Close();
|
||||
window = null;
|
||||
@@ -102,11 +107,15 @@ public sealed class BroadcastPullOutTests
|
||||
writer.SaveWindowState(-99999, -99999, 800, 500, "Normal");
|
||||
|
||||
window = new MainWindow();
|
||||
var work = System.Windows.SystemParameters.WorkArea;
|
||||
Assert.Equal(1366, window.Width);
|
||||
Assert.Equal(768, window.Height);
|
||||
Assert.InRange(window.Left, work.Left - window.Width + 120, work.Right - 120);
|
||||
Assert.InRange(window.Top, work.Top, work.Bottom - 80);
|
||||
Assert.Equal(1366, window.Width); // saved 800 clamps up to MinWidth
|
||||
Assert.Equal(768, window.Height); // saved 500 clamps up to MinHeight
|
||||
// A wildly off-screen saved position (-99999) no longer influences placement
|
||||
// at all — the old clamp tolerated Left as low as work.Left - Width + 120,
|
||||
// i.e. the window could sit almost entirely off the left edge.
|
||||
Assert.Equal(Math.Min(work.Left + 75, work.Right - window.Width), window.Left);
|
||||
Assert.Equal(Math.Min(work.Top + 75, work.Bottom - window.Height), window.Top);
|
||||
Assert.InRange(window.Left, work.Left, work.Right - window.Width);
|
||||
Assert.InRange(window.Top, work.Top, work.Bottom - window.Height);
|
||||
|
||||
var auth = new YouTubeAuthService("test-client", "test-secret");
|
||||
auth.SetSession(new YouTubeChannel
|
||||
|
||||
Reference in New Issue
Block a user