Funny, on my gaming windows computer I turn off my OLED monitor BEFORE I turn off the computer to let it do its special processing reliably. I’ve had the opposite issue to yours, several windows will remain on the turned off monitor! I have that one on HDMI and the second monitor on a DP connection.
...that seems like a really good and intuitive feature. What would expect it to do instead? Close the window? Keep it on some invisible virtual desktop? (how large is the mysterious off-screen area in which windows can be lost?)
My laptop has a 15" 1080p panel. It's attached to 2x 32" 4K panels. When I'm done for the day, I turn the screens off.
When I come back the next day, all my windows are on the laptop onboard display, and if I'm lucky, resized in a way that makes them movable. If I'm unlucky, I need to close the application, re-open it, and hope it's back in a helpful way.
The 2x 4K panels show me my wallpaper every morning. They don't show me any windows that were on them.
For anyone else who gets stuck with a window where the draggable part is off-screen on Windows, if you click the icon in the taskbar to "focus" the window, hold Win+Shift and hit the up arrow, it'll maximize the window so you can see the controls. If it's on a different monitor, or on a "ghost" monitor your computer thinks is plugged in but isn't actually, use Win+Shift and left/right arrow keys until you can see the window :)
You can ask Windows to try and remember the location. It's not fool proof, but it works 90% of the time.
In fact, I've got more issues with windows opening on a non-connected screen (and then having to do Winkey + right a couple of times until it shows up on my laptop screen.
Suspend the machine instead? The external monitors will go to sleep when they lose the signal.
I don't know how you expect that machine to know that you're only disabling that monitor temporarily and you expect it to restore your windows at some future time when it reconnects.
If you plug in a new monitor, should windows jump onto it spontaneously?
I do the same, either my Dock, my Laptop or my screens, or all together give some weird issues where the screens turn on every 5 minutes and go to sleep.
And searching for 'Dock screen wakes up during sleep' just floods <search engine> with 'screen does not wake up after sleep'. And with <search engine>'s removal of respecting + and -, I am not sure I'll ever find a solution...
I'd start with the question: where do you want them to go? Windowing systems generally don't have a 'limbo' where windows can live without being displayable, and that probably isn't what you want, either.
Do you want them all to auto-minimize? You can probably get that. But it starts with answering the question.
I could imagine a tiling window manager like sway having a "temporarily gone" pseudo-workspace that holds windows that were on another monitor until you plug it back in or pull them to another workspace. Or to remember that workspaces 1, 3, and 5 were on another monitor recently, and to put them back there when you plug back in.
Sway does the latter. When you have multiple displays, every workspace gets assigned to a display. When you remove a display, those workspaces move onto a remaining display, but, importantly, every window stays on the workspace it was on, so you don't get shuffling and rearranging windows. When you plug that display back in, those workspaces go back to that display. I get that there's no "perfect" way to handle this situation, but the way Sway does it is so much more simple and predictable than Gnome or Windows.
If it's the same problem I've had, I feel the pain!
On a laptop, reconfiguring to use monitors as and when you connect/disconnect them can be great.
However, I'm often on a PC with a fixed multi-monitor setup. The situation where one monitor is briefly out is transient. But some windowing systems decide to permanently erase all your painfully eked out settings at the drop of a hat.
The correct behavior in this particular case is actually just to do nothing, the fact that a monitor seems to have gone away should just be ignored. (Because it didn't go away, really. Maybe I'm just messing with it for a sec, or it's a different brand and turns on/off a few seconds after the others)
[IIRC on KDE you can prevent auto-reconfiguration by turning Kscreen OFF ]
Or even cheaper, there are little HDMI EDID emulation dongles. That said, you end up with windows staying on unreachable displays, so it's not always the best solution.