Commit fa32c2ef authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Use find_adapter_device_by_(name|id) helpers in find_adapter.

parent aa1e5939
...@@ -2017,16 +2017,16 @@ static struct display_device *find_adapter_device_by_name( UNICODE_STRING *name ...@@ -2017,16 +2017,16 @@ static struct display_device *find_adapter_device_by_name( UNICODE_STRING *name
*/ */
static struct adapter *find_adapter( UNICODE_STRING *name ) static struct adapter *find_adapter( UNICODE_STRING *name )
{ {
struct display_device *device;
struct adapter *adapter; struct adapter *adapter;
LIST_FOR_EACH_ENTRY(adapter, &adapters, struct adapter, entry) if (name && name->Length) device = find_adapter_device_by_name( name );
{ else device = find_adapter_device_by_id( 0 ); /* use primary adapter */
if (!name || !name->Length) return adapter_acquire( adapter ); /* use primary adapter */
if (!wcsnicmp( name->Buffer, adapter->dev.device_name, name->Length / sizeof(WCHAR) ) && if (!device) adapter = NULL;
!adapter->dev.device_name[name->Length / sizeof(WCHAR)]) else adapter = adapter_acquire( CONTAINING_RECORD( device, struct adapter, dev ) );
return adapter_acquire( adapter );
} return adapter;
return NULL;
} }
/*********************************************************************** /***********************************************************************
...@@ -2496,11 +2496,7 @@ LONG WINAPI NtUserChangeDisplaySettings( UNICODE_STRING *devname, DEVMODEW *devm ...@@ -2496,11 +2496,7 @@ LONG WINAPI NtUserChangeDisplaySettings( UNICODE_STRING *devname, DEVMODEW *devm
if (!lock_display_devices()) return DISP_CHANGE_FAILED; if (!lock_display_devices()) return DISP_CHANGE_FAILED;
adapter = find_adapter( devname ); adapter = find_adapter( devname );
unlock_display_devices(); unlock_display_devices();
if (!adapter) if (!adapter) return DISP_CHANGE_BADPARAM;
{
WARN( "Invalid device name %s.\n", debugstr_us(devname) );
return DISP_CHANGE_BADPARAM;
}
if (!adapter_get_full_mode( adapter, devmode, &full_mode )) ret = DISP_CHANGE_BADMODE; if (!adapter_get_full_mode( adapter, devmode, &full_mode )) ret = DISP_CHANGE_BADMODE;
else if ((flags & CDS_UPDATEREGISTRY) && !adapter_set_registry_settings( adapter, &full_mode )) ret = DISP_CHANGE_NOTUPDATED; else if ((flags & CDS_UPDATEREGISTRY) && !adapter_set_registry_settings( adapter, &full_mode )) ret = DISP_CHANGE_NOTUPDATED;
...@@ -2559,11 +2555,7 @@ BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD index, DEVM ...@@ -2559,11 +2555,7 @@ BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD index, DEVM
if (!lock_display_devices()) return FALSE; if (!lock_display_devices()) return FALSE;
adapter = find_adapter( device ); adapter = find_adapter( device );
unlock_display_devices(); unlock_display_devices();
if (!adapter) if (!adapter) return FALSE;
{
WARN( "Invalid device name %s.\n", debugstr_us(device) );
return FALSE;
}
lstrcpynW( devmode->dmDeviceName, wine_display_driverW, ARRAY_SIZE(devmode->dmDeviceName) ); lstrcpynW( devmode->dmDeviceName, wine_display_driverW, ARRAY_SIZE(devmode->dmDeviceName) );
devmode->dmSpecVersion = DM_SPECVERSION; devmode->dmSpecVersion = DM_SPECVERSION;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment