Fix window geometry save/restore: DPI scaling, position drift, maximized state

- LFM: Position = poDesigned (was poScreenCenter, overriding our restore)
- RestoreWindowBounds: remove position scaling (L,T invariant across DPI);
  scale size correctly per backend: LCLWin32 uses CurDPI/SavedDPI (physical px),
  Qt6/GTK/Cocoa use SavedDPI/CurDPI (logical px, inverse); fix min-size
  inflation on Qt6 (was MulDiv(900,DPI,96) which exceeds logical screen width
  at 150%+ scale, forcing window to 0,0)
- SaveWindowBounds moved from FormDestroy to FormClose while window is still
  stable; add guard for bogus RestoredLeft/Top values on Qt6 when maximized
- RestoreWindowBounds stores FRestoreL/T and re-applies position in AfterShowTick
  (200ms after show) when WM frame extents are already known to Qt, fixing the
  systematic right/down drift caused by unknown frame extents at FormCreate time
- Save and restore WindowState (maximized flag); skip AfterShowTick position
  re-apply when window is maximized

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 11:56:56 +03:00
co-authored by Claude Sonnet 4.6
parent 1eecd974fc
commit 9028a8dac0
3 changed files with 70 additions and 22 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ object MainForm: TMainForm
Font.Color = clSilver
Font.Height = -13
Font.Name = 'Courier New'
Position = poScreenCenter
Position = poDesigned
LCLVersion = '4.6.0.0'
OnClose = FormClose
OnCreate = FormCreate