Author: jimtabor
Date: Mon Feb 28 06:31:44 2011
New Revision: 50933

URL: http://svn.reactos.org/svn/reactos?rev=50933&view=rev
Log:
[Win32k|User32]
- Clarify the meaning and the use of 0, 1 and 2 for user window regions, wine 
never did. Noticing patches not corresponding in correctness and understanding, 
leaving potential crashes in the DCE code, which depend on these types.
- Patch based on Rafal Harabien patch, fixes wine msg SetWindowRgn test, see 
also bug 5959.

Modified:
    trunk/reactos/dll/win32/user32/windows/defwnd.c
    trunk/reactos/dll/win32/user32/windows/nonclient.c
    trunk/reactos/dll/win32/user32/windows/window.c
    trunk/reactos/include/reactos/win32k/ntuser.h
    trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
    trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
    trunk/reactos/subsystems/win32/win32k/ntuser/window.c
    trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c

Modified: trunk/reactos/dll/win32/user32/windows/defwnd.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/defwnd.c?rev=50933&r1=50932&r2=50933&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] Mon Feb 28 
06:31:44 2011
@@ -1189,7 +1189,7 @@
         case WM_SYSCOLORCHANGE:
         {
             /* force to redraw non-client area */
-            DefWndNCPaint(hWnd, (HRGN)1, -1);
+            DefWndNCPaint(hWnd, HRGN_WINDOW, -1);
             /* Use InvalidateRect to redraw client area, enable
              * erase to redraw all subcontrols otherwise send the
              * WM_SYSCOLORCHANGE to child windows/controls is required
@@ -1966,7 +1966,7 @@
 
             if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == 
WS_CAPTION)
             {
-                DefWndNCPaint(hWnd, (HRGN)1, -1);
+                DefWndNCPaint(hWnd, HRGN_WINDOW, -1);
             }
             Result = 1;
             break;
@@ -2112,7 +2112,7 @@
 
             if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == 
WS_CAPTION)
             {
-                DefWndNCPaint(hWnd, (HRGN)1, -1);
+                DefWndNCPaint(hWnd, HRGN_WINDOW, -1);
             }
             Result = 1;
             break;

Modified: trunk/reactos/dll/win32/user32/windows/nonclient.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/nonclient.c?rev=50933&r1=50932&r2=50933&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/nonclient.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/nonclient.c [iso-8859-1] Mon Feb 28 
06:31:44 2011
@@ -489,7 +489,8 @@
    }
 
    ReleaseDC(hWnd, hDC);
-   DeleteObject(hRgn); // We use DCX_KEEPCLIPRGN
+   if (hRgn != HRGN_WINDOW)
+      DeleteObject(hRgn); // We use DCX_KEEPCLIPRGN
 
    return 0;
 }
@@ -650,7 +651,7 @@
 LRESULT
 DefWndNCActivate(HWND hWnd, WPARAM wParam)
 {
-   DefWndNCPaint(hWnd, (HRGN)1, wParam);
+   DefWndNCPaint(hWnd, HRGN_WINDOW, wParam);
    return TRUE;
 }
 

Modified: trunk/reactos/dll/win32/user32/windows/window.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/window.c?rev=50933&r1=50932&r2=50933&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] Mon Feb 28 
06:31:44 2011
@@ -1727,7 +1727,7 @@
 
         if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
         {
-            DefWndNCPaint(hWnd, (HRGN)1, -1);
+            DefWndNCPaint(hWnd, HRGN_WINDOW, -1);
         }
         return TRUE;
     }
@@ -1757,7 +1757,7 @@
 
         if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
         {
-            DefWndNCPaint(hWnd, (HRGN)1, -1);
+            DefWndNCPaint(hWnd, HRGN_WINDOW, -1);
         }
         return TRUE;
     }

Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntuser.h?rev=50933&r1=50932&r2=50933&view=diff
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Mon Feb 28 
06:31:44 2011
@@ -230,6 +230,10 @@
 C_ASSERT(sizeof(CLIENTINFO) <= sizeof(((PTEB)0)->Win32ClientInfo));
 
 #define GetWin32ClientInfo() ((PCLIENTINFO)(NtCurrentTeb()->Win32ClientInfo))
+
+#define HRGN_NULL    ( (HRGN) 0) // NULL empty region
+#define HRGN_WINDOW  ( (HRGN) 1) // region from window rcWindow
+#define HRGN_MONITOR ( (HRGN) 2) // region from monitor region.
 
 /* Menu Item fType. */
 #define MFT_RTOL 0x6000

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/painting.c?rev=50933&r1=50932&r2=50933&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] Mon 
Feb 28 06:31:44 2011
@@ -141,7 +141,7 @@
    UINT RgnType;
 
    if (Window->hrgnUpdate != NULL &&
-       Window->hrgnUpdate != (HRGN)1)
+       Window->hrgnUpdate != HRGN_WINDOW)
    {
       hRgnNonClient = IntCalcWindowRgn(Window, FALSE);
 
@@ -151,14 +151,14 @@
        */
       if (hRgnNonClient == NULL)
       {
-         return (HRGN)1;
+         return HRGN_WINDOW;
       }
 
       hRgnWindow = IntCalcWindowRgn(Window, TRUE);
       if (hRgnWindow == NULL)
       {
          REGION_FreeRgnByHandle(hRgnNonClient);
-         return (HRGN)1;
+         return HRGN_WINDOW;
       }
 
       RgnType = NtGdiCombineRgn(hRgnNonClient, hRgnNonClient,
@@ -167,7 +167,7 @@
       {
          REGION_FreeRgnByHandle(hRgnWindow);
          REGION_FreeRgnByHandle(hRgnNonClient);
-         return (HRGN)1;
+         return HRGN_WINDOW;
       }
       else if (RgnType == NULLREGION)
       {
@@ -1049,7 +1049,7 @@
    else
    {
       /* Get the update region bounding box. */
-      if (Window->hrgnUpdate == (HRGN)1)
+      if (Window->hrgnUpdate == HRGN_WINDOW)
       {
          Rect = Window->rcClient;
       }

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/windc.c?rev=50933&r1=50932&r2=50933&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/windc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/windc.c [iso-8859-1] Mon Feb 
28 06:31:44 2011
@@ -551,7 +551,7 @@
       ClipRegion = Wnd->hrgnUpdate;
    }
 
-   if (ClipRegion == (HRGN) 1)
+   if (ClipRegion == HRGN_WINDOW)
    {
       if (!(Flags & DCX_WINDOW))
       {

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/window.c?rev=50933&r1=50932&r2=50933&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Mon Feb 
28 06:31:44 2011
@@ -4017,6 +4017,7 @@
 }
 
 
+// This should be in user32!
 INT FASTCALL
 IntGetWindowRgn(PWND Window, HRGN hRgn)
 {
@@ -4055,6 +4056,7 @@
    return Ret;
 }
 
+// This should be in user32!
 INT FASTCALL
 IntGetWindowRgnBox(PWND Window, RECTL *Rect)
 {
@@ -4104,6 +4106,8 @@
 {
    HRGN hrgnCopy;
    PWND Window;
+   INT flags = 
(SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE);
+   BOOLEAN Ret = FALSE;
    DECLARE_RETURN(INT);
 
    DPRINT("Enter NtUserSetWindowRgn\n");
@@ -4119,32 +4123,31 @@
       if (GDIOBJ_ValidateHandle(hRgn, GDI_OBJECT_TYPE_REGION))
       {
          hrgnCopy = IntSysCreateRectRgn(0, 0, 0, 0);
+
+         /* Set public ownership */
+         IntGdiSetRegionOwner(hrgnCopy, GDI_OBJ_HMGR_PUBLIC);
+
          NtGdiCombineRgn(hrgnCopy, hRgn, 0, RGN_COPY);
       }
       else
          RETURN( 0);
    }
    else
-      hrgnCopy = (HRGN) 1;
+   {
+      hrgnCopy = IntSysCreateRectRgnIndirect(&Window->rcWindow); //HRGN_WINDOW;
+   }
 
    if (Window->hrgnClip)
    {
       /* Delete no longer needed region handle */
       GreDeleteObject(Window->hrgnClip);
    }
+
    Window->hrgnClip = hrgnCopy;
 
-   /* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to 
the window */
-
-   if(bRedraw)
-   {
-      USER_REFERENCE_ENTRY Ref;
-      UserRefObjectCo(Window, &Ref);
-      co_UserRedrawWindow(Window, NULL, NULL, RDW_INVALIDATE);
-      UserDerefObjectCo(Window);
-   }
-
-   RETURN( (INT)hRgn);
+   Ret = co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, bRedraw ? flags : 
(flags|SWP_NOREDRAW) );
+
+   RETURN( (INT)Ret);
 
 CLEANUP:
    DPRINT("Leave NtUserSetWindowRgn, ret=%i\n",_ret_);

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c?rev=50933&r1=50932&r2=50933&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] Mon Feb 
28 06:31:44 2011
@@ -1120,7 +1120,7 @@
       Window->style |= WS_VISIBLE;
    }
 
-   if (Window->hrgnUpdate != NULL && Window->hrgnUpdate != (HRGN)1)
+   if (Window->hrgnUpdate != NULL && Window->hrgnUpdate != HRGN_WINDOW)
    {
       NtGdiOffsetRgn(Window->hrgnUpdate,
                      NewWindowRect.left - OldWindowRect.left,


Reply via email to