- Fixed multiwin.exe painting problem.
authorFilip Navara <filip.navara@gmail.com>
Fri, 21 Nov 2003 21:12:09 +0000 (21:12 +0000)
committerFilip Navara <filip.navara@gmail.com>
Fri, 21 Nov 2003 21:12:09 +0000 (21:12 +0000)
- Reverted my fix to cursoricon.c.

svn path=/trunk/; revision=6741

reactos/subsys/win32k/ntuser/painting.c
reactos/subsys/win32k/ntuser/vis.c
reactos/subsys/win32k/ntuser/window.c
reactos/subsys/win32k/objects/cursoricon.c

index ba23e94..cf9f640 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- *  $Id: painting.c,v 1.37 2003/11/21 17:01:16 navaraf Exp $
+ *  $Id: painting.c,v 1.38 2003/11/21 21:12:08 navaraf Exp $
  *
  *  COPYRIGHT:        See COPYING in the top level directory
  *  PROJECT:          ReactOS kernel
@@ -169,6 +169,10 @@ IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags)
 
 #ifndef DESKTOP_IN_CSRSS
          VIS_RepaintDesktop(hWnd, Window->UpdateRegion);
+         Window->Flags &= ~(WINDOWOBJECT_NEED_NCPAINT |
+            WINDOWOBJECT_NEED_INTERNALPAINT | WINDOWOBJECT_NEED_ERASEBKGND);
+         NtGdiDeleteObject(Window->UpdateRegion);
+         Window->UpdateRegion = NULL;
 #else
          if (Window->Flags & WINDOWOBJECT_NEED_NCPAINT)
          {
@@ -189,8 +193,8 @@ IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags)
             {
                NtUserSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0);
                NtUserReleaseDC(hWnd, hDC);
-               DeleteObject(WindowObject->UpdateRegion);
-               WindowObject->UpdateRegion = NULL;
+               NtGdiDeleteObject(Window->UpdateRegion);
+               Window->UpdateRegion = NULL;
             }
          }
 #endif
@@ -279,11 +283,13 @@ IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags)
  */
 
 VOID FASTCALL
-IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
+IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags,
+   BOOL ValidateParent)
 {
    INT RgnType;
    BOOL HadPaintMessage, HadNCPaintMessage;
    BOOL HasPaintMessage, HasNCPaintMessage;
+   HRGN hRgnWindow;
 
    /*
     * Clip the given region with window rectangle (or region)
@@ -293,7 +299,6 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
    if (!Window->WindowRegion)
 #endif
    {
-      HRGN hRgnWindow;
       hRgnWindow = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
       NtGdiOffsetRgn(hRgnWindow,
          -Window->WindowRect.left,
@@ -373,35 +378,13 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
    }
 
    /*
-    * Fake post paint messages to window message queue if needed
+    * Validate parent covered by region
     */
 
-#ifndef DESKTOP_IN_CSRSS
-   if (Window->MessageQueue)
-#endif
+   if (ValidateParent)
    {
-      HasPaintMessage = Window->UpdateRegion != NULL ||
-         Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
-      HasNCPaintMessage = Window->Flags & WINDOWOBJECT_NEED_NCPAINT;
-
-      if (HasPaintMessage != HadPaintMessage)
-      {
-         if (HadPaintMessage)
-            MsqDecPaintCountQueue(Window->MessageQueue);
-         else
-            MsqIncPaintCountQueue(Window->MessageQueue);
-      }
-
-      if (HasNCPaintMessage != HadNCPaintMessage)
-      {
-         if (HadNCPaintMessage)
-            MsqDecPaintCountQueue(Window->MessageQueue);
-         else
-            MsqIncPaintCountQueue(Window->MessageQueue);
-      }
-#ifndef DESKTOP_IN_CSRSS
+      IntValidateParent(Window);
    }
-#endif
 
    /*
     * Process children if needed
@@ -420,13 +403,34 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
             Child = IntGetWindowObject(*phWnd);
             if ((Child->Style & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE)
             {
+               /*
+                * Recursive call to update children UpdateRegion
+                */
                HRGN hRgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0);
-               Child = IntGetWindowObject(*phWnd);
                NtGdiCombineRgn(hRgnTemp, hRgn, 0, RGN_COPY);
                NtGdiOffsetRgn(hRgnTemp,
                   Window->WindowRect.left - Child->WindowRect.left,
                   Window->WindowRect.top - Child->WindowRect.top);
-               IntInvalidateWindows(Child, hRgnTemp, Flags);
+               IntInvalidateWindows(Child, hRgnTemp, Flags, FALSE);
+
+               /*
+                * Update our UpdateRegion depending on children
+                */
+               NtGdiCombineRgn(hRgnTemp, Child->UpdateRegion, 0, RGN_COPY);
+               NtGdiOffsetRgn(hRgnTemp,
+                  Child->WindowRect.left - Window->WindowRect.left,
+                  Child->WindowRect.top - Window->WindowRect.top);
+               hRgnWindow = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
+               NtGdiOffsetRgn(hRgnWindow,
+                  -Window->WindowRect.left,
+                  -Window->WindowRect.top);
+               NtGdiCombineRgn(hRgnTemp, hRgnTemp, hRgnWindow, RGN_AND);
+               if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
+                   hRgnTemp, RGN_DIFF) == NULLREGION)
+               {
+                  NtGdiDeleteObject(Window->UpdateRegion);
+                  Window->UpdateRegion = NULL;
+               }
                NtGdiDeleteObject(hRgnTemp);
             }
             IntReleaseWindowObject(Child);
@@ -434,6 +438,37 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
          ExFreePool(List);
       }
    }
+
+   /*
+    * Fake post paint messages to window message queue if needed
+    */
+
+#ifndef DESKTOP_IN_CSRSS
+   if (Window->MessageQueue)
+#endif
+   {
+      HasPaintMessage = Window->UpdateRegion != NULL ||
+         Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
+      HasNCPaintMessage = Window->Flags & WINDOWOBJECT_NEED_NCPAINT;
+
+      if (HasPaintMessage != HadPaintMessage)
+      {
+         if (HadPaintMessage)
+            MsqDecPaintCountQueue(Window->MessageQueue);
+         else
+            MsqIncPaintCountQueue(Window->MessageQueue);
+      }
+
+      if (HasNCPaintMessage != HadNCPaintMessage)
+      {
+         if (HadNCPaintMessage)
+            MsqDecPaintCountQueue(Window->MessageQueue);
+         else
+            MsqIncPaintCountQueue(Window->MessageQueue);
+      }
+#ifndef DESKTOP_IN_CSRSS
+   }
+#endif
 }
 
 /*
@@ -528,15 +563,11 @@ IntRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRgn,
 
    if (Flags & (RDW_INVALIDATE | RDW_VALIDATE | RDW_INTERNALPAINT | RDW_NOINTERNALPAINT))
    {
-      IntInvalidateWindows(Window, hRgn, Flags);
-   }
-
-   /*
-    * Validate parent covered by region.
-    */
-
-   if (Window->UpdateRegion != NULL && Flags & (RDW_ERASENOW | RDW_VALIDATE))
+      IntInvalidateWindows(Window, hRgn, Flags, TRUE);
+   } else
+   if (Window->UpdateRegion != NULL && Flags & RDW_ERASENOW)
    {
+      /* Validate parent covered by region. */
       IntValidateParent(Window);
    }
 
index 9b7a686..ea4d9d1 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: vis.c,v 1.11 2003/11/21 17:01:16 navaraf Exp $
+ * $Id: vis.c,v 1.12 2003/11/21 21:12:08 navaraf Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -215,9 +215,12 @@ VOID FASTCALL
 VIS_RepaintDesktop(HWND Desktop, HRGN RepaintRgn)
 {
   HDC dc = NtUserGetDC(Desktop);
-  HBRUSH DesktopBrush = NtGdiCreateSolidBrush(RGB(58, 110, 165));
-  NtGdiFillRgn(dc, RepaintRgn, DesktopBrush);
-  NtGdiDeleteObject(DesktopBrush);
+  if (dc)
+    {
+      HBRUSH DesktopBrush = NtGdiCreateSolidBrush(RGB(58, 110, 165));
+      NtGdiFillRgn(dc, RepaintRgn, DesktopBrush);
+      NtGdiDeleteObject(DesktopBrush);
+    }
   NtUserReleaseDC(Desktop, dc);
 }
 
index a7c0715..6953b33 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: window.c,v 1.141 2003/11/21 17:01:16 navaraf Exp $
+/* $Id: window.c,v 1.142 2003/11/21 21:12:08 navaraf Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -666,6 +666,8 @@ IntInitDesktopWindow(ULONG Width, ULONG Height)
     {
       return;
     }
+  DesktopWindow->WindowRect.left = 0;
+  DesktopWindow->WindowRect.top = 0;
   DesktopWindow->WindowRect.right = Width;
   DesktopWindow->WindowRect.bottom = Height;
   DesktopWindow->ClientRect = DesktopWindow->WindowRect;
index 4dff241..ce5bfe1 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: cursoricon.c,v 1.22 2003/11/21 16:36:26 weiden Exp $ */
+/* $Id: cursoricon.c,v 1.23 2003/11/21 21:12:09 navaraf Exp $ */
 
 #undef WIN32_LEAN_AND_MEAN
 
@@ -82,7 +82,6 @@ IntSendSetCursorMessage(PWINDOW_OBJECT Window, USHORT Msg, USHORT HitTest)
 HCURSOR FASTCALL
 IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL ForceChange)
 {
-  HDC hDC;
   PDC dc;
   PSURFOBJ SurfObj;
   PSURFGDI SurfGDI;
@@ -106,13 +105,11 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL Fo
     goto done;
   
   /* FIXME use the desktop's HDC instead of using ScreenDeviceContext */
-  hDC = NtUserGetDC(0);
-  dc = DC_LockDc(hDC);
+  dc = DC_LockDc(ScreenDeviceContext);
   SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
   SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
   DevInfo = dc->DevInfo;
-  DC_UnlockDc(hDC);
-  NtUserReleaseDC(0, hDC);
+  DC_UnlockDc(ScreenDeviceContext);
   
   if(!NewCursor && (CurInfo->CurrentCursorObject || ForceChange))
   {