winemac.drv: Move synthetic display modes after the real ones.

Also return higher synthesized bitdepths first.

Signed-off-by: Tim Clem <tclem@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Tim Clem 2022-03-22 11:06:01 -07:00 committed by Alexandre Julliard
parent 8a8808e98b
commit c2936f70e3
1 changed files with 30 additions and 22 deletions

View File

@ -1049,7 +1049,7 @@ BOOL CDECL macdrv_EnumDisplaySettingsEx(LPCWSTR devname, DWORD mode,
display_mode = NULL; display_mode = NULL;
if (modes) if (modes)
{ {
int default_bpp = get_default_bpp(); int default_bpp;
DWORD seen_modes = 0; DWORD seen_modes = 0;
count = CFArrayGetCount(modes); count = CFArrayGetCount(modes);
@ -1064,36 +1064,44 @@ BOOL CDECL macdrv_EnumDisplaySettingsEx(LPCWSTR devname, DWORD mode,
display_mode_bpp = display_mode_bits_per_pixel(display_mode); display_mode_bpp = display_mode_bits_per_pixel(display_mode);
break; break;
} }
}
default_bpp = get_default_bpp();
/* If all the real modes are exhausted, synthesize lower bpp modes. */
if (!display_mode && (!modes_has_16bpp || !modes_has_8bpp))
{
/* We want to synthesize higher depths first. */
int synth_bpps[] = { modes_has_16bpp ? 0 : 16, modes_has_8bpp ? 0 : 8 };
size_t synth_bpp_idx;
for (synth_bpp_idx = 0; synth_bpp_idx < 2; synth_bpp_idx++)
{
int synth_bpp = synth_bpps[synth_bpp_idx];
if (synth_bpp == 0)
continue;
for (i = 0; i < count; i++)
{
CGDisplayModeRef candidate = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
/* We only synthesize modes from those having the default bpp. */ /* We only synthesize modes from those having the default bpp. */
if (display_mode_bits_per_pixel(candidate) != default_bpp) if (display_mode_bits_per_pixel(candidate) != default_bpp)
continue; continue;
if (!modes_has_8bpp)
{
seen_modes++; seen_modes++;
if (seen_modes > mode) if (seen_modes > mode)
{ {
display_mode = (CGDisplayModeRef)CFRetain(candidate); display_mode = (CGDisplayModeRef)CFRetain(candidate);
display_mode_bpp = 8; display_mode_bpp = synth_bpp;
synthesized = TRUE; synthesized = TRUE;
break; break;
} }
} }
if (!modes_has_16bpp) if (display_mode)
{
seen_modes++;
if (seen_modes > mode)
{
display_mode = (CGDisplayModeRef)CFRetain(candidate);
display_mode_bpp = 16;
synthesized = TRUE;
break; break;
} }
} }
} }
}
LeaveCriticalSection(&modes_section); LeaveCriticalSection(&modes_section);
} }