Disable monitor autodetect

Hello,

I'm looking for a way to keep my X Server (or whatever is responsible) from moving every window to my secondary screen whenever I turn off my main screen or switch its input device. My primary monitor is connected via DisplayPort and my DVI Monitor never had that problem. I searched the internet and read that I should turn off DDC/CI in my monitor's settings which didn't change anything. I didn't find much more, especially for linux. I'm running Fedora 25 and I'm using the proprietary nvidia drivers. Does anyone of you have a solution for this problem?

There are so many variables with these things, maybe try a different port to your primary display? at least to test specific behaviours of the different ports because DP is different:

http://us.download.nvidia.com/XFree86/Linux-x86/313.30/README/xconfigoptions.html

Option "UseHotplugEvents" "boolean"

    ...

    Disabling this option suppresses the generation of these RandR events for non-DisplayPort displays, i.e., ones connected via VGA, DVI, or HDMI. Hotplug events cannot be suppressed for displays connected via DisplayPort.

    ...

    Default: on. The driver will generate RandR events when displays are added or removed.

If you want to keep DP for whatever reason, you can probably use some tools to fix things

arandr (saves configs as shell scripts)
arandr-indicator (handy menu)
xdotool - messing with windows from scripts, fiddly
pacmd - any associated audio changes too

You could try adding a hardware distribution amp or 'splitter' box if you can find one. I don't know about DP, but for things like hdmi, it'll show the box as a display that's always on. Complete overkill, but might work if you can find one cheap enough.

Thank you for your answers. The xconfig option looks interesting but unfortunately doesn't work for DP. I need to connect at least one graphics card with DP because I want to run GPU passthrough and I want to able to switch between the host and the vm without my monitor getting disconnected.
I think a splitter box could work, but those are too expensive. DP switches are more affordable, but I don't think those would help because there isn't any active eletronics inside.