2003-05-18 17:16:18 +00:00
|
|
|
/*
|
|
|
|
* ReactOS W32 Subsystem
|
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2002-07-04 20:12:28 +00:00
|
|
|
*
|
2005-01-06 13:58:04 +00:00
|
|
|
* $Id$
|
2003-11-18 20:49:39 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: Window painting function
|
|
|
|
* FILE: subsys/win32k/ntuser/painting.c
|
|
|
|
* PROGRAMER: Filip Navara (xnavara@volny.cz)
|
|
|
|
* REVISION HISTORY:
|
|
|
|
* 06/06/2001 Created (?)
|
|
|
|
* 18/11/2003 Complete rewrite
|
2002-07-04 20:12:28 +00:00
|
|
|
*/
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2002-07-04 20:12:28 +00:00
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2004-05-10 17:07:20 +00:00
|
|
|
#include <w32k.h>
|
2002-07-04 20:12:28 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
2005-06-29 07:09:25 +00:00
|
|
|
#include <debug.h>
|
2002-07-04 20:12:28 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
/* PRIVATE FUNCTIONS **********************************************************/
|
2003-05-26 18:52:37 +00:00
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
/**
|
|
|
|
* @name IntIntersectWithParents
|
|
|
|
*
|
|
|
|
* Intersect window rectangle with all parent client rectangles.
|
|
|
|
*
|
|
|
|
* @param Child
|
|
|
|
* Pointer to child window to start intersecting from.
|
|
|
|
* @param WindowRect
|
|
|
|
* Pointer to rectangle that we want to intersect in screen
|
|
|
|
* coordinates on input and intersected rectangle on output (if TRUE
|
|
|
|
* is returned).
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* If any parent is minimized or invisible or the resulting rectangle
|
|
|
|
* is empty then FALSE is returned. Otherwise TRUE is returned.
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL FASTCALL
|
|
|
|
IntIntersectWithParents(PWINDOW_OBJECT Child, PRECT WindowRect)
|
|
|
|
{
|
|
|
|
PWINDOW_OBJECT ParentWindow;
|
|
|
|
|
|
|
|
ParentWindow = Child->Parent;
|
|
|
|
while (ParentWindow != NULL)
|
|
|
|
{
|
|
|
|
if (!(ParentWindow->Style & WS_VISIBLE) ||
|
|
|
|
(ParentWindow->Style & WS_MINIMIZE))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IntGdiIntersectRect(WindowRect, WindowRect, &ParentWindow->ClientRect))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: Layered windows. */
|
|
|
|
|
|
|
|
ParentWindow = ParentWindow->Parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-11-21 17:01:16 +00:00
|
|
|
VOID FASTCALL
|
2003-12-28 10:56:20 +00:00
|
|
|
IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion)
|
2003-11-21 17:01:16 +00:00
|
|
|
{
|
2005-09-06 14:09:22 +00:00
|
|
|
PWINDOW_OBJECT ParentWindow = Child->Parent;
|
2003-11-21 17:01:16 +00:00
|
|
|
|
2004-02-24 01:30:58 +00:00
|
|
|
while (ParentWindow)
|
2003-11-21 17:01:16 +00:00
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
if (ParentWindow->Style & WS_CLIPCHILDREN)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (ParentWindow->UpdateRegion != 0)
|
|
|
|
{
|
|
|
|
NtGdiCombineRgn(ParentWindow->UpdateRegion, ParentWindow->UpdateRegion,
|
|
|
|
ValidRegion, RGN_DIFF);
|
|
|
|
/* FIXME: If the resulting region is empty, remove fake posted paint message */
|
|
|
|
}
|
|
|
|
|
|
|
|
ParentWindow = ParentWindow->Parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name IntCalcWindowRgn
|
|
|
|
*
|
|
|
|
* Get a window or client region.
|
|
|
|
*/
|
|
|
|
|
|
|
|
HRGN FASTCALL
|
|
|
|
IntCalcWindowRgn(PWINDOW_OBJECT Window, BOOL Client)
|
|
|
|
{
|
|
|
|
HRGN hRgnWindow;
|
|
|
|
UINT RgnType;
|
|
|
|
|
|
|
|
if (Client)
|
|
|
|
hRgnWindow = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
|
|
|
|
else
|
|
|
|
hRgnWindow = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
|
|
|
|
|
|
|
|
if (Window->WindowRegion != NULL && !(Window->Style & WS_MINIMIZE))
|
|
|
|
{
|
|
|
|
NtGdiOffsetRgn(hRgnWindow,
|
|
|
|
-Window->WindowRect.left,
|
|
|
|
-Window->WindowRect.top);
|
|
|
|
RgnType = NtGdiCombineRgn(hRgnWindow, hRgnWindow, Window->WindowRegion, RGN_AND);
|
|
|
|
NtGdiOffsetRgn(hRgnWindow,
|
|
|
|
Window->WindowRect.left,
|
|
|
|
Window->WindowRect.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hRgnWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name IntGetNCUpdateRgn
|
|
|
|
*
|
|
|
|
* Get non-client update region of a window and optionally validate it.
|
|
|
|
*
|
|
|
|
* @param Window
|
|
|
|
* Pointer to window to get the NC update region from.
|
|
|
|
* @param Validate
|
|
|
|
* Set to TRUE to force validating the NC update region.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* Handle to NC update region. The caller is responsible for deleting
|
|
|
|
* it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
HRGN FASTCALL
|
|
|
|
IntGetNCUpdateRgn(PWINDOW_OBJECT Window, BOOL Validate)
|
|
|
|
{
|
|
|
|
HRGN hRgnNonClient;
|
|
|
|
HRGN hRgnWindow;
|
|
|
|
UINT RgnType;
|
|
|
|
|
|
|
|
if (Window->UpdateRegion != NULL &&
|
|
|
|
Window->UpdateRegion != (HRGN)1)
|
|
|
|
{
|
|
|
|
hRgnNonClient = NtGdiCreateRectRgn(0, 0, 0, 0);
|
|
|
|
hRgnWindow = IntCalcWindowRgn(Window, TRUE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If region creation fails it's safe to fallback to whole
|
|
|
|
* window region.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (hRgnNonClient == NULL)
|
|
|
|
{
|
|
|
|
return (HRGN)1;
|
|
|
|
}
|
|
|
|
|
|
|
|
RgnType = NtGdiCombineRgn(hRgnNonClient, Window->UpdateRegion,
|
|
|
|
hRgnWindow, RGN_DIFF);
|
|
|
|
if (RgnType == ERROR)
|
2003-11-21 17:01:16 +00:00
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
NtGdiDeleteObject(hRgnNonClient);
|
|
|
|
return (HRGN)1;
|
|
|
|
}
|
|
|
|
else if (RgnType == NULLREGION)
|
|
|
|
{
|
|
|
|
NtGdiDeleteObject(hRgnNonClient);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove the nonclient region from the standard update region if
|
|
|
|
* we were asked for it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (Validate)
|
|
|
|
{
|
|
|
|
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
|
|
|
|
hRgnWindow, RGN_AND) == NULLREGION)
|
2003-11-21 17:01:16 +00:00
|
|
|
{
|
2006-04-01 15:25:40 +00:00
|
|
|
GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
|
2005-09-19 10:39:26 +00:00
|
|
|
NtGdiDeleteObject(Window->UpdateRegion);
|
|
|
|
Window->UpdateRegion = NULL;
|
|
|
|
if (!(Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT))
|
|
|
|
MsqDecPaintCountQueue(Window->MessageQueue);
|
2003-11-21 17:01:16 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-06 14:09:22 +00:00
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
NtGdiDeleteObject(hRgnWindow);
|
|
|
|
|
|
|
|
return hRgnNonClient;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Window->UpdateRegion;
|
2003-11-21 17:01:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
/*
|
|
|
|
* IntPaintWindows
|
|
|
|
*
|
|
|
|
* Internal function used by IntRedrawWindow.
|
|
|
|
*/
|
|
|
|
|
2006-01-08 23:26:03 +00:00
|
|
|
static VOID FASTCALL
|
2005-09-05 21:19:23 +00:00
|
|
|
co_IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags)
|
2002-08-26 23:20:54 +00:00
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
HDC hDC;
|
|
|
|
HWND hWnd = Window->hSelf;
|
|
|
|
HRGN TempRegion;
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
if (Flags & (RDW_ERASENOW | RDW_UPDATENOW))
|
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
if (Window->UpdateRegion)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
IntValidateParent(Window, Window->UpdateRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Flags & RDW_UPDATENOW)
|
|
|
|
{
|
|
|
|
if (Window->UpdateRegion != NULL ||
|
|
|
|
Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
co_IntSendMessage(hWnd, WM_PAINT, 0, 0);
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
2005-09-19 10:39:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Window->Flags & WINDOWOBJECT_NEED_NCPAINT)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
TempRegion = IntGetNCUpdateRgn(Window, TRUE);
|
|
|
|
Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
|
|
|
|
MsqDecPaintCountQueue(Window->MessageQueue);
|
|
|
|
co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0);
|
|
|
|
if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
|
|
|
|
{
|
|
|
|
/* NOTE: The region can already be deleted! */
|
2006-04-01 15:25:40 +00:00
|
|
|
GDIOBJ_FreeObj(GdiHandleTable, TempRegion, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
|
2005-09-19 10:39:26 +00:00
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
2003-12-07 23:02:57 +00:00
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
if (Window->Flags & WINDOWOBJECT_NEED_ERASEBKGND)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
if (Window->UpdateRegion)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2005-09-19 12:21:52 +00:00
|
|
|
hDC = UserGetDCEx(Window, Window->UpdateRegion,
|
|
|
|
DCX_CACHE | DCX_USESTYLE |
|
|
|
|
DCX_INTERSECTRGN | DCX_KEEPCLIPRGN);
|
2005-09-07 21:25:42 +00:00
|
|
|
if (co_IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0))
|
|
|
|
{
|
|
|
|
Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND;
|
|
|
|
}
|
2005-09-19 12:21:52 +00:00
|
|
|
UserReleaseDC(Window, hDC, FALSE);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
/*
|
|
|
|
* Check that the window is still valid at this point
|
|
|
|
*/
|
2005-09-19 10:39:26 +00:00
|
|
|
if (!IntIsWindow(hWnd))
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2003-11-18 20:49:39 +00:00
|
|
|
return;
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Paint child windows.
|
|
|
|
*/
|
|
|
|
if (!(Flags & RDW_NOCHILDREN) && !(Window->Style & WS_MINIMIZE) &&
|
2005-09-19 10:39:26 +00:00
|
|
|
((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2003-11-18 20:49:39 +00:00
|
|
|
HWND *List, *phWnd;
|
|
|
|
|
|
|
|
if ((List = IntWinListChildren(Window)))
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
|
|
|
for (phWnd = List; *phWnd; ++phWnd)
|
|
|
|
{
|
2005-09-24 02:50:02 +00:00
|
|
|
Window = UserGetWindowObject(*phWnd);
|
2005-09-07 21:25:42 +00:00
|
|
|
if (Window && (Window->Style & WS_VISIBLE))
|
2003-11-19 09:10:36 +00:00
|
|
|
{
|
2005-10-15 13:22:13 +00:00
|
|
|
USER_REFERENCE_ENTRY Ref;
|
|
|
|
UserRefObjectCo(Window, &Ref);
|
2005-09-07 21:25:42 +00:00
|
|
|
co_IntPaintWindows(Window, Flags);
|
2005-09-24 02:50:02 +00:00
|
|
|
UserDerefObjectCo(Window);
|
2003-11-19 09:10:36 +00:00
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
|
|
|
ExFreePool(List);
|
|
|
|
}
|
|
|
|
}
|
2002-08-26 23:20:54 +00:00
|
|
|
}
|
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
/*
|
|
|
|
* IntInvalidateWindows
|
|
|
|
*
|
|
|
|
* Internal function used by IntRedrawWindow.
|
|
|
|
*/
|
|
|
|
|
|
|
|
VOID FASTCALL
|
2004-01-18 08:29:31 +00:00
|
|
|
IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
|
2002-07-04 20:12:28 +00:00
|
|
|
{
|
2003-11-18 20:49:39 +00:00
|
|
|
INT RgnType;
|
2003-11-21 17:01:16 +00:00
|
|
|
BOOL HadPaintMessage, HadNCPaintMessage;
|
|
|
|
BOOL HasPaintMessage, HasNCPaintMessage;
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-12-04 22:31:43 +00:00
|
|
|
/*
|
|
|
|
* If the nonclient is not to be redrawn, clip the region to the client
|
|
|
|
* rect
|
|
|
|
*/
|
|
|
|
if (0 != (Flags & RDW_INVALIDATE) && 0 == (Flags & RDW_FRAME))
|
|
|
|
{
|
|
|
|
HRGN hRgnClient;
|
|
|
|
|
|
|
|
hRgnClient = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
|
|
|
|
RgnType = NtGdiCombineRgn(hRgn, hRgn, hRgnClient, RGN_AND);
|
|
|
|
NtGdiDeleteObject(hRgnClient);
|
|
|
|
}
|
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
/*
|
|
|
|
* Clip the given region with window rectangle (or region)
|
|
|
|
*/
|
|
|
|
|
2004-03-23 18:08:07 +00:00
|
|
|
if (!Window->WindowRegion || (Window->Style & WS_MINIMIZE))
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2004-02-21 13:13:27 +00:00
|
|
|
HRGN hRgnWindow;
|
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
hRgnWindow = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
|
2004-02-21 13:13:27 +00:00
|
|
|
RgnType = NtGdiCombineRgn(hRgn, hRgn, hRgnWindow, RGN_AND);
|
2003-11-21 17:01:16 +00:00
|
|
|
NtGdiDeleteObject(hRgnWindow);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
NtGdiOffsetRgn(hRgn,
|
|
|
|
-Window->WindowRect.left,
|
|
|
|
-Window->WindowRect.top);
|
2004-03-22 20:14:29 +00:00
|
|
|
RgnType = NtGdiCombineRgn(hRgn, hRgn, Window->WindowRegion, RGN_AND);
|
2005-09-19 10:39:26 +00:00
|
|
|
NtGdiOffsetRgn(hRgn,
|
|
|
|
Window->WindowRect.left,
|
|
|
|
Window->WindowRect.top);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2003-11-21 17:01:16 +00:00
|
|
|
* Save current state of pending updates
|
2003-11-18 20:49:39 +00:00
|
|
|
*/
|
|
|
|
|
2003-11-21 17:01:16 +00:00
|
|
|
HadPaintMessage = Window->UpdateRegion != NULL ||
|
2005-09-07 21:25:42 +00:00
|
|
|
Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
|
2003-11-21 17:01:16 +00:00
|
|
|
HadNCPaintMessage = Window->Flags & WINDOWOBJECT_NEED_NCPAINT;
|
2003-11-18 20:49:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the region and flags
|
|
|
|
*/
|
|
|
|
|
2003-11-21 17:01:16 +00:00
|
|
|
if (Flags & RDW_INVALIDATE && RgnType != NULLREGION)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
|
|
|
if (Window->UpdateRegion == NULL)
|
|
|
|
{
|
|
|
|
Window->UpdateRegion = NtGdiCreateRectRgn(0, 0, 0, 0);
|
2006-04-01 15:25:40 +00:00
|
|
|
GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, NULL);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
|
2005-09-07 21:25:42 +00:00
|
|
|
hRgn, RGN_OR) == NULLREGION)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2006-04-01 15:25:40 +00:00
|
|
|
GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
|
2003-11-18 20:49:39 +00:00
|
|
|
NtGdiDeleteObject(Window->UpdateRegion);
|
|
|
|
Window->UpdateRegion = NULL;
|
|
|
|
}
|
2002-08-26 23:20:54 +00:00
|
|
|
|
|
|
|
if (Flags & RDW_FRAME)
|
2003-11-18 20:49:39 +00:00
|
|
|
Window->Flags |= WINDOWOBJECT_NEED_NCPAINT;
|
2002-08-26 23:20:54 +00:00
|
|
|
if (Flags & RDW_ERASE)
|
2003-11-18 20:49:39 +00:00
|
|
|
Window->Flags |= WINDOWOBJECT_NEED_ERASEBKGND;
|
|
|
|
|
2002-08-26 23:20:54 +00:00
|
|
|
Flags |= RDW_FRAME;
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
|
2003-11-21 17:01:16 +00:00
|
|
|
if (Flags & RDW_VALIDATE && RgnType != NULLREGION)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
|
|
|
if (Window->UpdateRegion != NULL)
|
|
|
|
{
|
|
|
|
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
|
2005-09-07 21:25:42 +00:00
|
|
|
hRgn, RGN_DIFF) == NULLREGION)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2006-04-01 15:25:40 +00:00
|
|
|
GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
|
2003-11-18 20:49:39 +00:00
|
|
|
NtGdiDeleteObject(Window->UpdateRegion);
|
|
|
|
Window->UpdateRegion = NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-08-26 23:20:54 +00:00
|
|
|
|
2003-11-21 17:01:16 +00:00
|
|
|
if (Window->UpdateRegion == NULL)
|
|
|
|
Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND;
|
2002-08-26 23:20:54 +00:00
|
|
|
if (Flags & RDW_NOFRAME)
|
2003-11-18 20:49:39 +00:00
|
|
|
Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
|
2002-08-26 23:20:54 +00:00
|
|
|
if (Flags & RDW_NOERASE)
|
2003-11-18 20:49:39 +00:00
|
|
|
Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Flags & RDW_INTERNALPAINT)
|
|
|
|
{
|
|
|
|
Window->Flags |= WINDOWOBJECT_NEED_INTERNALPAINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Flags & RDW_NOINTERNALPAINT)
|
|
|
|
{
|
|
|
|
Window->Flags &= ~WINDOWOBJECT_NEED_INTERNALPAINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process children if needed
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!(Flags & RDW_NOCHILDREN) && !(Window->Style & WS_MINIMIZE) &&
|
2005-09-07 21:25:42 +00:00
|
|
|
((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
|
|
|
PWINDOW_OBJECT Child;
|
|
|
|
|
2005-09-24 02:50:02 +00:00
|
|
|
for (Child = Window->FirstChild; Child; Child = Child->NextSibling)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2005-09-24 02:50:02 +00:00
|
|
|
if (Child->Style & WS_VISIBLE)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2005-09-24 02:50:02 +00:00
|
|
|
/*
|
|
|
|
* Recursive call to update children UpdateRegion
|
|
|
|
*/
|
|
|
|
HRGN hRgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0);
|
|
|
|
NtGdiCombineRgn(hRgnTemp, hRgn, 0, RGN_COPY);
|
|
|
|
IntInvalidateWindows(Child, hRgnTemp, Flags);
|
|
|
|
NtGdiDeleteObject(hRgnTemp);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
2005-09-24 02:50:02 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-21 21:12:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fake post paint messages to window message queue if needed
|
|
|
|
*/
|
2004-02-21 13:13:27 +00:00
|
|
|
|
2003-12-07 23:02:57 +00:00
|
|
|
HasPaintMessage = Window->UpdateRegion != NULL ||
|
2005-09-07 21:25:42 +00:00
|
|
|
Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
|
2003-12-07 23:02:57 +00:00
|
|
|
HasNCPaintMessage = Window->Flags & WINDOWOBJECT_NEED_NCPAINT;
|
2003-11-21 21:12:09 +00:00
|
|
|
|
2003-12-07 23:02:57 +00:00
|
|
|
if (HasPaintMessage != HadPaintMessage)
|
|
|
|
{
|
|
|
|
if (HadPaintMessage)
|
|
|
|
MsqDecPaintCountQueue(Window->MessageQueue);
|
|
|
|
else
|
|
|
|
MsqIncPaintCountQueue(Window->MessageQueue);
|
|
|
|
}
|
2003-11-21 21:12:09 +00:00
|
|
|
|
2003-12-07 23:02:57 +00:00
|
|
|
if (HasNCPaintMessage != HadNCPaintMessage)
|
|
|
|
{
|
|
|
|
if (HadNCPaintMessage)
|
|
|
|
MsqDecPaintCountQueue(Window->MessageQueue);
|
|
|
|
else
|
|
|
|
MsqIncPaintCountQueue(Window->MessageQueue);
|
2003-11-21 21:12:09 +00:00
|
|
|
}
|
2004-02-04 23:01:07 +00:00
|
|
|
|
2002-07-04 20:12:28 +00:00
|
|
|
}
|
|
|
|
|
2003-11-21 17:01:16 +00:00
|
|
|
/*
|
|
|
|
* IntIsWindowDrawable
|
|
|
|
*
|
|
|
|
* Remarks
|
2003-12-30 16:55:00 +00:00
|
|
|
* Window is drawable when it is visible and all parents are not
|
|
|
|
* minimized.
|
2003-11-21 17:01:16 +00:00
|
|
|
*/
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2003-11-21 17:01:16 +00:00
|
|
|
BOOL FASTCALL
|
|
|
|
IntIsWindowDrawable(PWINDOW_OBJECT Window)
|
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
PWINDOW_OBJECT Wnd;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
for (Wnd = Window; Wnd != NULL; Wnd = Wnd->Parent)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2003-12-30 16:55:00 +00:00
|
|
|
if (!(Wnd->Style & WS_VISIBLE) ||
|
2005-09-07 21:25:42 +00:00
|
|
|
((Wnd->Style & WS_MINIMIZE) && (Wnd != Window)))
|
2004-02-24 01:30:58 +00:00
|
|
|
{
|
2003-11-21 17:01:16 +00:00
|
|
|
return FALSE;
|
2004-02-24 01:30:58 +00:00
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
2003-11-21 17:01:16 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
2002-07-04 20:12:28 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
/*
|
|
|
|
* IntRedrawWindow
|
|
|
|
*
|
|
|
|
* Internal version of NtUserRedrawWindow that takes WINDOW_OBJECT as
|
|
|
|
* first parameter.
|
|
|
|
*/
|
2003-05-26 18:52:37 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
BOOL FASTCALL
|
2005-09-05 21:19:23 +00:00
|
|
|
co_UserRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRgn,
|
2005-09-07 21:25:42 +00:00
|
|
|
ULONG Flags)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
|
|
|
HRGN hRgn = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Step 1.
|
|
|
|
* Validation of passed parameters.
|
|
|
|
*/
|
|
|
|
|
2003-11-21 17:01:16 +00:00
|
|
|
if (!IntIsWindowDrawable(Window) ||
|
2005-09-07 21:25:42 +00:00
|
|
|
(Flags & (RDW_VALIDATE | RDW_INVALIDATE)) ==
|
|
|
|
(RDW_VALIDATE | RDW_INVALIDATE))
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Step 2.
|
|
|
|
* Transform the parameters UpdateRgn and UpdateRect into
|
2005-09-19 10:39:26 +00:00
|
|
|
* a region hRgn specified in screen coordinates.
|
2003-11-18 20:49:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (Flags & (RDW_INVALIDATE | RDW_VALIDATE))
|
|
|
|
{
|
|
|
|
if (UpdateRgn != NULL)
|
|
|
|
{
|
|
|
|
hRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
|
2005-09-19 10:39:26 +00:00
|
|
|
if (NtGdiCombineRgn(hRgn, UpdateRgn, NULL, RGN_COPY) == NULLREGION)
|
|
|
|
NtGdiDeleteObject(hRgn);
|
|
|
|
else
|
|
|
|
NtGdiOffsetRgn(hRgn, Window->ClientRect.left, Window->ClientRect.top);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
2005-09-19 10:39:26 +00:00
|
|
|
else if (UpdateRect != NULL)
|
|
|
|
{
|
|
|
|
if (!IntGdiIsEmptyRect(UpdateRect))
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
|
|
|
hRgn = UnsafeIntCreateRectRgnIndirect((RECT *)UpdateRect);
|
2005-09-19 10:39:26 +00:00
|
|
|
NtGdiOffsetRgn(hRgn, Window->ClientRect.left, Window->ClientRect.top);
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
2005-09-19 10:39:26 +00:00
|
|
|
}
|
|
|
|
else if ((Flags & (RDW_INVALIDATE | RDW_FRAME)) == (RDW_INVALIDATE | RDW_FRAME) ||
|
|
|
|
(Flags & (RDW_VALIDATE | RDW_NOFRAME)) == (RDW_VALIDATE | RDW_NOFRAME))
|
|
|
|
{
|
|
|
|
if (!IntGdiIsEmptyRect(&Window->WindowRect))
|
|
|
|
hRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!IntGdiIsEmptyRect(&Window->ClientRect))
|
|
|
|
hRgn = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
|
|
|
|
}
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
2002-07-04 20:12:28 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
/*
|
|
|
|
* Step 3.
|
|
|
|
* Adjust the window update region depending on hRgn and flags.
|
|
|
|
*/
|
2003-05-26 18:52:37 +00:00
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
if (Flags & (RDW_INVALIDATE | RDW_VALIDATE | RDW_INTERNALPAINT | RDW_NOINTERNALPAINT) &&
|
|
|
|
hRgn != NULL)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2004-01-18 08:29:31 +00:00
|
|
|
IntInvalidateWindows(Window, hRgn, Flags);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
2002-07-04 20:12:28 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
/*
|
|
|
|
* Step 4.
|
|
|
|
* Repaint and erase windows if needed.
|
|
|
|
*/
|
|
|
|
|
2004-02-21 13:51:13 +00:00
|
|
|
if (Flags & (RDW_ERASENOW | RDW_UPDATENOW))
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2005-09-05 21:19:23 +00:00
|
|
|
co_IntPaintWindows(Window, Flags);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Step 5.
|
|
|
|
* Cleanup ;-)
|
|
|
|
*/
|
|
|
|
|
2004-02-01 08:07:07 +00:00
|
|
|
if (hRgn != NULL)
|
2003-11-25 23:46:23 +00:00
|
|
|
{
|
|
|
|
NtGdiDeleteObject(hRgn);
|
|
|
|
}
|
2003-11-18 20:49:39 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2002-07-04 20:12:28 +00:00
|
|
|
}
|
|
|
|
|
2004-02-21 13:13:27 +00:00
|
|
|
BOOL FASTCALL
|
|
|
|
IntIsWindowDirty(PWINDOW_OBJECT Window)
|
|
|
|
{
|
|
|
|
return (Window->Style & WS_VISIBLE) &&
|
2005-09-07 21:25:42 +00:00
|
|
|
((Window->UpdateRegion != NULL) ||
|
|
|
|
(Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT) ||
|
|
|
|
(Window->Flags & WINDOWOBJECT_NEED_NCPAINT));
|
2004-02-21 13:13:27 +00:00
|
|
|
}
|
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
HWND FASTCALL
|
|
|
|
IntFindWindowToRepaint(PWINDOW_OBJECT Window, PW32THREAD Thread)
|
2002-07-04 20:12:28 +00:00
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
HWND hChild;
|
2005-09-21 13:49:09 +00:00
|
|
|
PWINDOW_OBJECT TempWindow;
|
2002-07-04 20:12:28 +00:00
|
|
|
|
2005-09-21 13:49:09 +00:00
|
|
|
for (; Window != NULL; Window = Window->NextSibling)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2005-09-21 13:49:09 +00:00
|
|
|
if (IntWndBelongsToThread(Window, Thread) &&
|
|
|
|
IntIsWindowDirty(Window))
|
2003-08-11 19:14:16 +00:00
|
|
|
{
|
2005-09-21 13:49:09 +00:00
|
|
|
/* Make sure all non-transparent siblings are already drawn. */
|
|
|
|
if (Window->ExStyle & WS_EX_TRANSPARENT)
|
|
|
|
{
|
|
|
|
for (TempWindow = Window->NextSibling; TempWindow != NULL;
|
|
|
|
TempWindow = TempWindow->NextSibling)
|
|
|
|
{
|
|
|
|
if (!(TempWindow->ExStyle & WS_EX_TRANSPARENT) &&
|
|
|
|
IntWndBelongsToThread(TempWindow, Thread) &&
|
|
|
|
IntIsWindowDirty(TempWindow))
|
|
|
|
{
|
|
|
|
return TempWindow->hSelf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
return Window->hSelf;
|
2003-08-11 19:14:16 +00:00
|
|
|
}
|
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
if (Window->FirstChild)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
hChild = IntFindWindowToRepaint(Window->FirstChild, Thread);
|
|
|
|
if (hChild != NULL)
|
|
|
|
return hChild;
|
2005-09-21 14:01:49 +00:00
|
|
|
}
|
2004-01-17 15:18:25 +00:00
|
|
|
}
|
2003-05-26 18:52:37 +00:00
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
return NULL;
|
2002-07-04 20:12:28 +00:00
|
|
|
}
|
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
BOOL FASTCALL
|
2004-04-29 21:13:16 +00:00
|
|
|
IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax,
|
|
|
|
PW32THREAD Thread, MSG *Message, BOOL Remove)
|
2003-09-09 09:39:21 +00:00
|
|
|
{
|
2003-11-21 17:01:16 +00:00
|
|
|
PUSER_MESSAGE_QUEUE MessageQueue = (PUSER_MESSAGE_QUEUE)Thread->MessageQueue;
|
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
if (!MessageQueue->PaintCount)
|
2003-11-21 17:01:16 +00:00
|
|
|
return FALSE;
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-03-21 00:55:16 +00:00
|
|
|
if ((MsgFilterMin != 0 || MsgFilterMax != 0) &&
|
2005-09-07 21:25:42 +00:00
|
|
|
(MsgFilterMin > WM_PAINT || MsgFilterMax < WM_PAINT))
|
2005-03-21 00:55:16 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2006-07-20 14:53:47 +00:00
|
|
|
Message->hwnd = IntFindWindowToRepaint(UserGetDesktopWindow(), PsGetCurrentThreadWin32Thread());
|
2003-11-18 20:49:39 +00:00
|
|
|
|
|
|
|
if (Message->hwnd == NULL)
|
2003-11-20 21:21:29 +00:00
|
|
|
{
|
2005-09-19 10:39:26 +00:00
|
|
|
DPRINT1("PAINTING BUG: Thread marked as containing dirty windows, but no dirty windows found!\n");
|
2003-11-18 20:49:39 +00:00
|
|
|
return FALSE;
|
2003-11-20 21:21:29 +00:00
|
|
|
}
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
if (hWnd != NULL && Message->hwnd != hWnd)
|
2005-09-11 14:48:32 +00:00
|
|
|
return FALSE;
|
2005-03-21 00:55:16 +00:00
|
|
|
|
2005-09-11 14:48:32 +00:00
|
|
|
Message->message = WM_PAINT;
|
|
|
|
Message->wParam = Message->lParam = 0;
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-09-11 14:48:32 +00:00
|
|
|
return TRUE;
|
2003-09-09 09:39:21 +00:00
|
|
|
}
|
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
static
|
2003-12-08 18:21:25 +00:00
|
|
|
HWND FASTCALL
|
2005-09-07 20:59:26 +00:00
|
|
|
co_IntFixCaret(PWINDOW_OBJECT Window, LPRECT lprc, UINT flags)
|
2003-12-08 18:21:25 +00:00
|
|
|
{
|
2004-02-03 17:53:55 +00:00
|
|
|
PDESKTOP_OBJECT Desktop;
|
|
|
|
PTHRDCARETINFO CaretInfo;
|
|
|
|
HWND hWndCaret;
|
2005-09-07 20:59:26 +00:00
|
|
|
PWINDOW_OBJECT WndCaret;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
ASSERT_REFS_CO(Window);
|
2004-02-03 17:53:55 +00:00
|
|
|
|
2005-11-08 08:56:41 +00:00
|
|
|
Desktop = ((PW32THREAD)PsGetCurrentThread()->Tcb.Win32Thread)->Desktop;
|
2004-02-03 17:53:55 +00:00
|
|
|
CaretInfo = ((PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue)->CaretInfo;
|
|
|
|
hWndCaret = CaretInfo->hWnd;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
WndCaret = UserGetWindowObject(hWndCaret);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-11 14:48:32 +00:00
|
|
|
//fix: check for WndCaret can be null
|
2005-09-07 20:59:26 +00:00
|
|
|
if (WndCaret == Window ||
|
2005-09-11 14:48:32 +00:00
|
|
|
((flags & SW_SCROLLCHILDREN) && IntIsChildWindow(Window, WndCaret)))
|
2003-12-08 18:21:25 +00:00
|
|
|
{
|
|
|
|
POINT pt, FromOffset, ToOffset, Offset;
|
2004-02-03 17:53:55 +00:00
|
|
|
RECT rcCaret;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2004-02-03 17:53:55 +00:00
|
|
|
pt.x = CaretInfo->Pos.x;
|
|
|
|
pt.y = CaretInfo->Pos.y;
|
2005-09-07 20:59:26 +00:00
|
|
|
IntGetClientOrigin(WndCaret, &FromOffset);
|
|
|
|
IntGetClientOrigin(Window, &ToOffset);
|
2003-12-08 18:21:25 +00:00
|
|
|
Offset.x = FromOffset.x - ToOffset.x;
|
|
|
|
Offset.y = FromOffset.y - ToOffset.y;
|
2004-02-03 17:53:55 +00:00
|
|
|
rcCaret.left = pt.x;
|
|
|
|
rcCaret.top = pt.y;
|
|
|
|
rcCaret.right = pt.x + CaretInfo->Size.cx;
|
|
|
|
rcCaret.bottom = pt.y + CaretInfo->Size.cy;
|
2004-11-15 23:10:42 +00:00
|
|
|
if (IntGdiIntersectRect(lprc, lprc, &rcCaret))
|
2003-12-08 18:21:25 +00:00
|
|
|
{
|
2005-09-05 21:19:23 +00:00
|
|
|
co_UserHideCaret(0);
|
2003-12-08 18:21:25 +00:00
|
|
|
lprc->left = pt.x;
|
|
|
|
lprc->top = pt.y;
|
2004-02-03 17:53:55 +00:00
|
|
|
return hWndCaret;
|
2003-12-08 18:21:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NtUserBeginPaint
|
|
|
|
*
|
|
|
|
* Status
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
|
2002-07-04 20:12:28 +00:00
|
|
|
HDC STDCALL
|
2004-11-15 23:10:42 +00:00
|
|
|
NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
|
2002-07-04 20:12:28 +00:00
|
|
|
{
|
2005-09-11 14:48:32 +00:00
|
|
|
PWINDOW_OBJECT Window = NULL;
|
2004-11-15 23:10:42 +00:00
|
|
|
PAINTSTRUCT Ps;
|
|
|
|
PROSRGNDATA Rgn;
|
|
|
|
NTSTATUS Status;
|
2005-09-05 21:19:23 +00:00
|
|
|
DECLARE_RETURN(HDC);
|
2005-10-15 13:22:13 +00:00
|
|
|
USER_REFERENCE_ENTRY Ref;
|
2005-09-05 21:19:23 +00:00
|
|
|
|
|
|
|
DPRINT("Enter NtUserBeginPaint\n");
|
|
|
|
UserEnterExclusive();
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-09-11 14:48:32 +00:00
|
|
|
if (!(Window = UserGetWindowObject(hWnd)))
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( NULL);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
|
2005-10-15 13:22:13 +00:00
|
|
|
UserRefObjectCo(Window, &Ref);
|
2005-09-11 14:48:32 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
co_UserHideCaret(Window);
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-01-30 12:56:12 +00:00
|
|
|
if (Window->Flags & WINDOWOBJECT_NEED_NCPAINT)
|
|
|
|
{
|
|
|
|
HRGN hRgn;
|
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
hRgn = IntGetNCUpdateRgn(Window, FALSE);
|
2005-01-30 12:56:12 +00:00
|
|
|
Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
|
|
|
|
MsqDecPaintCountQueue(Window->MessageQueue);
|
2005-09-05 21:19:23 +00:00
|
|
|
co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)hRgn, 0);
|
2005-01-30 12:56:12 +00:00
|
|
|
if (hRgn != (HANDLE)1 && hRgn != NULL)
|
|
|
|
{
|
|
|
|
/* NOTE: The region can already by deleted! */
|
2006-04-01 15:25:40 +00:00
|
|
|
GDIOBJ_FreeObj(GdiHandleTable, hRgn, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
|
2005-01-30 12:56:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-15 23:10:42 +00:00
|
|
|
RtlZeroMemory(&Ps, sizeof(PAINTSTRUCT));
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-19 10:39:26 +00:00
|
|
|
Ps.hdc = UserGetDCEx(Window, Window->UpdateRegion, DCX_INTERSECTRGN | DCX_USESTYLE);
|
2004-11-15 23:10:42 +00:00
|
|
|
if (!Ps.hdc)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2005-09-25 11:16:54 +00:00
|
|
|
RETURN(NULL);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Window->UpdateRegion != NULL)
|
|
|
|
{
|
2002-08-27 23:29:40 +00:00
|
|
|
MsqDecPaintCountQueue(Window->MessageQueue);
|
2004-11-15 23:10:42 +00:00
|
|
|
Rgn = RGNDATA_LockRgn(Window->UpdateRegion);
|
|
|
|
if (NULL != Rgn)
|
2005-01-30 12:56:12 +00:00
|
|
|
{
|
|
|
|
UnsafeIntGetRgnBox(Rgn, &Ps.rcPaint);
|
2005-06-07 16:34:07 +00:00
|
|
|
RGNDATA_UnlockRgn(Rgn);
|
2005-09-25 11:16:54 +00:00
|
|
|
IntGdiIntersectRect(&Ps.rcPaint, &Ps.rcPaint, &Window->ClientRect);
|
2005-12-04 22:30:27 +00:00
|
|
|
if (! IntGdiIsEmptyRect(&Ps.rcPaint))
|
|
|
|
{
|
|
|
|
IntGdiOffsetRect(&Ps.rcPaint,
|
|
|
|
-Window->ClientRect.left,
|
|
|
|
-Window->ClientRect.top);
|
|
|
|
}
|
2005-01-30 12:56:12 +00:00
|
|
|
}
|
2004-11-15 23:10:42 +00:00
|
|
|
else
|
2005-01-30 12:56:12 +00:00
|
|
|
{
|
|
|
|
IntGetClientRect(Window, &Ps.rcPaint);
|
|
|
|
}
|
2006-04-01 15:25:40 +00:00
|
|
|
GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
|
2003-11-18 20:49:39 +00:00
|
|
|
Window->UpdateRegion = NULL;
|
|
|
|
}
|
2004-02-03 17:53:55 +00:00
|
|
|
else
|
|
|
|
{
|
2005-03-21 00:55:16 +00:00
|
|
|
if (Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
|
|
|
|
MsqDecPaintCountQueue(Window->MessageQueue);
|
2005-09-11 14:48:32 +00:00
|
|
|
|
2004-11-15 23:10:42 +00:00
|
|
|
IntGetClientRect(Window, &Ps.rcPaint);
|
2004-02-03 17:53:55 +00:00
|
|
|
}
|
2005-09-19 10:39:26 +00:00
|
|
|
|
2005-03-21 00:55:16 +00:00
|
|
|
Window->Flags &= ~WINDOWOBJECT_NEED_INTERNALPAINT;
|
2003-11-18 20:49:39 +00:00
|
|
|
|
|
|
|
if (Window->Flags & WINDOWOBJECT_NEED_ERASEBKGND)
|
|
|
|
{
|
|
|
|
Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND;
|
2005-09-05 21:19:23 +00:00
|
|
|
Ps.fErase = !co_IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)Ps.hdc, 0);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-11-15 23:10:42 +00:00
|
|
|
Ps.fErase = FALSE;
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
2002-07-04 20:12:28 +00:00
|
|
|
|
2004-11-15 23:10:42 +00:00
|
|
|
Status = MmCopyToCaller(UnsafePs, &Ps, sizeof(PAINTSTRUCT));
|
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
2005-09-25 11:16:54 +00:00
|
|
|
RETURN(NULL);
|
2004-11-15 23:10:42 +00:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:16:54 +00:00
|
|
|
RETURN(Ps.hdc);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
CLEANUP:
|
2005-09-11 14:48:32 +00:00
|
|
|
if (Window) UserDerefObjectCo(Window);
|
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
DPRINT("Leave NtUserBeginPaint, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
2002-07-04 20:12:28 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
/*
|
|
|
|
* NtUserEndPaint
|
|
|
|
*
|
|
|
|
* Status
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-07-04 20:12:28 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* lPs)
|
|
|
|
{
|
2005-09-05 21:19:23 +00:00
|
|
|
PWINDOW_OBJECT Window;
|
|
|
|
DECLARE_RETURN(BOOL);
|
2005-10-15 13:22:13 +00:00
|
|
|
USER_REFERENCE_ENTRY Ref;
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
DPRINT("Enter NtUserEndPaint\n");
|
|
|
|
UserEnterExclusive();
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-11 14:48:32 +00:00
|
|
|
if (!(Window = UserGetWindowObject(hWnd)))
|
2005-09-05 21:19:23 +00:00
|
|
|
{
|
|
|
|
RETURN(FALSE);
|
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-19 12:21:52 +00:00
|
|
|
UserReleaseDC(Window, lPs->hdc, TRUE);
|
2005-09-05 21:19:23 +00:00
|
|
|
|
2005-10-15 13:22:13 +00:00
|
|
|
UserRefObjectCo(Window, &Ref);
|
2005-09-11 14:48:32 +00:00
|
|
|
co_UserShowCaret(Window);
|
|
|
|
UserDerefObjectCo(Window);
|
2005-09-05 21:19:23 +00:00
|
|
|
|
|
|
|
RETURN(TRUE);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
CLEANUP:
|
|
|
|
DPRINT("Leave NtUserEndPaint, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2002-07-04 20:12:28 +00:00
|
|
|
}
|
2003-03-27 02:25:14 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
|
|
|
|
INT FASTCALL
|
2005-09-07 20:59:26 +00:00
|
|
|
co_UserGetUpdateRgn(PWINDOW_OBJECT Window, HRGN hRgn, BOOL bErase)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
|
|
|
int RegionType;
|
2005-09-25 11:16:54 +00:00
|
|
|
RECT Rect;
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
ASSERT_REFS_CO(Window);
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
if (Window->UpdateRegion == NULL)
|
|
|
|
{
|
2003-08-19 11:48:50 +00:00
|
|
|
RegionType = (NtGdiSetRectRgn(hRgn, 0, 0, 0, 0) ? NULLREGION : ERROR);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-25 11:16:54 +00:00
|
|
|
Rect = Window->ClientRect;
|
|
|
|
IntIntersectWithParents(Window, &Rect);
|
|
|
|
NtGdiSetRectRgn(hRgn, Rect.left, Rect.top, Rect.right, Rect.bottom);
|
|
|
|
RegionType = NtGdiCombineRgn(hRgn, hRgn, Window->UpdateRegion, RGN_AND);
|
2005-09-19 10:39:26 +00:00
|
|
|
NtGdiOffsetRgn(hRgn, -Window->ClientRect.left, -Window->ClientRect.top);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bErase && RegionType != NULLREGION && RegionType != ERROR)
|
|
|
|
{
|
2005-09-05 21:19:23 +00:00
|
|
|
co_UserRedrawWindow(Window, NULL, NULL, RDW_ERASENOW | RDW_NOCHILDREN);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
return RegionType;
|
|
|
|
}
|
2005-09-25 11:16:54 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
/*
|
|
|
|
* NtUserGetUpdateRgn
|
|
|
|
*
|
|
|
|
* Status
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
|
|
|
|
INT STDCALL
|
|
|
|
NtUserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase)
|
|
|
|
{
|
|
|
|
DECLARE_RETURN(INT);
|
2005-09-07 20:59:26 +00:00
|
|
|
PWINDOW_OBJECT Window;
|
|
|
|
INT ret;
|
2005-10-15 13:22:13 +00:00
|
|
|
USER_REFERENCE_ENTRY Ref;
|
2005-09-05 21:19:23 +00:00
|
|
|
|
|
|
|
DPRINT("Enter NtUserGetUpdateRgn\n");
|
|
|
|
UserEnterExclusive();
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
if (!(Window = UserGetWindowObject(hWnd)))
|
|
|
|
{
|
|
|
|
RETURN(ERROR);
|
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-10-15 13:22:13 +00:00
|
|
|
UserRefObjectCo(Window, &Ref);
|
2005-09-07 20:59:26 +00:00
|
|
|
ret = co_UserGetUpdateRgn(Window, hRgn, bErase);
|
|
|
|
UserDerefObjectCo(Window);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
RETURN(ret);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
CLEANUP:
|
|
|
|
DPRINT("Leave NtUserGetUpdateRgn, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
|
|
|
}
|
2003-11-18 20:49:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NtUserGetUpdateRect
|
|
|
|
*
|
|
|
|
* Status
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL STDCALL
|
2005-03-27 08:29:25 +00:00
|
|
|
NtUserGetUpdateRect(HWND hWnd, LPRECT UnsafeRect, BOOL bErase)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2005-03-27 08:29:25 +00:00
|
|
|
PWINDOW_OBJECT Window;
|
|
|
|
RECT Rect;
|
|
|
|
INT RegionType;
|
|
|
|
PROSRGNDATA RgnData;
|
|
|
|
NTSTATUS Status;
|
2005-09-05 21:19:23 +00:00
|
|
|
DECLARE_RETURN(BOOL);
|
|
|
|
|
|
|
|
DPRINT("Enter NtUserGetUpdateRect\n");
|
|
|
|
UserEnterExclusive();
|
2003-03-27 02:25:14 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
if (!(Window = UserGetWindowObject(hWnd)))
|
2005-03-27 08:29:25 +00:00
|
|
|
{
|
2005-09-25 11:16:54 +00:00
|
|
|
RETURN(FALSE);
|
2005-03-27 08:29:25 +00:00
|
|
|
}
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-03-27 08:29:25 +00:00
|
|
|
if (Window->UpdateRegion == NULL)
|
|
|
|
{
|
|
|
|
Rect.left = Rect.top = Rect.right = Rect.bottom = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-25 11:16:54 +00:00
|
|
|
/* Get the update region bounding box. */
|
|
|
|
if (Window->UpdateRegion == (HRGN)1)
|
|
|
|
{
|
|
|
|
Rect = Window->ClientRect;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RgnData = RGNDATA_LockRgn(Window->UpdateRegion);
|
|
|
|
ASSERT(RgnData != NULL);
|
|
|
|
RegionType = UnsafeIntGetRgnBox(RgnData, &Rect);
|
|
|
|
RGNDATA_UnlockRgn(RgnData);
|
|
|
|
|
|
|
|
if (RegionType != ERROR && RegionType != NULLREGION)
|
|
|
|
IntGdiIntersectRect(&Rect, &Rect, &Window->ClientRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IntIntersectWithParents(Window, &Rect))
|
|
|
|
{
|
|
|
|
IntGdiOffsetRect(&Rect,
|
|
|
|
-Window->ClientRect.left,
|
|
|
|
-Window->ClientRect.top);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
Rect.left = Rect.top = Rect.right = Rect.bottom = 0;
|
|
|
|
}
|
2005-03-27 08:29:25 +00:00
|
|
|
}
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-09-25 11:16:54 +00:00
|
|
|
if (bErase && !IntGdiIsEmptyRect(&Rect))
|
2005-03-27 08:29:25 +00:00
|
|
|
{
|
2005-10-15 13:22:13 +00:00
|
|
|
USER_REFERENCE_ENTRY Ref;
|
|
|
|
UserRefObjectCo(Window, &Ref);
|
2005-09-05 21:19:23 +00:00
|
|
|
co_UserRedrawWindow(Window, NULL, NULL, RDW_ERASENOW | RDW_NOCHILDREN);
|
2005-09-07 20:59:26 +00:00
|
|
|
UserDerefObjectCo(Window);
|
2005-03-27 08:29:25 +00:00
|
|
|
}
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-03-27 08:29:25 +00:00
|
|
|
if (UnsafeRect != NULL)
|
|
|
|
{
|
2004-07-09 20:13:00 +00:00
|
|
|
Status = MmCopyToCaller(UnsafeRect, &Rect, sizeof(RECT));
|
2005-03-27 08:29:25 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
2005-09-25 11:16:54 +00:00
|
|
|
RETURN(FALSE);
|
2005-03-27 08:29:25 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-12-04 22:28:29 +00:00
|
|
|
RETURN(!IntGdiIsEmptyRect(&Rect));
|
2005-09-05 21:19:23 +00:00
|
|
|
|
|
|
|
CLEANUP:
|
|
|
|
DPRINT("Leave NtUserGetUpdateRect, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NtUserRedrawWindow
|
|
|
|
*
|
|
|
|
* Status
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL STDCALL
|
|
|
|
NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
|
2005-09-07 21:25:42 +00:00
|
|
|
UINT flags)
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
|
|
|
RECT SafeUpdateRect;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PWINDOW_OBJECT Wnd;
|
2005-09-05 21:19:23 +00:00
|
|
|
DECLARE_RETURN(BOOL);
|
2005-10-15 13:22:13 +00:00
|
|
|
USER_REFERENCE_ENTRY Ref;
|
2005-09-05 21:19:23 +00:00
|
|
|
|
|
|
|
DPRINT("Enter NtUserRedrawWindow\n");
|
|
|
|
UserEnterExclusive();
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
if (!(Wnd = UserGetWindowObject(hWnd ? hWnd : IntGetDesktopWindow())))
|
2003-11-18 20:49:39 +00:00
|
|
|
{
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( FALSE);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lprcUpdate != NULL)
|
|
|
|
{
|
|
|
|
Status = MmCopyFromCaller(&SafeUpdateRect, (PRECT)lprcUpdate,
|
2005-09-07 21:25:42 +00:00
|
|
|
sizeof(RECT));
|
2003-11-18 20:49:39 +00:00
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( FALSE);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-15 13:22:13 +00:00
|
|
|
UserRefObjectCo(Wnd, &Ref);
|
2005-09-07 20:59:26 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
Status = co_UserRedrawWindow(Wnd, NULL == lprcUpdate ? NULL : &SafeUpdateRect,
|
2005-09-07 21:25:42 +00:00
|
|
|
hrgnUpdate, flags);
|
2003-11-18 20:49:39 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
UserDerefObjectCo(Wnd);
|
|
|
|
|
2003-11-18 20:49:39 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* IntRedrawWindow fails only in case that flags are invalid */
|
|
|
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( FALSE);
|
2003-11-18 20:49:39 +00:00
|
|
|
}
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( TRUE);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
CLEANUP:
|
|
|
|
DPRINT("Leave NtUserRedrawWindow, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2003-03-27 02:25:14 +00:00
|
|
|
}
|
2003-05-26 18:52:37 +00:00
|
|
|
|
2003-12-08 18:21:25 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
|
|
|
|
static
|
|
|
|
DWORD FASTCALL
|
|
|
|
UserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
|
2005-09-07 21:25:42 +00:00
|
|
|
const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
|
2003-12-08 18:21:25 +00:00
|
|
|
{
|
|
|
|
RECT rSrc, rClipped_src, rClip, rDst, offset;
|
2004-01-10 21:59:05 +00:00
|
|
|
PDC DC;
|
2003-12-08 18:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute device clipping region (in device coordinates).
|
|
|
|
*/
|
|
|
|
|
2004-01-10 21:59:05 +00:00
|
|
|
DC = DC_LockDc(hDC);
|
|
|
|
if (NULL == DC)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-12-08 18:21:25 +00:00
|
|
|
if (lprcScroll)
|
|
|
|
rSrc = *lprcScroll;
|
|
|
|
else
|
2003-12-13 12:12:41 +00:00
|
|
|
IntGdiGetClipBox(hDC, &rSrc);
|
2004-01-10 21:59:05 +00:00
|
|
|
IntLPtoDP(DC, (LPPOINT)&rSrc, 2);
|
2003-12-08 18:21:25 +00:00
|
|
|
|
|
|
|
if (lprcClip)
|
|
|
|
rClip = *lprcClip;
|
|
|
|
else
|
2003-12-13 12:12:41 +00:00
|
|
|
IntGdiGetClipBox(hDC, &rClip);
|
2004-01-10 21:59:05 +00:00
|
|
|
IntLPtoDP(DC, (LPPOINT)&rClip, 2);
|
2003-12-08 18:21:25 +00:00
|
|
|
|
2004-11-15 23:10:42 +00:00
|
|
|
IntGdiIntersectRect(&rClipped_src, &rSrc, &rClip);
|
2003-12-08 18:21:25 +00:00
|
|
|
|
|
|
|
rDst = rClipped_src;
|
2004-11-15 23:10:42 +00:00
|
|
|
IntGdiSetRect(&offset, 0, 0, dx, dy);
|
2004-01-10 21:59:05 +00:00
|
|
|
IntLPtoDP(DC, (LPPOINT)&offset, 2);
|
2004-11-15 23:10:42 +00:00
|
|
|
IntGdiOffsetRect(&rDst, offset.right - offset.left, offset.bottom - offset.top);
|
|
|
|
IntGdiIntersectRect(&rDst, &rDst, &rClip);
|
2003-12-08 18:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy bits, if possible.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (rDst.bottom > rDst.top && rDst.right > rDst.left)
|
|
|
|
{
|
|
|
|
RECT rDst_lp = rDst, rSrc_lp = rDst;
|
|
|
|
|
2004-11-15 23:10:42 +00:00
|
|
|
IntGdiOffsetRect(&rSrc_lp, offset.left - offset.right, offset.top - offset.bottom);
|
2004-02-03 17:53:55 +00:00
|
|
|
IntDPtoLP(DC, (LPPOINT)&rDst_lp, 2);
|
|
|
|
IntDPtoLP(DC, (LPPOINT)&rSrc_lp, 2);
|
2005-06-07 16:34:07 +00:00
|
|
|
DC_UnlockDc(DC);
|
2003-12-08 18:21:25 +00:00
|
|
|
|
|
|
|
if (!NtGdiBitBlt(hDC, rDst_lp.left, rDst_lp.top, rDst_lp.right - rDst_lp.left,
|
|
|
|
rDst_lp.bottom - rDst_lp.top, hDC, rSrc_lp.left, rSrc_lp.top,
|
2005-12-28 20:31:44 +00:00
|
|
|
SRCCOPY, 0, 0))
|
2003-12-08 18:21:25 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2004-02-03 17:53:55 +00:00
|
|
|
else
|
|
|
|
{
|
2005-06-07 16:34:07 +00:00
|
|
|
DC_UnlockDc(DC);
|
2004-02-03 17:53:55 +00:00
|
|
|
}
|
2003-12-08 18:21:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute update areas. This is the clipped source or'ed with the
|
|
|
|
* unclipped source translated minus the clipped src translated (rDst)
|
|
|
|
* all clipped to rClip.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (hrgnUpdate || lprcUpdate)
|
|
|
|
{
|
|
|
|
HRGN hRgn = hrgnUpdate, hRgn2;
|
|
|
|
|
|
|
|
if (hRgn)
|
|
|
|
NtGdiSetRectRgn(hRgn, rClipped_src.left, rClipped_src.top, rClipped_src.right, rClipped_src.bottom);
|
|
|
|
else
|
|
|
|
hRgn = NtGdiCreateRectRgn(rClipped_src.left, rClipped_src.top, rClipped_src.right, rClipped_src.bottom);
|
|
|
|
|
2004-02-03 17:53:55 +00:00
|
|
|
hRgn2 = UnsafeIntCreateRectRgnIndirect(&rSrc);
|
2003-12-08 18:21:25 +00:00
|
|
|
NtGdiOffsetRgn(hRgn2, offset.right - offset.left, offset.bottom - offset.top);
|
|
|
|
NtGdiCombineRgn(hRgn, hRgn, hRgn2, RGN_OR);
|
|
|
|
|
|
|
|
NtGdiSetRectRgn(hRgn2, rDst.left, rDst.top, rDst.right, rDst.bottom);
|
|
|
|
NtGdiCombineRgn(hRgn, hRgn, hRgn2, RGN_DIFF);
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2003-12-08 18:21:25 +00:00
|
|
|
NtGdiSetRectRgn(hRgn2, rClip.left, rClip.top, rClip.right, rClip.bottom);
|
|
|
|
NtGdiCombineRgn(hRgn, hRgn, hRgn2, RGN_AND);
|
|
|
|
|
|
|
|
if (lprcUpdate)
|
|
|
|
{
|
|
|
|
NtGdiGetRgnBox(hRgn, lprcUpdate);
|
|
|
|
|
|
|
|
/* Put the lprcUpdate in logical coordinate */
|
|
|
|
NtGdiDPtoLP(hDC, (LPPOINT)lprcUpdate, 2);
|
|
|
|
}
|
|
|
|
if (!hrgnUpdate)
|
|
|
|
NtGdiDeleteObject(hRgn);
|
|
|
|
NtGdiDeleteObject(hRgn2);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NtUserScrollDC
|
|
|
|
*
|
|
|
|
* Status
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
|
|
|
|
DWORD STDCALL
|
|
|
|
NtUserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
|
2005-09-07 21:25:42 +00:00
|
|
|
const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
|
2005-09-05 21:19:23 +00:00
|
|
|
{
|
|
|
|
DECLARE_RETURN(DWORD);
|
|
|
|
|
|
|
|
DPRINT("Enter NtUserScrollDC\n");
|
|
|
|
UserEnterExclusive();
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( UserScrollDC(hDC, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate));
|
|
|
|
|
|
|
|
CLEANUP:
|
|
|
|
DPRINT("Leave NtUserScrollDC, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
}
|
|
|
|
|
2003-12-08 18:21:25 +00:00
|
|
|
/*
|
|
|
|
* NtUserScrollWindowEx
|
|
|
|
*
|
|
|
|
* Status
|
2003-12-23 18:19:07 +00:00
|
|
|
* @implemented
|
2003-12-08 18:21:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
DWORD STDCALL
|
2004-11-15 23:10:42 +00:00
|
|
|
NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
|
2005-09-07 21:25:42 +00:00
|
|
|
const RECT *UnsafeClipRect, HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags)
|
2003-12-08 18:21:25 +00:00
|
|
|
{
|
2004-11-15 23:10:42 +00:00
|
|
|
RECT rc, cliprc, caretrc, rect, clipRect;
|
2003-12-08 18:21:25 +00:00
|
|
|
INT Result;
|
2005-09-07 20:59:26 +00:00
|
|
|
PWINDOW_OBJECT Window = NULL, CaretWnd;
|
2003-12-08 18:21:25 +00:00
|
|
|
HDC hDC;
|
|
|
|
HRGN hrgnTemp;
|
|
|
|
HWND hwndCaret;
|
|
|
|
BOOL bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE));
|
|
|
|
BOOL bOwnRgn = TRUE;
|
2004-11-15 23:10:42 +00:00
|
|
|
NTSTATUS Status;
|
2005-09-05 21:19:23 +00:00
|
|
|
DECLARE_RETURN(DWORD);
|
2005-10-15 13:22:13 +00:00
|
|
|
USER_REFERENCE_ENTRY Ref, CaretRef;
|
2005-09-05 21:19:23 +00:00
|
|
|
|
|
|
|
DPRINT("Enter NtUserScrollWindowEx\n");
|
|
|
|
UserEnterExclusive();
|
2003-12-08 18:21:25 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
Window = UserGetWindowObject(hWnd);
|
2003-12-08 18:21:25 +00:00
|
|
|
if (!Window || !IntIsWindowDrawable(Window))
|
|
|
|
{
|
2005-09-07 20:59:26 +00:00
|
|
|
Window = NULL; /* prevent deref at cleanup */
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( ERROR);
|
2003-12-08 18:21:25 +00:00
|
|
|
}
|
2005-10-15 13:22:13 +00:00
|
|
|
UserRefObjectCo(Window, &Ref);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2003-12-08 18:21:25 +00:00
|
|
|
IntGetClientRect(Window, &rc);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2004-11-15 23:10:42 +00:00
|
|
|
if (NULL != UnsafeRect)
|
|
|
|
{
|
2005-05-08 02:11:54 +00:00
|
|
|
Status = MmCopyFromCaller(&rect, UnsafeRect, sizeof(RECT));
|
2004-11-15 23:10:42 +00:00
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( ERROR);
|
2004-11-15 23:10:42 +00:00
|
|
|
}
|
|
|
|
IntGdiIntersectRect(&rc, &rc, &rect);
|
|
|
|
}
|
2003-12-08 18:21:25 +00:00
|
|
|
|
2004-11-15 23:10:42 +00:00
|
|
|
if (NULL != UnsafeClipRect)
|
|
|
|
{
|
2005-05-08 02:11:54 +00:00
|
|
|
Status = MmCopyFromCaller(&clipRect, UnsafeClipRect, sizeof(RECT));
|
2004-11-15 23:10:42 +00:00
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( ERROR);
|
2004-11-15 23:10:42 +00:00
|
|
|
}
|
|
|
|
IntGdiIntersectRect(&cliprc, &rc, &clipRect);
|
|
|
|
}
|
2003-12-08 18:21:25 +00:00
|
|
|
else
|
|
|
|
cliprc = rc;
|
|
|
|
|
|
|
|
if (cliprc.right <= cliprc.left || cliprc.bottom <= cliprc.top ||
|
2005-09-07 21:25:42 +00:00
|
|
|
(dx == 0 && dy == 0))
|
2005-05-08 02:11:54 +00:00
|
|
|
{
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( NULLREGION);
|
2003-12-08 18:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
caretrc = rc;
|
2005-09-07 20:59:26 +00:00
|
|
|
hwndCaret = co_IntFixCaret(Window, &caretrc, flags);
|
2003-12-08 18:21:25 +00:00
|
|
|
|
|
|
|
if (hrgnUpdate)
|
|
|
|
bOwnRgn = FALSE;
|
|
|
|
else if (bUpdate)
|
|
|
|
hrgnUpdate = NtGdiCreateRectRgn(0, 0, 0, 0);
|
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
hDC = UserGetDCEx(Window, 0, DCX_CACHE | DCX_USESTYLE);
|
2003-12-08 18:21:25 +00:00
|
|
|
if (hDC)
|
|
|
|
{
|
2005-09-05 21:19:23 +00:00
|
|
|
UserScrollDC(hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate);
|
2005-09-19 12:21:52 +00:00
|
|
|
UserReleaseDC(Window, hDC, FALSE);
|
2003-12-08 18:21:25 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 02:11:54 +00:00
|
|
|
/*
|
2003-12-08 18:21:25 +00:00
|
|
|
* Take into account the fact that some damage may have occurred during
|
|
|
|
* the scroll.
|
|
|
|
*/
|
|
|
|
|
|
|
|
hrgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0);
|
2005-09-07 20:59:26 +00:00
|
|
|
Result = co_UserGetUpdateRgn(Window, hrgnTemp, FALSE);
|
2003-12-08 18:21:25 +00:00
|
|
|
if (Result != NULLREGION)
|
|
|
|
{
|
2004-02-03 17:53:55 +00:00
|
|
|
HRGN hrgnClip = UnsafeIntCreateRectRgnIndirect(&cliprc);
|
2003-12-08 18:21:25 +00:00
|
|
|
NtGdiOffsetRgn(hrgnTemp, dx, dy);
|
|
|
|
NtGdiCombineRgn(hrgnTemp, hrgnTemp, hrgnClip, RGN_AND);
|
2005-09-05 21:19:23 +00:00
|
|
|
co_UserRedrawWindow(Window, NULL, hrgnTemp, RDW_INVALIDATE | RDW_ERASE);
|
2003-12-08 18:21:25 +00:00
|
|
|
NtGdiDeleteObject(hrgnClip);
|
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2003-12-08 18:21:25 +00:00
|
|
|
NtGdiDeleteObject(hrgnTemp);
|
|
|
|
|
|
|
|
if (flags & SW_SCROLLCHILDREN)
|
|
|
|
{
|
|
|
|
HWND *List = IntWinListChildren(Window);
|
|
|
|
if (List)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
RECT r, dummy;
|
2005-05-02 14:05:38 +00:00
|
|
|
POINT ClientOrigin;
|
2005-09-07 20:59:26 +00:00
|
|
|
PWINDOW_OBJECT Wnd;
|
2005-10-15 13:22:13 +00:00
|
|
|
USER_REFERENCE_ENTRY WndRef;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
IntGetClientOrigin(Window, &ClientOrigin);
|
2003-12-08 18:21:25 +00:00
|
|
|
for (i = 0; List[i]; i++)
|
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
if (!(Wnd = UserGetWindowObject(List[i])))
|
|
|
|
continue;
|
2005-09-07 20:59:26 +00:00
|
|
|
|
|
|
|
r = Wnd->WindowRect;
|
2005-05-02 14:05:38 +00:00
|
|
|
r.left -= ClientOrigin.x;
|
|
|
|
r.top -= ClientOrigin.y;
|
|
|
|
r.right -= ClientOrigin.x;
|
|
|
|
r.bottom -= ClientOrigin.y;
|
2005-09-07 20:59:26 +00:00
|
|
|
|
2004-11-15 23:10:42 +00:00
|
|
|
if (! UnsafeRect || IntGdiIntersectRect(&dummy, &r, &rc))
|
2005-09-07 20:59:26 +00:00
|
|
|
{
|
2005-10-15 13:22:13 +00:00
|
|
|
UserRefObjectCo(Wnd, &WndRef);
|
2005-09-07 20:59:26 +00:00
|
|
|
co_WinPosSetWindowPos(Wnd, 0, r.left + dx, r.top + dy, 0, 0,
|
2005-09-07 21:25:42 +00:00
|
|
|
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE |
|
|
|
|
SWP_NOREDRAW);
|
|
|
|
UserDerefObjectCo(Wnd);
|
2005-09-07 20:59:26 +00:00
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2003-12-08 18:21:25 +00:00
|
|
|
}
|
|
|
|
ExFreePool(List);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & (SW_INVALIDATE | SW_ERASE))
|
2005-09-05 21:19:23 +00:00
|
|
|
co_UserRedrawWindow(Window, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE |
|
2005-09-07 21:25:42 +00:00
|
|
|
((flags & SW_ERASE) ? RDW_ERASENOW : 0) |
|
|
|
|
((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0));
|
2003-12-08 18:21:25 +00:00
|
|
|
|
|
|
|
if (bOwnRgn && hrgnUpdate)
|
|
|
|
NtGdiDeleteObject(hrgnUpdate);
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
if ((CaretWnd = UserGetWindowObject(hwndCaret)))
|
2003-12-08 18:21:25 +00:00
|
|
|
{
|
2005-10-15 13:22:13 +00:00
|
|
|
UserRefObjectCo(CaretWnd, &CaretRef);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
co_IntSetCaretPos(caretrc.left + dx, caretrc.top + dy);
|
|
|
|
co_UserShowCaret(CaretWnd);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-07 20:59:26 +00:00
|
|
|
UserDerefObjectCo(CaretWnd);
|
2003-12-08 18:21:25 +00:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:16:54 +00:00
|
|
|
RETURN(Result);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
CLEANUP:
|
2005-09-07 21:25:42 +00:00
|
|
|
if (Window)
|
|
|
|
UserDerefObjectCo(Window);
|
2005-09-07 20:59:26 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
DPRINT("Leave NtUserScrollWindowEx, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2003-12-08 18:21:25 +00:00
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
/* EOF */
|