[PATCH 1/1] ddraw: Implement get_window_region() on top of GetRandomRgn().

Henri Verbeet hverbeet at codeweavers.com
Fri Feb 3 15:00:27 CST 2012


Instead of just GetClientRect(). This fixes a regression introduced by
3e9fe3e938f26a8c831f92367a13776d165cfdf8. We also need to clip against e.g.
the screen edges instead of just the client rect.
---
 dlls/ddraw/clipper.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/dlls/ddraw/clipper.c b/dlls/ddraw/clipper.c
index 81e9e8b..89a3bf3 100644
--- a/dlls/ddraw/clipper.c
+++ b/dlls/ddraw/clipper.c
@@ -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;
 }
 
 /*****************************************************************************
-- 
1.7.3.4




More information about the wine-patches mailing list