From: Wei Xie xiewei@uniontech.com
1. Added fallback logic to use default display dimensions when XRandR fails to provide screen sizes 2. Implemented default mode creation with standard 60Hz refresh rate 3. Added proper error handling for memory allocation failures 4. Maintains compatibility with systems where XRandR extension is not available
The reason for the problem is that in scenes where the monitor is not connected, xrandr does not get connected display --- dlls/winex11.drv/xrandr.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 979cbc8645f..13d07805f5e 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -267,8 +267,35 @@ static BOOL xrandr10_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n short *rates;
sizes = pXRRSizes( gdi_display, DefaultScreen( gdi_display ), &size_count ); + /* If screen size is not obtained, try using default screen size */ if (size_count <= 0) + { + INT width = DisplayWidth(gdi_display, DefaultScreen(gdi_display)); + INT height = DisplayHeight(gdi_display, DefaultScreen(gdi_display)); + + if (width > 0 && height > 0) + { + /* Use default screen size to create a mode */ + mode_count = 1; + modes = calloc(mode_count * DEPTH_COUNT, sizeof(*modes) + sizeof(SizeID)); + if (!modes) + { + RtlSetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + for (depth_idx = 0, mode = modes; depth_idx < DEPTH_COUNT; ++depth_idx) + { + add_xrandr10_mode(mode, depths[depth_idx], width, height, 0, 0, full); + mode = NEXT_DEVMODEW(mode); + } + + *new_modes = modes; + *new_mode_count = mode_count * DEPTH_COUNT; + return TRUE; + } return FALSE; + }
for (size_idx = 0; size_idx < size_count; ++size_idx) { @@ -350,7 +377,13 @@ static BOOL xrandr10_get_current_mode( x11drv_settings_id id, DEVMODEW *mode )
sizes = pXRRSizes( gdi_display, DefaultScreen( gdi_display ), &size_count ); if (size_count <= 0) - return FALSE; + { + mode->dmBitsPerPel = screen_bpp; + mode->dmPelsWidth = DisplayWidth(gdi_display, DefaultScreen(gdi_display)); + mode->dmPelsHeight = DisplayHeight(gdi_display, DefaultScreen(gdi_display)); + mode->dmDisplayFrequency = 60; + return TRUE; + }
screen_config = pXRRGetScreenInfo( gdi_display, DefaultRootWindow( gdi_display ) ); size_id = pXRRConfigCurrentConfiguration( screen_config, &rotation );