According to tests, GetDeviceCaps(NUMCOLORS) returns -1 for display DCs when the current display mode is 8-bit on newer versions of Windows, which makes sense because lower bit depth display modes are actually emulated with 32-bit modes.
Spotted by Marc P marc.pluhar+winehq@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52679 Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/user32/tests/monitor.c | 1 - dlls/win32u/driver.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index 1d88afafb18..67c932398b9 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -2310,7 +2310,6 @@ static void test_display_dc(void)
value = GetDeviceCaps(hdc, NUMCOLORS); if (bpps[i] > 8 || (bpps[i] == 8 && LOBYTE(LOWORD(GetVersion())) >= 6)) - todo_wine_if(bpps[i] == 8 && LOBYTE(LOWORD(GetVersion())) >= 6) ok(value == -1, "Expected -1, got %d.\n", value); else if (bpps[i] == 8 && LOBYTE(LOWORD(GetVersion())) < 6) ok(value > 16 && value <= 256, "Got %d.\n", value); diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index d1062cb5f3a..75e07d6c4e3 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -294,7 +294,8 @@ static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap ) case LOGPIXELSY: return get_system_dpi(); case NUMCOLORS: bpp = NtGdiGetDeviceCaps( dev->hdc, BITSPIXEL ); - return (bpp > 8) ? -1 : (1 << bpp); + /* Newer versions of Windows return -1 for 8-bit and higher */ + return (bpp > 4) ? -1 : (1 << bpp); case COLORRES: /* The observed correspondence between BITSPIXEL and COLORRES is: * BITSPIXEL: 8 -> COLORRES: 18