Automatic hotplug event handling can be a problem, eg. when its run for monitors. I use HDMI splitter between my host OS and gaming VM and I didn’t like that my windows were all over the place when I’ve used it.
There are few ways to disable those (but still to be able to run them manually when needed!), but I’ve found only one method is able to run for all GPU drivers.
Most obvious method is xorg setting “UseHotplugEvents”. It’s great, but works only for Nvidia binary driver.
# HorizSync source: edid, VertRefresh source: edid
ModelName "BenQ G2450"
HorizSync 30.0 - 83.0
VertRefresh 50.0 - 76.0
Option "UseHotplugEvents" "False"
There is also similar setting but in this case, for Intel driver only.
Aside of both of that, there may be need to disable automatic xrandr events in your DE.
gsettings set org.cinnamon.settings-daemon.plugins.xrandr active false
gsettings set org.gnome.settings-daemon.plugins.xrandr active false
About this independent one (I use it with Nouveau) – option is to disable udev completely (for a while). That means that it also won’t work for dynamic USB devices, etc. But it’s good enough if you need to disable monitor discovery for a moment and can turn it on later again.
sudo udevadm control --stop
sudo udevadm control --start