winex11.drv: Sort display modes.
Although tests show that their order are not always guaranteed on Windows, most of the time it is sorted. It also makes sure that when a 0Hz or 1Hz display mode is specified for ChangeDisplaySettingsExW(), the chosen display mode is the one with the highest frequency. Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
46182aa559
commit
a8b4cf7f2d
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
|
@ -333,6 +334,22 @@ BOOL get_primary_adapter(WCHAR *name)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static int mode_compare(const void *p1, const void *p2)
|
||||
{
|
||||
const DEVMODEW *a = p1, *b = p2;
|
||||
|
||||
if (a->dmBitsPerPel != b->dmBitsPerPel)
|
||||
return b->dmBitsPerPel - a->dmBitsPerPel;
|
||||
|
||||
if (a->dmPelsWidth != b->dmPelsWidth)
|
||||
return a->dmPelsWidth - b->dmPelsWidth;
|
||||
|
||||
if (a->dmPelsHeight != b->dmPelsHeight)
|
||||
return a->dmPelsHeight - b->dmPelsHeight;
|
||||
|
||||
return b->dmDisplayFrequency - a->dmDisplayFrequency;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* EnumDisplaySettingsEx (X11DRV.@)
|
||||
*
|
||||
|
@ -379,6 +396,8 @@ BOOL CDECL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmo
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
qsort(modes, mode_count, sizeof(*modes) + modes[0].dmDriverExtra, mode_compare);
|
||||
|
||||
if (cached_modes)
|
||||
handler.free_modes(cached_modes);
|
||||
lstrcpyW(cached_device_name, name);
|
||||
|
@ -477,6 +496,7 @@ static DEVMODEW *get_full_mode(ULONG_PTR id, const DEVMODEW *dev_mode)
|
|||
if (!handler.get_modes(id, 0, &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);
|
||||
|
|
Loading…
Reference in New Issue