I just replaced my home dual monitor setup with two newer, 75Hz monitors (that, incidentally, aren't actively dying on me). Unfortunately, after replacing them, I discovered that all of my windows would move to the primary monitor and occasionally resize when my computer entered sleep mode. This is, of course, unacceptable.
Searching online yielded many interesting results, from Registry tweaks to updating drivers to putting tape on certain HDMI pins in order to prevent monitors entering deep sleep. Most of the "fixes" were very sketchy with lots of people saying they didn't do anything, and I didn't want to resort to messing with my connectors until I'd exhausted other avenues.
By chance, I was scrolling through yet another thread of tweaks when I stumbled upon an important part of the answer by user "st99": Windows remembers your old monitors! When you disconnect a monitor and connect another one, or sometimes install a different driver, Windows will see your monitor as a different device, but it will still keep track of the previous device. As your PC goes to sleep and monitors are seen as disconnected, Windows doesn't know which monitors are valid any more and just chooses one — possibly the first one registered. Because multiple monitors are no longer detected, all windows are moved to the one "active" monitor, and sometimes resized if that monitor's resolution is too low.
In order to avoid this issue, you need to remove all the monitors that no longer exist.
- Open the Device Manager by right-clicking the Start button and selecting Device Manager
- Select the View menu item, and click Show hidden devices (see above screenshot)
- Expand the Monitors section
- Find all entries inside the Monitors section that have a grayed out or light-colored icon and delete them (in the screenshot above, that would be the first two "CB272U" entries)
The other part of the solution to this problem is to avoid DisplayPort. For whatever reason, certain DisplayPort-connected monitors continue to cause Windows to exhibit the unwanted window moving/resizing behavior. If you've deleted all the disconnected monitors and the issue still occurs, try switching from DP to HDMI or DVI.
This issue was encountered on Windows 10 version 2004, but it has apparently existed since Windows 7 or even earlier. Microsoft really should fix it by having a more intelligent way of remembering what monitors were connected and configured last.
Delete old monitor entries from Device Manager, and avoid DisplayPort.