Module: wine Branch: master Commit: a3686eeb5e36416eee8a532dd358666fc46c7a39 URL: https://gitlab.winehq.org/wine/wine/-/commit/a3686eeb5e36416eee8a532dd358666...
Author: Rémi Bernon rbernon@codeweavers.com Date: Sat Feb 10 13:26:22 2024 +0100
win32u: Don't assume that the primary adapter is always first.
---
dlls/win32u/sysparams.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 87c37cd2e72..5dcf42ff7f5 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -2744,6 +2744,19 @@ static struct display_device *find_adapter_device_by_id( UINT index ) return NULL; }
+/* display_lock mutex must be held */ +static struct display_device *find_primary_adapter_device(void) +{ + struct adapter *adapter; + + LIST_FOR_EACH_ENTRY(adapter, &adapters, struct adapter, entry) + if (adapter->dev.state_flags & DISPLAY_DEVICE_PRIMARY_DEVICE) + return &adapter->dev; + + WARN( "Failed to find primary adapter.\n" ); + return NULL; +} + /* display_lock mutex must be held */ static struct display_device *find_adapter_device_by_name( UNICODE_STRING *name ) { @@ -2769,7 +2782,7 @@ static struct adapter *find_adapter( UNICODE_STRING *name ) if (!lock_display_devices()) return NULL;
if (name && name->Length) device = find_adapter_device_by_name( name ); - else device = find_adapter_device_by_id( 0 ); /* use primary adapter */ + else device = find_primary_adapter_device();
if (!device) adapter = NULL; else adapter = adapter_acquire( CONTAINING_RECORD( device, struct adapter, dev ) ); @@ -3226,7 +3239,7 @@ static LONG apply_display_settings( const WCHAR *devname, const DEVMODEW *devmod
place_all_displays( displays );
- if (!(primary = find_adapter_device_by_id( 0 ))) primary_name[0] = 0; + if (!(primary = find_primary_adapter_device())) primary_name[0] = 0; else wcscpy( primary_name, primary->device_name );
/* use the default implementation in virtual desktop mode */ @@ -3396,7 +3409,7 @@ INT get_display_depth( UNICODE_STRING *name ) if (name && name->Length) device = find_adapter_device_by_name( name ); else - device = find_adapter_device_by_id( 0 ); /* use primary adapter */ + device = find_primary_adapter_device();
if (!device) {