abaeb01139
Restoring left the window filling the screen, so it had to be dragged back by a border. OnStateChanged corrected the window placement synchronously, but at that point WindowState is already Normal while ActualWidth/Left still describe the maximised frame - so the placement helper saw a screen-sized window, "corrected" it, and wrote the working area into Width/Height, destroying the restore bounds. Every later restore repeated it. The correction is now posted at Background priority, after the transition has settled, and does nothing when the restored bounds are already sane. When there are no smaller bounds to return to - the window was maximised from the start - it falls back to the app's own default size, centred on the monitor the window was actually on rather than the primary. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>