mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 11:26:10 +00:00
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.
This commit is contained in:
parent
10b2a21c3b
commit
204e53e449
1 changed files with 19 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
|
Loading…
Reference in a new issue