Turning off your monitor or switching sources can be a big headache. You may find all of your windows being repositioned and resized or those of us with multiple displays may find everything being relocated to the remaining display/s. Sadly there don’t seem to be any reliable software solutions for this so a simple hardware solution may be required. HDMI and DVI both have a pin to detect weather the monitor is on or off, hot plug detect. Removing this pin has – for me and many others – solved the issue.
For DVI the pin (#16) can simply be pulled out using a pair of pliers.
For HDMI the pin (#19) can be a little harder to remove so a small slither of electrical tape can easily be stuck over the pin.
It may be helpful to note that if you were to power on your PC without the display switched on the PC may need a restart to display any image.