ddraw: Implement get_window_region() on top of GetRandomRgn().

Instead of just GetClientRect(). This fixes a regression introduced by
3e9fe3e938. We also need to clip against e.g.
the screen edges instead of just the client rect.
oldstable
Henri Verbeet 2012-02-03 22:00:27 +01:00 committed by Alexandre Julliard
parent 10b2a21c3b
commit 204e53e449
1 changed files with 19 additions and 10 deletions

View File

@ -99,29 +99,38 @@ static HRESULT WINAPI ddraw_clipper_SetHWnd(IDirectDrawClipper *iface, DWORD fla
static HRGN get_window_region(HWND window)
{
POINT origin = {0, 0};
RECT client_rect;
POINT origin;
HRGN rgn;
HDC dc;
if (!GetClientRect(window, &client_rect))
if (!(dc = GetDC(window)))
{
/* This can happen if the window is destroyed, for example. */
WARN("Failed to get client rect.\n");
WARN("Failed to get dc.\n");
return NULL;
}
if (!ClientToScreen(window, &origin))
if (!(rgn = CreateRectRgn(0, 0, 0, 0)))
{
ERR("Failed to translate origin.\n");
ERR("Failed to create region.\n");
ReleaseDC(window, dc);
return NULL;
}
if (!OffsetRect(&client_rect, origin.x, origin.y))
if (GetRandomRgn(dc, rgn, SYSRGN) != 1)
{
ERR("Failed to translate client rect.\n");
ERR("Failed to get window region.\n");
DeleteObject(rgn);
ReleaseDC(window, dc);
return NULL;
}
return CreateRectRgnIndirect(&client_rect);
if (GetVersion() & 0x80000000)
{
GetDCOrgEx(dc, &origin);
OffsetRgn(rgn, origin.x, origin.y);
}
return rgn;
}
/*****************************************************************************