I think `ChangeDisplaySettingsExW( NULL, NULL, NULL, 0, NULL );` only applies whatever was stored in the registry? So if a process changes the registry settings, this will *not* restore the original display mode, is that intended?
Generally speaking, in my opinion we should simply stop messing with the host display settings entirely and instead move toward a fully virtualized display modes. There's work in progress towards that for the wayland driver. It's still a long way to go for x11 though.
This looks interesting nonetheless, even though it also raises a couple of questions like what should happen if two processes change display mode one after another? Ideally for best user experience we should probably try to always restore the initial display settings. Which maybe could be queried by explorer on startup.