A simple, small calculator placed discreetly near the Windows Taskbar or anywhere on the screen
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: restore calculator window on-screen when saved monitor is disconnected

PlaceInitial() restored the saved window position from the registry without
checking that it still landed on a connected monitor. After detaching an
external display the window ended up off-screen and invisible (ToggleVisible
shows it with SWP_NOMOVE). Validate the target rect with MonitorFromRect
(MONITOR_DEFAULTTONULL); if it intersects no active monitor, discard the
saved position and fall through to the first-run bottom-right anchoring.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Marco Maroni (Jul 17, 2026, 12:06 PM +0200) eeebfc6f be50d0d4

+9 -2
+9 -2
CalculatorWindow.cpp
··· 169 169 AdjustWindowRectEx(&r, 170 170 (DWORD)GetWindowLongPtr(GWL_STYLE), FALSE, 171 171 (DWORD)GetWindowLongPtr(GWL_EXSTYLE)); 172 - SetWindowPos(NULL, r.left, r.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER); 173 - return; 172 + // Only restore the saved position if it still lands on a connected 173 + // monitor. Otherwise (e.g. the window was left on an external display 174 + // that is no longer attached) the point is off-screen and the window 175 + // would be invisible; fall through to first-run anchoring instead. 176 + RECT full = { r.left, r.top, r.left + w, r.top + h }; 177 + if (::MonitorFromRect(&full, MONITOR_DEFAULTTONULL) != NULL) { 178 + SetWindowPos(NULL, r.left, r.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER); 179 + return; 180 + } 174 181 } 175 182 // First run: anchor bottom-right, just above the notification area. 176 183 APPBARDATA abd{}; abd.cbSize = sizeof(abd);