Commit 546cbdc2 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

win32u: Create a dummy bitmap for display device contexts.

On Windows 7 and older versions of Windows, calling GetCurrentObject(hdc, OBJ_BITMAP) for a display device context will return a valid handle. However, this handle will fail for GetObject(). On newer versions of Windows, GetCurrentObject(hdc, OBJ_BITMAP) for display device contexts returns a bitmap of virtual screen size and its size changes after display mode changes. This behavior is tested in the _check_display_dc() function in user32/tests/monitor.c. The screen shot function of WeChat depends on GetObject() to either return failure or a valid size for the bitmap from display device contexts. Since Wine currently report Windows 7 as default and to save memory, the Windows 7 behavior is implemented. Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com>
parent 18d4d5a5
......@@ -2789,7 +2789,6 @@ static void test_CreateBitmap(void)
"0: %p, 1: %p, 4: %p, 5: %p, curObj1 %p, old1 %p\n",
bm, bm1, bm4, bm5, curObj1, old1);
ok(bm != bm2 && bm != bm3, "0: %p, 2: %p, 3: %p\n", bm, bm2, bm3);
todo_wine
ok(bm != curObj2, "0: %p, curObj2 %p\n", bm, curObj2);
ok(old2 == 0, "old2 %p\n", old2);
......
......@@ -2164,7 +2164,6 @@ static void _check_display_dc(INT line, HDC hdc, const DEVMODEA *dm, BOOL allow_
ok_(__FILE__, line)(!!hbmp, "GetCurrentObject failed, error %#lx.\n", GetLastError());
ret = GetObjectA(hbmp, sizeof(bitmap), &bitmap);
/* GetObjectA fails on Win7 and older */
ok_(__FILE__, line)(ret || broken(!ret), "GetObjectA failed, error %ld.\n", GetLastError());
if (ret)
{
ok_(__FILE__, line)(bitmap.bmType == 0, "Expected bmType %d, got %d.\n", 0, bitmap.bmType);
......
......@@ -274,7 +274,13 @@ void free_dc_ptr( DC *dc )
GDI_dec_ref_count( dc->hPen );
GDI_dec_ref_count( dc->hBrush );
GDI_dec_ref_count( dc->hFont );
if (dc->hBitmap) GDI_dec_ref_count( dc->hBitmap );
if (dc->hBitmap)
{
if (dc->is_display)
NtGdiDeleteClientObj( dc->hBitmap );
else
GDI_dec_ref_count( dc->hBitmap );
}
free_gdi_handle( dc->hSelf );
free_dc_state( dc );
}
......@@ -724,6 +730,9 @@ HDC WINAPI NtGdiOpenDCW( UNICODE_STRING *device, const DEVMODEW *devmode, UNICOD
if (!(dc = alloc_dc_ptr( NTGDI_OBJ_DC ))) return 0;
hdc = dc->hSelf;
if (is_display)
dc->hBitmap = NtGdiCreateClientObj( NTGDI_OBJ_SURF );
else
dc->hBitmap = GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP ));
TRACE("(device=%s, output=%s): returning %p\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment