From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/sysparams.c | 96 ++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 48 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 73923855bff..4f7a80f1918 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1802,7 +1802,7 @@ static BOOL default_update_display_devices( const struct gdi_device_manager *man }
/* parse the desktop size specification */ -static BOOL parse_size( const WCHAR *size, unsigned int *width, unsigned int *height ) +static BOOL parse_size( const WCHAR *size, DWORD *width, DWORD *height ) { WCHAR *end;
@@ -1815,7 +1815,7 @@ static BOOL parse_size( const WCHAR *size, unsigned int *width, unsigned int *he }
/* retrieve the default desktop size from the registry */ -static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height ) +static BOOL get_default_desktop_size( DWORD *width, DWORD *height ) { WCHAR buffer[4096]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; @@ -1833,10 +1833,9 @@ static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height return TRUE; }
-static BOOL add_virtual_source( struct device_manager_ctx *ctx ) +static BOOL add_virtual_modes( struct device_manager_ctx *ctx, const DEVMODEW *maximum, + const DEVMODEW *initial, const DEVMODEW *current ) { - static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE; - struct gdi_monitor monitor = {0}; static struct screen_size { unsigned int width; @@ -1874,24 +1873,54 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx ) {1920, 1200}, {2560, 1600} }; - - UINT screen_width, screen_height, max_width, max_height; - unsigned int depths[] = {8, 16, 0}; - DEVMODEW current, mode = + unsigned int depths[] = {8, 16, initial->dmBitsPerPel}; + DEVMODEW mode = { .dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY, .dmDisplayFrequency = 60, }; UINT i, j;
- max_width = ctx->primary.dmPelsWidth; - max_height = ctx->primary.dmPelsHeight; - depths[ARRAY_SIZE(depths) - 1] = ctx->primary.dmBitsPerPel; + for (i = 0; i < ARRAY_SIZE(depths); ++i) + { + mode.dmBitsPerPel = depths[i]; + + for (j = 0; j < ARRAY_SIZE(screen_sizes); ++j) + { + mode.dmPelsWidth = screen_sizes[j].width; + mode.dmPelsHeight = screen_sizes[j].height; + + if (mode.dmPelsWidth > maximum->dmPelsWidth || mode.dmPelsHeight > maximum->dmPelsWidth) continue; + if (mode.dmPelsWidth == maximum->dmPelsWidth && mode.dmPelsHeight == maximum->dmPelsWidth) continue; + if (mode.dmPelsWidth == initial->dmPelsWidth && mode.dmPelsHeight == initial->dmPelsHeight) continue; + if (!is_same_devmode( &mode, current )) add_mode( &mode, FALSE, ctx ); + } + + mode.dmPelsWidth = initial->dmPelsWidth; + mode.dmPelsHeight = initial->dmPelsHeight; + if (!is_same_devmode( &mode, current )) add_mode( &mode, FALSE, ctx ); + + if (maximum->dmPelsWidth != initial->dmPelsWidth || maximum->dmPelsWidth != initial->dmPelsHeight) + { + mode.dmPelsWidth = maximum->dmPelsWidth; + mode.dmPelsHeight = maximum->dmPelsHeight; + if (!is_same_devmode( &mode, current )) add_mode( &mode, FALSE, ctx ); + } + } + + return TRUE; +}
- if (!get_default_desktop_size( &screen_width, &screen_height )) +static BOOL add_virtual_source( struct device_manager_ctx *ctx ) +{ + static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE; + DEVMODEW current, mode = ctx->primary, maximum = mode, initial = mode; + struct gdi_monitor monitor = {0}; + + if (!get_default_desktop_size( &initial.dmPelsWidth, &initial.dmPelsHeight )) { - screen_width = max_width; - screen_height = max_height; + initial.dmPelsWidth = maximum.dmPelsWidth; + initial.dmPelsHeight = maximum.dmPelsHeight; }
add_source( ctx, "Virtual", source_flags ); @@ -1899,9 +1928,8 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx ) { current = mode; current.dmFields |= DM_POSITION; - current.dmBitsPerPel = ctx->primary.dmBitsPerPel; - current.dmPelsWidth = screen_width; - current.dmPelsHeight = screen_height; + current.dmPelsWidth = initial.dmPelsWidth; + current.dmPelsHeight = initial.dmPelsHeight; }
monitor.rc_monitor.right = current.dmPelsWidth; @@ -1910,36 +1938,8 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx ) monitor.rc_work.bottom = current.dmPelsHeight; add_monitor( &monitor, ctx );
- for (i = 0; i < ARRAY_SIZE(depths); ++i) - { - mode.dmBitsPerPel = depths[i]; - - for (j = 0; j < ARRAY_SIZE(screen_sizes); ++j) - { - mode.dmPelsWidth = screen_sizes[j].width; - mode.dmPelsHeight = screen_sizes[j].height; - - if (mode.dmPelsWidth > max_width || mode.dmPelsHeight > max_height) continue; - if (mode.dmPelsWidth == max_width && mode.dmPelsHeight == max_height) continue; - if (mode.dmPelsWidth == screen_width && mode.dmPelsHeight == screen_height) continue; - - if (is_same_devmode( &mode, ¤t )) add_mode( ¤t, TRUE, ctx ); - else add_mode( &mode, FALSE, ctx ); - } - - mode.dmPelsWidth = screen_width; - mode.dmPelsHeight = screen_height; - if (is_same_devmode( &mode, ¤t )) add_mode( ¤t, TRUE, ctx ); - else add_mode( &mode, FALSE, ctx ); - - if (max_width != screen_width || max_height != screen_height) - { - mode.dmPelsWidth = max_width; - mode.dmPelsHeight = max_height; - if (is_same_devmode( &mode, ¤t )) add_mode( ¤t, TRUE, ctx ); - else add_mode( &mode, FALSE, ctx ); - } - } + add_mode( ¤t, TRUE, ctx ); + add_virtual_modes( ctx, &maximum, &initial, ¤t );
return TRUE; }