Zhiyi Zhang (@zhiyi) commented about dlls/win32u/sysparams.c:
place_all_displays( displays );
- ret = user_driver->pChangeDisplaySettings( displays, hwnd, flags, lparam );
- if (!(ret = user_driver->pChangeDisplaySettings( displays, hwnd, flags, lparam )))
send_message_timeout( HWND_BROADCAST, WM_DISPLAYCHANGE, displays->dmBitsPerPel,
First, displays->dmBitsPerPel is from ChangeDisplaySettings() and maybe 8bit and 16bit. But in winex11.drv, screen_bpp is always used and is always 32bit or 24bit. On Windows, 8bit and 16bit display modes are emulated. If I remember correctly, Windows sends WM_DISPLAYCHANGE with 32bit depth even if you're changing to an 8bit display mode.
Second, the primary monitor may change after you detach the first monitor. So you can't just use the first monitor as the primary monitor. Instead, you should query for the primary monitor dimension after display changes and use that to use the WM_DISPLAYCHANGE message.