diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c index b081376be3b..5d56caa5eb1 100644 --- a/dlls/gdi32/tests/dc.c +++ b/dlls/gdi32/tests/dc.c @@ -556,6 +556,45 @@ static void test_boundsrect_invalid(void) DeleteDC(hdc); } +static void test_desktop_colorres(void) +{ + HDC hdc = GetDC(NULL); + int bitspixel, colorres; + + bitspixel = GetDeviceCaps(hdc, BITSPIXEL); + ok(bitspixel != 0, "Expected to get valid BITSPIXEL capability value\n"); + + colorres = GetDeviceCaps(hdc, COLORRES); + ok(colorres != 0 || + broken(colorres == 0), /* Win9x */ + "Expected to get valid COLORRES capability value\n"); + + if (colorres) + { + switch (bitspixel) + { + case 8: + ok(colorres == 18, + "Expected COLORRES to be 18, got %d\n", colorres); + break; + case 16: + ok(colorres == 16, + "Expected COLORRES to be 16, got %d\n", colorres); + break; + case 24: + case 32: + ok(colorres == 24, + "Expected COLORRES to be 24, got %d\n", bitspixel); + break; + default: + ok(0, "Got unknown BITSPIXEL %d with COLORRES %d\n", bitspixel, colorres); + break; + } + } + + DeleteDC(hdc); +} + START_TEST(dc) { test_savedc(); @@ -565,4 +604,5 @@ START_TEST(dc) test_DC_bitmap(); test_DeleteDC(); test_boundsrect_invalid(); + test_desktop_colorres(); } diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index ba6cc51cf93..1462b5ed40c 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -235,6 +235,15 @@ INT CDECL X11DRV_GetDeviceCaps( X11DRV_PDEVICE *physDev, INT cap ) return text_caps; case CLIPCAPS: return CP_REGION; + case COLORRES: + /* The observed correspondence between BITSPIXEL and COLORRES is: + * BITSPIXEL: 8 -> COLORRES: 18 + * BITSPIXEL: 16 -> COLORRES: 16 + * BITSPIXEL: 24 -> COLORRES: 24 + * (note that depth_to_bpp never chooses a bpp of 24) + * BITSPIXEL: 32 -> COLORRES: 24 */ + return (screen_bpp <= 8) ? 18 : + (screen_bpp == 32) ? 24 : screen_bpp; case RASTERCAPS: return (RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 | RC_DI_BITMAP | RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS | @@ -258,7 +267,6 @@ INT CDECL X11DRV_GetDeviceCaps( X11DRV_PDEVICE *physDev, INT cap ) case SIZEPALETTE: return palette_size; case NUMRESERVED: - case COLORRES: case PHYSICALWIDTH: case PHYSICALHEIGHT: case PHYSICALOFFSETX: