mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 08:49:15 +00:00
win32u: Sort adapter display modes after reading from the registry.
This commit is contained in:
parent
e741f49aa3
commit
25272711b4
2 changed files with 49 additions and 3 deletions
|
@ -546,6 +546,53 @@ static BOOL write_registry_settings( const WCHAR *adapter_path, const DEVMODEW *
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int mode_compare(const void *p1, const void *p2)
|
||||
{
|
||||
DWORD a_width, a_height, b_width, b_height;
|
||||
const DEVMODEW *a = p1, *b = p2;
|
||||
int ret;
|
||||
|
||||
/* Depth in descending order */
|
||||
if ((ret = b->dmBitsPerPel - a->dmBitsPerPel)) return ret;
|
||||
|
||||
/* Use the width and height in landscape mode for comparison */
|
||||
if (a->dmDisplayOrientation == DMDO_DEFAULT || a->dmDisplayOrientation == DMDO_180)
|
||||
{
|
||||
a_width = a->dmPelsWidth;
|
||||
a_height = a->dmPelsHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
a_width = a->dmPelsHeight;
|
||||
a_height = a->dmPelsWidth;
|
||||
}
|
||||
|
||||
if (b->dmDisplayOrientation == DMDO_DEFAULT || b->dmDisplayOrientation == DMDO_180)
|
||||
{
|
||||
b_width = b->dmPelsWidth;
|
||||
b_height = b->dmPelsHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
b_width = b->dmPelsHeight;
|
||||
b_height = b->dmPelsWidth;
|
||||
}
|
||||
|
||||
/* Width in ascending order */
|
||||
if ((ret = a_width - b_width)) return ret;
|
||||
|
||||
/* Height in ascending order */
|
||||
if ((ret = a_height - b_height)) return ret;
|
||||
|
||||
/* Frequency in descending order */
|
||||
if ((ret = b->dmDisplayFrequency - a->dmDisplayFrequency)) return ret;
|
||||
|
||||
/* Orientation in ascending order */
|
||||
if ((ret = a->dmDisplayOrientation - b->dmDisplayOrientation)) return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL read_display_adapter_settings( unsigned int index, struct adapter *info )
|
||||
{
|
||||
char buffer[4096];
|
||||
|
@ -606,6 +653,8 @@ static BOOL read_display_adapter_settings( unsigned int index, struct adapter *i
|
|||
mode = NEXT_DEVMODEW(mode);
|
||||
}
|
||||
info->mode_count = i;
|
||||
|
||||
qsort(info->modes, info->mode_count, sizeof(*info->modes) + info->modes->dmDriverExtra, mode_compare);
|
||||
}
|
||||
|
||||
/* DeviceID */
|
||||
|
|
|
@ -403,7 +403,6 @@ static DEVMODEW *get_full_mode(ULONG_PTR id, DEVMODEW *dev_mode)
|
|||
if (!settings_handler.get_modes(id, EDS_ROTATEDMODE, &modes, &mode_count))
|
||||
return NULL;
|
||||
|
||||
qsort(modes, mode_count, sizeof(*modes) + modes[0].dmDriverExtra, mode_compare);
|
||||
for (mode_idx = 0; mode_idx < mode_count; ++mode_idx)
|
||||
{
|
||||
found_mode = (DEVMODEW *)((BYTE *)modes + (sizeof(*modes) + modes[0].dmDriverExtra) * mode_idx);
|
||||
|
@ -1062,8 +1061,6 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
|
|||
if (!settings_handler.get_modes( adapters[adapter].id, EDS_ROTATEDMODE, &modes, &mode_count ))
|
||||
continue;
|
||||
|
||||
qsort( modes, mode_count, sizeof(*modes) + modes[0].dmDriverExtra, mode_compare );
|
||||
|
||||
for (mode = modes; mode_count; mode_count--)
|
||||
{
|
||||
TRACE( "mode: %p\n", mode );
|
||||
|
|
Loading…
Reference in a new issue