The first parameter `current` for get_virtual_modes() is unused. It was introduced by 1ffe5b35.
From: Zhiyi Zhang zzhang@codeweavers.com
The first parameter `current` for get_virtual_modes() is unused. It was introduced by 1ffe5b35. --- dlls/win32u/sysparams.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 51ff4aceccc..d36a6ddfb7e 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1667,7 +1667,7 @@ static SIZE *get_screen_sizes( const DEVMODEW *maximum, const DEVMODEW *modes, U return sizes; }
-static DEVMODEW *get_virtual_modes( const DEVMODEW *current, const DEVMODEW *initial, const DEVMODEW *maximum, +static DEVMODEW *get_virtual_modes( const DEVMODEW *initial, const DEVMODEW *maximum, const DEVMODEW *host_modes, UINT host_modes_count, UINT32 *modes_count ) { UINT depths[] = {8, 16, initial->dmBitsPerPel}, freqs[] = {60, -1}, sizes_count, i, j, f, count = 0; @@ -1764,7 +1764,7 @@ static void add_modes( const DEVMODEW *current, UINT host_modes_count, const DEV if (!read_source_mode( source->key, ENUM_CURRENT_SETTINGS, &virtual )) virtual = physical;
- if ((virtual_modes = get_virtual_modes( &virtual, current, &physical, host_modes, host_modes_count, &virtual_count ))) + if ((virtual_modes = get_virtual_modes( current, &physical, host_modes, host_modes_count, &virtual_count ))) { modes_count = virtual_count; modes = virtual_modes; @@ -2281,7 +2281,7 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx ) add_monitor( &monitor, ctx );
/* Expose the virtual source display modes as physical modes, to avoid DPI scaling */ - if (!(modes = get_virtual_modes( ¤t, &initial, &maximum, NULL, 0, &modes_count ))) return STATUS_NO_MEMORY; + if (!(modes = get_virtual_modes( &initial, &maximum, NULL, 0, &modes_count ))) return STATUS_NO_MEMORY; add_modes( ¤t, modes_count, modes, ctx ); free( modes );
From: Zhiyi Zhang zzhang@codeweavers.com
Don't use the current mode in the registry if it's a detached mode when adding virtual modes. Otherwise, the requested/previous current mode in the registry could be a detached mode and it will cause functions like MonitorFromRect() to return NULL, even after monitor gets turned on.
Fix Witcher 3 (292030) black screen after monitor is turned off and then on. --- dlls/win32u/sysparams.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index d36a6ddfb7e..783ea6c3c11 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -466,6 +466,15 @@ static UINT devmode_get( const DEVMODEW *mode, UINT field ) return 0; }
+static BOOL is_detached_mode( const DEVMODEW *mode ) +{ + return mode->dmFields & DM_POSITION && + mode->dmFields & DM_PELSWIDTH && + mode->dmFields & DM_PELSHEIGHT && + mode->dmPelsWidth == 0 && + mode->dmPelsHeight == 0; +} + static BOOL write_source_mode( HKEY hkey, UINT index, const DEVMODEW *mode ) { WCHAR bufferW[MAX_PATH] = {0}; @@ -1761,7 +1770,7 @@ static void add_modes( const DEVMODEW *current, UINT host_modes_count, const DEV } else { - if (!read_source_mode( source->key, ENUM_CURRENT_SETTINGS, &virtual )) + if (!read_source_mode( source->key, ENUM_CURRENT_SETTINGS, &virtual ) || is_detached_mode( &virtual )) virtual = physical;
if ((virtual_modes = get_virtual_modes( current, &physical, host_modes, host_modes_count, &virtual_count ))) @@ -1815,15 +1824,6 @@ static void release_display_manager_ctx( struct device_manager_ctx *ctx ) } }
-static BOOL is_detached_mode( const DEVMODEW *mode ) -{ - return mode->dmFields & DM_POSITION && - mode->dmFields & DM_PELSWIDTH && - mode->dmFields & DM_PELSHEIGHT && - mode->dmPelsWidth == 0 && - mode->dmPelsHeight == 0; -} - static BOOL is_monitor_active( struct monitor *monitor ) { DEVMODEW current_mode = {.dmSize = sizeof(DEVMODEW)};
This merge request was approved by Rémi Bernon.