From b1635197577cc38105cb2a46eb6656a5e45a3b3e Mon Sep 17 00:00:00 2001 From: David Welch Date: Sun, 1 Sep 2002 20:39:56 +0000 Subject: [PATCH] Don't reinitialize the VGA on an enable surface if it is already initialized Implemented patblt and rectangle fill Offset drawing by the origin of the DC Other GUI fixes svn path=/trunk/; revision=3450 --- reactos/apps/tests/winhello/winhello.c | 2 +- reactos/drivers/dd/vga/display/main/enable.c | 36 +- .../drivers/dd/vga/display/objects/bitblt.c | 14 +- reactos/iface/addsys/w32ksvc.db | 1 + reactos/include/defines.h | 8 - reactos/include/win32k/ntuser.h | 3 +- reactos/include/win32k/region.h | 3 + reactos/lib/gdi32/misc/stubs.c | 25 +- reactos/lib/gdi32/objects/bitblt.c | 5 + reactos/lib/gdi32/objects/dc.c | 7 + reactos/lib/user32/misc/stubs.c | 10 +- reactos/lib/user32/windows/class.c | 30 +- reactos/lib/user32/windows/defwnd.c | 8 +- reactos/lib/user32/windows/draw.c | 30 +- reactos/lib/user32/windows/rect.c | 158 ++++---- reactos/subsys/win32k/eng/bitblt.c | 9 +- reactos/subsys/win32k/include/dce.h | 2 +- reactos/subsys/win32k/include/window.h | 2 +- reactos/subsys/win32k/ntuser/class.c | 34 +- reactos/subsys/win32k/ntuser/metric.c | 4 +- reactos/subsys/win32k/ntuser/windc.c | 380 ++++++++++++------ reactos/subsys/win32k/ntuser/window.c | 7 +- reactos/subsys/win32k/objects/brush.c | 65 ++- reactos/subsys/win32k/objects/cliprgn.c | 26 +- reactos/subsys/win32k/objects/dc.c | 18 +- reactos/subsys/win32k/objects/fillshap.c | 39 +- reactos/subsys/win32k/objects/gdiobj.c | 43 +- reactos/subsys/win32k/objects/rect.c | 2 +- reactos/subsys/win32k/objects/region.c | 52 ++- reactos/subsys/win32k/objects/text.c | 7 +- 30 files changed, 702 insertions(+), 328 deletions(-) diff --git a/reactos/apps/tests/winhello/winhello.c b/reactos/apps/tests/winhello/winhello.c index d330b6de514..122da78ee06 100644 --- a/reactos/apps/tests/winhello/winhello.c +++ b/reactos/apps/tests/winhello/winhello.c @@ -19,7 +19,7 @@ WinMain(HINSTANCE hInstance, wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); + wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH); wc.lpszMenuName = NULL; wc.cbClsExtra = 0; wc.cbWndExtra = 0; diff --git a/reactos/drivers/dd/vga/display/main/enable.c b/reactos/drivers/dd/vga/display/main/enable.c index 3bd357fc2c4..b2174d94a29 100644 --- a/reactos/drivers/dd/vga/display/main/enable.c +++ b/reactos/drivers/dd/vga/display/main/enable.c @@ -1,9 +1,9 @@ /* * entry.c * - * $Revision: 1.19 $ - * $Author: jfilby $ - * $Date: 2002/08/19 22:01:11 $ + * $Revision: 1.20 $ + * $Author: dwelch $ + * $Date: 2002/09/01 20:39:53 $ * */ @@ -13,6 +13,7 @@ #define DBG_PREFIX "VGADDI: " +static BOOL VGAInitialized = FALSE; DRVFN FuncList[] = { @@ -186,12 +187,15 @@ DrvAssertMode(IN DHPDEV DPev, return FALSE; } - if (!InitVGA(ppdev, FALSE)) - { - // Failed to initialize the VGA - return FALSE; - } - + if (!VGAInitialized) + { + if (!InitVGA(ppdev, FALSE)) + { + // Failed to initialize the VGA + return FALSE; + } + VGAInitialized = TRUE; + } } else { // Go back to last known mode DPRINT( "ppdev: %x, KMDriver: %x", ppdev, ppdev->KMDriver ); @@ -200,7 +204,7 @@ DrvAssertMode(IN DHPDEV DPev, // Failed to go back to mode return FALSE; } - + VGAInitialized = FALSE; } } @@ -323,10 +327,14 @@ DrvEnableSurface(IN DHPDEV PDev) DPRINT1("DrvEnableSurface() called\n"); // Initialize the VGA - if (!InitVGA(ppdev, TRUE)) - { - goto error_done; - } + if (!VGAInitialized) + { + if (!InitVGA(ppdev, TRUE)) + { + goto error_done; + } + VGAInitialized = TRUE; + } CHECKPOINT1; // dhsurf is of type DEVSURF, which is the drivers specialized surface type diff --git a/reactos/drivers/dd/vga/display/objects/bitblt.c b/reactos/drivers/dd/vga/display/objects/bitblt.c index cc89dc50196..279e6a78363 100644 --- a/reactos/drivers/dd/vga/display/objects/bitblt.c +++ b/reactos/drivers/dd/vga/display/objects/bitblt.c @@ -57,9 +57,19 @@ BOOL DIBtoVGA( } tMask += Mask->lDelta; } - } - } else + } else if (rop4 == PATCOPY) + { + for (j=0;jleft+i, DestRect->top+j, + Brush->iSolidColor); + } + } + } + else DIB_BltToVGA(DestRect->left, DestRect->top, dx, dy, Source->pvBits, Source->lDelta); } else { diff --git a/reactos/iface/addsys/w32ksvc.db b/reactos/iface/addsys/w32ksvc.db index 3d978a11d03..989850c8a19 100644 --- a/reactos/iface/addsys/w32ksvc.db +++ b/reactos/iface/addsys/w32ksvc.db @@ -355,6 +355,7 @@ NtUserGetAsyncKeyState 1 NtUserGetCaretBlinkTime 0 NtUserGetCaretPos 1 NtUserGetClassInfo 5 +NtUserGetClassLong 2 NtUserGetClassName 3 NtUserGetClipboardData 2 NtUserGetClipboardFormatName 3 diff --git a/reactos/include/defines.h b/reactos/include/defines.h index 29ab9868534..a1defe1f50f 100644 --- a/reactos/include/defines.h +++ b/reactos/include/defines.h @@ -1302,14 +1302,6 @@ extern "C" { #define DCX_EXCLUDEUPDATE (0x00000100L) #define DCX_INTERSECTUPDATE (0x00000200L) -/* Internal DCX flags */ -#define DCX_DCEEMPTY (0x00000800L) -#define DCX_DCEBUSY (0x00001000L) -#define DCX_DCEDIRTY (0x00002000L) -#define DCX_WINDOWPAINT (0x00020000L) -#define DCX_KEEPCLIPRGN (0x00040000L) -#define DCX_NOCLIPCHILDREN (0x00080000L) - /* GetDeviceCaps */ #define DRIVERVERSION (0) #define TECHNOLOGY (2) diff --git a/reactos/include/win32k/ntuser.h b/reactos/include/win32k/ntuser.h index aca3017649b..c5ca69dba2c 100644 --- a/reactos/include/win32k/ntuser.h +++ b/reactos/include/win32k/ntuser.h @@ -614,8 +614,7 @@ STDCALL NtUserGetCursorInfo( DWORD Unknown0); -DWORD -STDCALL +HDC STDCALL NtUserGetDC(HWND hWnd); HDC STDCALL NtUserGetDCEx(HWND hWnd, HANDLE hRegion, ULONG Flags); diff --git a/reactos/include/win32k/region.h b/reactos/include/win32k/region.h index 2c87cd20ece..6ee4ea49bf8 100644 --- a/reactos/include/win32k/region.h +++ b/reactos/include/win32k/region.h @@ -146,5 +146,8 @@ W32kGetRegionData(HRGN hrgn, HRGN REGION_CropRgn(HRGN hDst, HRGN hSrc, const PRECT lpRect, PPOINT lpPt); HRGN STDCALL UnsafeW32kCreateRectRgnIndirect(CONST PRECT rc); +INT STDCALL +UnsafeW32kGetRgnBox(HRGN hRgn, + LPRECT pRect); #endif diff --git a/reactos/lib/gdi32/misc/stubs.c b/reactos/lib/gdi32/misc/stubs.c index 0b31c0423d3..06c29bb844d 100644 --- a/reactos/lib/gdi32/misc/stubs.c +++ b/reactos/lib/gdi32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.9 2002/08/31 23:18:45 dwelch Exp $ +/* $Id: stubs.c,v 1.10 2002/09/01 20:39:54 dwelch Exp $ * * reactos/lib/gdi32/misc/stubs.c * @@ -690,15 +690,6 @@ GetRasterizerCaps( -HGDIOBJ -STDCALL -GetStockObject( - int a0 - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} @@ -939,20 +930,6 @@ OffsetClipRgn( } -BOOL -STDCALL -PatBlt( - HDC a0, - int a1, - int a2, - int a3, - int a4, - DWORD a5 - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} diff --git a/reactos/lib/gdi32/objects/bitblt.c b/reactos/lib/gdi32/objects/bitblt.c index 94ccdc26b1e..ec8f3a4fd88 100644 --- a/reactos/lib/gdi32/objects/bitblt.c +++ b/reactos/lib/gdi32/objects/bitblt.c @@ -217,6 +217,11 @@ SetPixel(HDC hDC, return W32kSetPixel(hDC, X, Y, Color); } +BOOL STDCALL +PatBlt(HDC hDC, INT Top, INT Left, INT Width, INT Height, ULONG Rop) +{ + return(W32kPatBlt(hDC, Top, Left, Width, Height, Rop)); +} diff --git a/reactos/lib/gdi32/objects/dc.c b/reactos/lib/gdi32/objects/dc.c index 454fb651871..13195c52add 100644 --- a/reactos/lib/gdi32/objects/dc.c +++ b/reactos/lib/gdi32/objects/dc.c @@ -7,6 +7,13 @@ #include #include +HGDIOBJ STDCALL +GetStockObject(int Index) +{ + return(W32kGetStockObject(Index)); +} + + int STDCALL GetClipBox(HDC hDc, LPRECT Rect) { diff --git a/reactos/lib/user32/misc/stubs.c b/reactos/lib/user32/misc/stubs.c index 0c798e0620b..36cd5bd15ef 100644 --- a/reactos/lib/user32/misc/stubs.c +++ b/reactos/lib/user32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.10 2002/08/31 23:18:46 dwelch Exp $ +/* $Id: stubs.c,v 1.11 2002/09/01 20:39:55 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -223,14 +223,6 @@ GetSysColor( return 0; } -HBRUSH -STDCALL -GetSysColorBrush( - int nIndex) -{ - return (HBRUSH)0; -} - HMENU STDCALL GetSystemMenu( diff --git a/reactos/lib/user32/windows/class.c b/reactos/lib/user32/windows/class.c index 3f32909a15c..004f95b686e 100644 --- a/reactos/lib/user32/windows/class.c +++ b/reactos/lib/user32/windows/class.c @@ -1,4 +1,4 @@ -/* $Id: class.c,v 1.13 2002/06/18 21:51:09 dwelch Exp $ +/* $Id: class.c,v 1.14 2002/09/01 20:39:55 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -53,22 +53,26 @@ GetClassInfoW( return FALSE; } -DWORD -STDCALL -GetClassLongA( - HWND hWnd, - int nIndex) +DWORD STDCALL +GetClassLongA(HWND hWnd, int nIndex) { - return 0; + switch (nIndex) + { + case GCL_WNDPROC: + UNIMPLEMENTED; + return(0); + case GCL_MENUNAME: + UNIMPLEMENTED; + return(0); + default: + return(GetClassLongW(hWnd, nIndex)); + } } -DWORD -STDCALL -GetClassLongW( - HWND hWnd, - int nIndex) +DWORD STDCALL +GetClassLongW(HWND hWnd, int nIndex) { - return 0; + return(NtUserGetClassLong(hWnd, nIndex)); } int diff --git a/reactos/lib/user32/windows/defwnd.c b/reactos/lib/user32/windows/defwnd.c index 1caab235bb8..75a124a580d 100644 --- a/reactos/lib/user32/windows/defwnd.c +++ b/reactos/lib/user32/windows/defwnd.c @@ -1,4 +1,4 @@ -/* $Id: defwnd.c,v 1.5 2002/08/31 23:18:46 dwelch Exp $ +/* $Id: defwnd.c,v 1.6 2002/09/01 20:39:55 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -69,6 +69,12 @@ GetSysColorPen(int nIndex) return(CreatePen(PS_SOLID, 1, SysColours[nIndex])); } +HBRUSH STDCALL +GetSysColorBrush(int nIndex) +{ + return(CreateSolidBrush(SysColours[nIndex])); +} + LRESULT STDCALL DefFrameProcA(HWND hWnd, diff --git a/reactos/lib/user32/windows/draw.c b/reactos/lib/user32/windows/draw.c index 778f3e761da..d5b5ea8efd6 100644 --- a/reactos/lib/user32/windows/draw.c +++ b/reactos/lib/user32/windows/draw.c @@ -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: draw.c,v 1.1 2002/06/13 20:36:40 dwelch Exp $ +/* $Id: draw.c,v 1.2 2002/09/01 20:39:55 dwelch Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -32,6 +32,10 @@ #include #include +/* GLOBALS *******************************************************************/ + +#define COLOR_MAX (28) + /* FUNCTIONS *****************************************************************/ WINBOOL @@ -127,15 +131,25 @@ FlashWindowEx( { return FALSE; } -int -STDCALL -FillRect( - HDC hDC, - CONST RECT *lprc, - HBRUSH hbr) + +int STDCALL +FillRect(HDC hDC, CONST RECT *lprc, HBRUSH hbr) { - return 0; + HBRUSH prevhbr; + /*if (hbr <= (HBRUSH)(COLOR_MAX + 1)) + { + hbr = GetSysColorBrush((INT)hbr - 1); + }*/ + if ((prevhbr = SelectObject(hDC, hbr)) == NULL) + { + return(FALSE); + } + PatBlt(hDC, lprc->left, lprc->top, lprc->right - lprc->left, + lprc->bottom - lprc->top, PATCOPY); + SelectObject(hDC, prevhbr); + return(TRUE); } + WINBOOL STDCALL DrawAnimatedRects( diff --git a/reactos/lib/user32/windows/rect.c b/reactos/lib/user32/windows/rect.c index 3296f868d96..13d0f951081 100644 --- a/reactos/lib/user32/windows/rect.c +++ b/reactos/lib/user32/windows/rect.c @@ -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: rect.c,v 1.5 2002/06/13 20:36:40 dwelch Exp $ +/* $Id: rect.c,v 1.6 2002/09/01 20:39:55 dwelch Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -34,30 +34,31 @@ /* FUNCTIONS *****************************************************************/ -WINBOOL -STDCALL -CopyRect( - LPRECT lprcDst, - CONST RECT *lprcSrc) +WINBOOL STDCALL +CopyRect(LPRECT lprcDst, CONST RECT *lprcSrc) { - return FALSE; + *lprcDst = *lprcSrc; + return(TRUE); } + WINBOOL STDCALL EqualRect( CONST RECT *lprc1, CONST RECT *lprc2) { + UNIMPLEMENTED; return FALSE; } -WINBOOL -STDCALL -InflateRect( - LPRECT lprc, - int dx, - int dy) + +WINBOOL STDCALL +InflateRect(LPRECT rect, int dx, int dy) { - return FALSE; + rect->left -= dx; + rect->top -= dy; + rect->right -= dx; + rect->bottom -= dy; + return(TRUE); } WINBOOL @@ -67,66 +68,85 @@ IntersectRect( CONST RECT *lprcSrc1, CONST RECT *lprcSrc2) { - return FALSE; -} -WINBOOL -STDCALL -IsRectEmpty( - CONST RECT *lprc) -{ - return FALSE; -} -WINBOOL -STDCALL -OffsetRect( - LPRECT lprc, - int dx, - int dy) -{ - return FALSE; -} -WINBOOL -STDCALL -PtInRect( - CONST RECT *lprc, - POINT pt) -{ - return FALSE; -} -WINBOOL -STDCALL -SetRect( - LPRECT lprc, - int xLeft, - int yTop, - int xRight, - int yBottom) -{ + UNIMPLEMENTED; return FALSE; } -WINBOOL -STDCALL -SetRectEmpty( - LPRECT lprc) +WINBOOL STDCALL +IsRectEmpty(CONST RECT *lprc) { + return((lprc->left >= lprc->right) || (lprc->top >= lprc->bottom)); +} + +WINBOOL STDCALL +OffsetRect(LPRECT rect, int dx, int dy) +{ + rect->left += dx; + rect->top += dy; + rect->right += dx; + rect->bottom += dy; + return(TRUE); +} + +WINBOOL STDCALL +PtInRect(CONST RECT *lprc, POINT pt) +{ + return((pt.x >= lprc->left) && (pt.x < lprc->right) && + (pt.y >= lprc->top) && (pt.y < lprc->bottom)); +} + +WINBOOL STDCALL +SetRect(LPRECT lprc, int xLeft, int yTop, int xRight, int yBottom) +{ + lprc->left = xLeft; + lprc->top = yTop; + lprc->right = xRight; + lprc->bottom = yBottom; + return(TRUE); +} + +BOOL STDCALL +SetRectEmpty(LPRECT lprc) +{ + lprc->left = lprc->right = lprc->top = lprc->bottom = 0; + return(TRUE); +} + +WINBOOL STDCALL +SubtractRect(LPRECT lprcDst, CONST RECT *lprcSrc1, CONST RECT *lprcSrc2) +{ + UNIMPLEMENTED; return FALSE; } -WINBOOL -STDCALL -SubtractRect( - LPRECT lprcDst, - CONST RECT *lprcSrc1, - CONST RECT *lprcSrc2) + +WINBOOL STDCALL +UnionRect(LPRECT lprcDst, CONST RECT *lprcSrc1, CONST RECT *lprcSrc2) { - return FALSE; -} -WINBOOL -STDCALL -UnionRect( - LPRECT lprcDst, - CONST RECT *lprcSrc1, - CONST RECT *lprcSrc2) -{ - return FALSE; + if (IsRectEmpty(lprcSrc1)) + { + if (IsRectEmpty(lprcSrc2)) + { + SetRectEmpty(lprcDst); + return(FALSE); + } + else + { + *lprcDst = *lprcSrc2; + } + } + else + { + if (IsRectEmpty(lprcSrc2)) + { + *lprcDst = *lprcSrc1; + } + else + { + lprcDst->left = min(lprcSrc1->left, lprcSrc2->left); + lprcDst->top = min(lprcSrc1->top, lprcSrc2->top); + lprcDst->right = max(lprcSrc1->right, lprcSrc2->right); + lprcDst->bottom = max(lprcSrc1->bottom, lprcSrc2->bottom); + } + } + return(TRUE); } diff --git a/reactos/subsys/win32k/eng/bitblt.c b/reactos/subsys/win32k/eng/bitblt.c index d03f25b56ae..91ba8835bb1 100644 --- a/reactos/subsys/win32k/eng/bitblt.c +++ b/reactos/subsys/win32k/eng/bitblt.c @@ -72,9 +72,12 @@ EngBitBlt(SURFOBJ *Dest, if(Source != NULL) SourceGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Source); if(Dest != NULL) DestGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Dest); - MouseSafetyOnDrawStart(Source, SourceGDI, SourcePoint->x, SourcePoint->y, - (SourcePoint->x + abs(DestRect->right - DestRect->left)), - (SourcePoint->y + abs(DestRect->bottom - DestRect->top))); + if (Source != NULL) + { + MouseSafetyOnDrawStart(Source, SourceGDI, SourcePoint->x, SourcePoint->y, + (SourcePoint->x + abs(DestRect->right - DestRect->left)), + (SourcePoint->y + abs(DestRect->bottom - DestRect->top))); + } MouseSafetyOnDrawStart(Dest, DestGDI, DestRect->left, DestRect->top, DestRect->right, DestRect->bottom); // If we don't have to do anything special, we can punt to DrvCopyBits diff --git a/reactos/subsys/win32k/include/dce.h b/reactos/subsys/win32k/include/dce.h index 4ca0a136359..1fd417bf5cd 100644 --- a/reactos/subsys/win32k/include/dce.h +++ b/reactos/subsys/win32k/include/dce.h @@ -29,7 +29,7 @@ typedef struct tagDCE HWND hwndDC; HRGN hClipRgn; DCE_TYPE type; - DWORD DCXflags; + DWORD DCXFlags; } DCE, *PDCE; diff --git a/reactos/subsys/win32k/include/window.h b/reactos/subsys/win32k/include/window.h index 31f103ced36..6e9d1c4215c 100644 --- a/reactos/subsys/win32k/include/window.h +++ b/reactos/subsys/win32k/include/window.h @@ -74,7 +74,7 @@ typedef struct _WINDOW_OBJECT /* Pointer to the parent window. */ struct _WINDOW_OBJECT* Parent; /* DC Entries (DCE) */ - PDCE dce; + PDCE Dce; } WINDOW_OBJECT, *PWINDOW_OBJECT; /* Window flags. */ diff --git a/reactos/subsys/win32k/ntuser/class.c b/reactos/subsys/win32k/ntuser/class.c index c5e03443330..a9e431c8017 100644 --- a/reactos/subsys/win32k/ntuser/class.c +++ b/reactos/subsys/win32k/ntuser/class.c @@ -1,4 +1,4 @@ -/* $Id: class.c,v 1.10 2002/08/16 01:39:17 dwelch Exp $ +/* $Id: class.c,v 1.11 2002/09/01 20:39:56 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -18,6 +18,7 @@ #include #include #include +#include //#define NDEBUG #include @@ -267,6 +268,37 @@ NtUserRegisterClassExWOW(LPWNDCLASSEX lpwcx, DWORD STDCALL NtUserGetClassLong(HWND hWnd, DWORD Offset) { + PWINDOW_OBJECT WindowObject; + LONG Ret; + + WindowObject = W32kGetWindowObject(hWnd); + if (WindowObject == NULL) + { + return(0); + } + switch (Offset) + { + case GCL_STYLE: + Ret = WindowObject->Class->Class.style; + break; + case GCL_CBWNDEXTRA: + Ret = WindowObject->Class->Class.cbWndExtra; + break; + case GCL_CBCLSEXTRA: + Ret = WindowObject->Class->Class.cbClsExtra; + break; + case GCL_HMODULE: + Ret = WindowObject->Class->Class.hInstance; + break; + case GCL_HBRBACKGROUND: + Ret = WindowObject->Class->Class.hbrBackground; + break; + default: + Ret = 0; + break; + } + W32kReleaseWindowObject(WindowObject); + return(Ret); } DWORD STDCALL diff --git a/reactos/subsys/win32k/ntuser/metric.c b/reactos/subsys/win32k/ntuser/metric.c index 9ce097244dc..17ca998ac8d 100644 --- a/reactos/subsys/win32k/ntuser/metric.c +++ b/reactos/subsys/win32k/ntuser/metric.c @@ -1,4 +1,4 @@ -/* $Id: metric.c,v 1.2 2002/08/31 23:18:47 dwelch Exp $ +/* $Id: metric.c,v 1.3 2002/09/01 20:39:56 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -53,6 +53,8 @@ NtUserGetSystemMetrics(ULONG Index) return(17); case SM_CYHSCROLL: return(17); + case SM_CYCAPTION: + return(20); default: return(0xFFFFFFFF); } diff --git a/reactos/subsys/win32k/ntuser/windc.c b/reactos/subsys/win32k/ntuser/windc.c index 611e8b62be9..ab5930be835 100644 --- a/reactos/subsys/win32k/ntuser/windc.c +++ b/reactos/subsys/win32k/ntuser/windc.c @@ -1,4 +1,4 @@ -/* $Id: windc.c,v 1.5 2002/08/27 23:29:40 dwelch Exp $ +/* $Id: windc.c,v 1.6 2002/09/01 20:39:56 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -25,13 +25,26 @@ #define NDEBUG #include -static PDCE firstDCE; +/* GLOBALS *******************************************************************/ + +static PDCE FirstDce = NULL; + +#define DCX_CACHECOMPAREMASK (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | \ + DCX_CACHE | DCX_WINDOW | DCX_PARENTCLIP) /* FUNCTIONS *****************************************************************/ -VOID DCE_FreeWindowDCE(HWND); -INT DCE_ExcludeRgn(HDC, HWND, HRGN); -BOOL DCE_InvalidateDCE(HWND, const PRECTL); +VOID STATIC +DceOffsetVisRgn(HDC hDC, HRGN hVisRgn) +{ + DC *dc = DC_HandleToPtr(hDC); + if (dc == NULL) + { + return; + } + W32kOffsetRgn(hVisRgn, dc->w.DCOrgX, dc->w.DCOrgY); + DC_ReleasePtr(hDC); +} BOOL STATIC DceGetVisRect(PWINDOW_OBJECT Window, BOOL ClientArea, RECT* Rect) @@ -130,7 +143,7 @@ DceGetVisRgn(HWND hWnd, ULONG Flags, HWND hWndChild, ULONG CFlags) if (Window != NULL && DceGetVisRect(Window, !(Flags & DCX_WINDOW), &Rect)) { - if ((VisRgn = W32kCreateRectRgnIndirect(&Rect)) != NULL) + if ((VisRgn = UnsafeW32kCreateRectRgnIndirect(&Rect)) != NULL) { HRGN ClipRgn = W32kCreateRectRgn(0, 0, 0, 0); INT XOffset, YOffset; @@ -232,8 +245,7 @@ NtUserReleaseDC(HWND hWnd, HDC hDc) } -DWORD -STDCALL +HDC STDCALL NtUserGetDC(HWND hWnd) { if (!hWnd) @@ -241,159 +253,279 @@ NtUserGetDC(HWND hWnd) return NtUserGetDCEx(hWnd, 0, DCX_USESTYLE); } +DCE* DceAllocDCE(HWND hWnd, DCE_TYPE Type) +{ + HDCE DceHandle; + DCE* Dce; + + DceHandle = DCEOBJ_AllocDCE(); + Dce = DCEOBJ_LockDCE(DceHandle); + Dce->hDC = W32kCreateDC(L"DISPLAY", NULL, NULL, NULL); + Dce->hwndCurrent = hWnd; + Dce->hClipRgn = NULL; + Dce->next = FirstDce; + FirstDce = Dce; + + if (Type != DCE_CACHE_DC) + { + Dce->DCXFlags = DCX_DCEBUSY; + if (hWnd != NULL) + { + PWINDOW_OBJECT WindowObject; + + WindowObject = W32kGetWindowObject(hWnd); + if (WindowObject->Style & WS_CLIPCHILDREN) + { + Dce->DCXFlags |= DCX_CLIPCHILDREN; + } + if (WindowObject->Style & WS_CLIPSIBLINGS) + { + Dce->DCXFlags |= DCX_CLIPSIBLINGS; + } + W32kReleaseWindowObject(WindowObject); + } + } + else + { + Dce->DCXFlags = DCX_CACHE | DCX_DCEEMPTY; + } + + return(Dce); +} + +VOID STATIC +DceSetDrawable(PWINDOW_OBJECT WindowObject, HDC hDC, ULONG Flags, + BOOL SetClipOrigin) +{ + DC *dc = DC_HandleToPtr(hDC); + if (WindowObject == NULL) + { + dc->w.DCOrgX = 0; + dc->w.DCOrgY = 0; + } + else + { + if (Flags & DCX_WINDOW) + { + dc->w.DCOrgX = WindowObject->WindowRect.left; + dc->w.DCOrgY = WindowObject->WindowRect.top; + } + else + { + dc->w.DCOrgX = WindowObject->ClientRect.left; + dc->w.DCOrgY = WindowObject->ClientRect.top; + } + /* FIXME: Offset by parent's client rectangle. */ + } + DC_ReleasePtr(hDC); +} + HDC STDCALL NtUserGetDCEx(HWND hWnd, HANDLE hRegion, ULONG Flags) { - HDC hdc = 0; - HDCE hdce; - PDCE dce; - DWORD dcxFlags = 0; - BOOL bUpdateVisRgn = TRUE; - BOOL bUpdateClipOrigin = FALSE; - HWND parent, full; - PWINDOW_OBJECT Window; + PWINDOW_OBJECT Window; + ULONG DcxFlags; + DCE* Dce; + BOOL UpdateVisRgn = TRUE; + BOOL UpdateClipOrigin = FALSE; + HANDLE hRgnVisible = NULL; - DPRINT("hWnd %04x, hRegion %04x, Flags %08x\n", hWnd, hRegion, (unsigned)Flags); - - if (!hWnd) hWnd = W32kGetDesktopWindow(); - if (!(Window = W32kGetWindowObject(hWnd))) return 0; - - // fixup flags - - if (Flags & (DCX_WINDOW | DCX_PARENTCLIP)) Flags |= DCX_CACHE; - - if (Flags & DCX_USESTYLE) + if ((Window = W32kGetWindowObject(hWnd)) == NULL) { - Flags &= ~(DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS | DCX_PARENTCLIP); + return(0); + } - if(Window->Style & WS_CLIPSIBLINGS) - Flags |= DCX_CLIPSIBLINGS; + if (Window->Dce == NULL) + { + Flags |= DCX_CACHE; + } - if (!(Flags & DCX_WINDOW)) + if (Flags & DCX_USESTYLE) + { + Flags &= ~(DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS | DCX_PARENTCLIP); + + if (Window->Style & WS_CLIPSIBLINGS) { - if (Window->ExStyle & CS_PARENTDC) Flags |= DCX_PARENTCLIP; + Flags |= DCX_CLIPSIBLINGS; + } - if (Window->Style & WS_CLIPCHILDREN && - !(Window->Style & WS_MINIMIZE)) Flags |= DCX_CLIPCHILDREN; - if (!Window->dce) Flags |= DCX_CACHE; + if (!(Flags & DCX_WINDOW)) + { + if (Window->Class->Class.style & CS_PARENTDC) + { + Flags |= DCX_PARENTCLIP; + } + + if (Window->Style & WS_CLIPCHILDREN && + !(Window->Style & WS_MINIMIZE)) + { + Flags |= DCX_CLIPCHILDREN; + } + } + else + { + Flags |= DCX_CACHE; } } - if (Flags & DCX_WINDOW) Flags &= ~DCX_CLIPCHILDREN; - - parent = W32kGetParentWindow(hWnd); - if (!parent || (parent == W32kGetDesktopWindow())) - Flags = (Flags & ~DCX_PARENTCLIP) | DCX_CLIPSIBLINGS; - - // it seems parent clip is ignored when clipping siblings or children - if (Flags & (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN)) Flags &= ~DCX_PARENTCLIP; - - if(Flags & DCX_PARENTCLIP) + if (Flags & DCX_NOCLIPCHILDREN) { - LONG parent_style = NtUserGetWindowLong(parent, GWL_STYLE); - if((Window->Style & WS_VISIBLE) && (parent_style & WS_VISIBLE)) - { - Flags &= ~DCX_CLIPCHILDREN; - if (parent_style & WS_CLIPSIBLINGS) Flags |= DCX_CLIPSIBLINGS; - } + Flags |= DCX_CACHE; + Flags |= ~(DCX_PARENTCLIP | DCX_CLIPCHILDREN); } - // find a suitable DCE - - dcxFlags = Flags & (DCX_PARENTCLIP | DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | - DCX_CACHE | DCX_WINDOW); - - if (Flags & DCX_CACHE) + if (Flags & DCX_WINDOW) { - PDCE dceEmpty; - PDCE dceUnused; + Flags = (Flags & ~DCX_CLIPCHILDREN) | DCX_CACHE; + } - dceEmpty = dceUnused = NULL; - - /* Strategy: First, we attempt to find a non-empty but unused DCE with - * compatible flags. Next, we look for an empty entry. If the cache is - * full we have to purge one of the unused entries. - */ - - for (dce = firstDCE; (dce); dce = dce->next) + if (!(Window->Style & WS_CHILD) || Window->Parent == NULL) + { + Flags &= ~DCX_PARENTCLIP; + } + else if (Flags & DCX_PARENTCLIP) + { + Flags |= DCX_CACHE; + if (!(Flags & (DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS))) { - if ((dce->DCXflags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE) + if ((Window->Style & WS_VISIBLE) && + (Window->Parent->Style & WS_VISIBLE)) { - dceUnused = dce; - - if (dce->DCXflags & DCX_DCEEMPTY) - dceEmpty = dce; - else - if ((dce->hwndCurrent == hWnd) && - ((dce->DCXflags & (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | - DCX_CACHE | DCX_WINDOW | DCX_PARENTCLIP)) == dcxFlags)) + Flags &= ~DCX_CLIPCHILDREN; + if (Window->Parent->Style & WS_CLIPSIBLINGS) { - DPRINT("Found valid %08x dce [%04x], flags %08x\n", - (unsigned)dce, hWnd, (unsigned)dcxFlags); - bUpdateVisRgn = FALSE; - bUpdateClipOrigin = TRUE; - break; + Flags |= DCX_CLIPSIBLINGS; + } + } + } + } + + DcxFlags = Flags & DCX_CACHECOMPAREMASK; + + if (Flags & DCX_CACHE) + { + DCE* DceEmpty = NULL; + DCE* DceUnused = NULL; + + for (Dce = FirstDce; Dce != NULL; Dce = Dce->next) + { + if ((Dce->DCXFlags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE) + { + DceUnused = Dce; + if (Dce->DCXFlags & DCX_DCEEMPTY) + { + DceEmpty = Dce; + } + else if (Dce->hwndCurrent == hWnd && + ((Dce->DCXFlags & DCX_CACHECOMPAREMASK) == DcxFlags)) + { + UpdateVisRgn = FALSE; + UpdateClipOrigin = TRUE; + break; } } } - if (!dce) dce = (dceEmpty) ? dceEmpty : dceUnused; - - // if there's no dce empty or unused, allocate a new one - if (!dce) - { - hdce = DCEOBJ_AllocDCE(); - if (hdce == NULL) - { - return 0; - } - dce = DCEOBJ_LockDCE(hdce); - dce->type = DCE_CACHE_DC; - dce->hDC = W32kCreateDC(L"DISPLAY", NULL, NULL, NULL); - } - } - else - { - dce = Window->dce; - if (dce && dce->hwndCurrent == hWnd) + if (Dce == NULL) { - DPRINT("skipping hVisRgn update\n"); - bUpdateVisRgn = FALSE; // updated automatically, via DCHook() + Dce = (DceEmpty == NULL) ? DceEmpty : DceUnused; + } + + if (Dce == NULL) + { + Dce = DceAllocDCE(NULL, DCE_CACHE_DC); } } - if (!dce) + else { - hdc = 0; - goto END; + Dce = Window->Dce; + /* FIXME: Implement this. */ + DbgBreakPoint(); } - if (!(Flags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN))) hRegion = 0; - - if (((Flags ^ dce->DCXflags) & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) && - (dce->hClipRgn != hRegion)) + if (Dce == NULL) { - // if the extra clip region has changed, get rid of the old one -/* DCE_DeleteClipRgn(dce); */ + W32kReleaseWindowObject(Window); + return(NULL); } - dce->hwndCurrent = hWnd; - dce->hClipRgn = hRegion; - dce->DCXflags = Flags & (DCX_PARENTCLIP | DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | - DCX_CACHE | DCX_WINDOW | DCX_WINDOWPAINT | - DCX_KEEPCLIPRGN | DCX_INTERSECTRGN | DCX_EXCLUDERGN); - dce->DCXflags |= DCX_DCEBUSY; - dce->DCXflags &= ~DCX_DCEDIRTY; - hdc = dce->hDC; + Dce->hwndCurrent = hWnd; + Dce->hClipRgn = NULL; + Dce->DCXFlags = DcxFlags | (Flags & DCX_WINDOWPAINT) | DCX_DCEBUSY; -/* if (bUpdateVisRgn) SetHookFlags(hdc, DCHF_INVALIDATEVISRGN); // force update */ + DceSetDrawable(Window, Dce->hDC, Flags, UpdateClipOrigin); -/* if (!USER_Driver.pGetDC(hWnd, hdc, hRegion, Flags)) hdc = 0; */ + if (UpdateVisRgn) + { + if (Flags & DCX_PARENTCLIP) + { + PWINDOW_OBJECT Parent; - DPRINT("(%04x,%04x,0x%lx): returning %04x\n", hWnd, hRegion, Flags, hdc); + Parent = Window->Parent; -END: -/* WIN_ReleasePtr(Window); */ - return hdc; + if (Window->Style & WS_VISIBLE && + !(Parent->Style & WS_MINIMIZE)) + { + if (Parent->Style & WS_CLIPSIBLINGS) + { + DcxFlags = DCX_CLIPSIBLINGS | + (Flags & ~(DCX_CLIPCHILDREN | DCX_WINDOW)); + } + else + { + DcxFlags = Flags & + ~(DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_WINDOW); + } + hRgnVisible = DceGetVisRgn(Parent->Self, DcxFlags, + Window->Self, Flags); + if (Flags & DCX_WINDOW) + { + W32kOffsetRgn(hRgnVisible, -Window->WindowRect.left, + -Window->WindowRect.top); + } + else + { + W32kOffsetRgn(hRgnVisible, -Window->ClientRect.left, + -Window->ClientRect.top); + } + DceOffsetVisRgn(Dce->hDC, hRgnVisible); + } + else + { + hRgnVisible = W32kCreateRectRgn(0, 0, 0, 0); + } + } + else + { + if (hWnd == W32kGetDesktopWindow()) + { + hRgnVisible = + W32kCreateRectRgn(0, 0, + NtUserGetSystemMetrics(SM_CXSCREEN), + NtUserGetSystemMetrics(SM_CYSCREEN)); + } + else + { + hRgnVisible = DceGetVisRgn(hWnd, Flags, 0, 0); + DceOffsetVisRgn(Dce->hDC, hRgnVisible); + } + + Dce->DCXFlags &= ~DCX_DCEDIRTY; + W32kSelectVisRgn(Dce->hDC, hRgnVisible); + } + } + + if (Flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN)) + { + DPRINT1("FIXME.\n"); + } + + if (hRgnVisible != NULL) + { + W32kDeleteObject(hRgnVisible); + } + W32kReleaseWindowObject(Window); + return(Dce->hDC); } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 04d7ea9b270..3df921dc9c0 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.13 2002/08/31 23:18:47 dwelch Exp $ +/* $Id: window.c,v 1.14 2002/09/01 20:39:56 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -158,9 +158,10 @@ W32kReleaseWindowObject(PWINDOW_OBJECT Window) VOID W32kGetClientRect(PWINDOW_OBJECT WindowObject, PRECT Rect) { - Rect->left = Rect->bottom = 0; + Rect->left = Rect->top = 0; Rect->right = WindowObject->ClientRect.right - WindowObject->ClientRect.left; - Rect->top = WindowObject->ClientRect.bottom - WindowObject->ClientRect.top; + Rect->bottom = + WindowObject->ClientRect.bottom - WindowObject->ClientRect.top; } BOOL STDCALL diff --git a/reactos/subsys/win32k/objects/brush.c b/reactos/subsys/win32k/objects/brush.c index 311828bbd36..038079a3ab8 100644 --- a/reactos/subsys/win32k/objects/brush.c +++ b/reactos/subsys/win32k/objects/brush.c @@ -1,4 +1,4 @@ -/* $Id: brush.c,v 1.14 2002/07/13 21:37:26 ei Exp $ +/* $Id: brush.c,v 1.15 2002/09/01 20:39:56 dwelch Exp $ */ @@ -8,6 +8,7 @@ #include #include //#include +#include #define NDEBUG #include @@ -177,13 +178,63 @@ BOOL STDCALL W32kFixBrushOrgEx(VOID) } BOOL STDCALL W32kPatBlt(HDC hDC, - INT XLeft, - INT YLeft, - INT Width, - INT Height, - DWORD ROP) + INT XLeft, + INT YLeft, + INT Width, + INT Height, + DWORD ROP) { - UNIMPLEMENTED; + RECT DestRect; + PBRUSHOBJ BrushObj; + PSURFOBJ SurfObj; + DC *dc = DC_HandleToPtr(hDC); + BOOL ret; + + if (dc == NULL) + { + return(FALSE); + } + + SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface); + + BrushObj = (BRUSHOBJ*) GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC); + assert(BrushObj); + if (BrushObj->logbrush.lbStyle != BS_NULL) + { + if (Width > 0) + { + DestRect.left = XLeft + dc->w.DCOrgX; + DestRect.right = XLeft + Width + dc->w.DCOrgX; + } + else + { + DestRect.left = XLeft + Width + dc->w.DCOrgX; + DestRect.right = XLeft + dc->w.DCOrgX; + } + if (Height > 0) + { + DestRect.top = YLeft + dc->w.DCOrgY; + DestRect.bottom = YLeft + Height + dc->w.DCOrgY; + } + else + { + DestRect.top = YLeft + Height + dc->w.DCOrgY; + DestRect.bottom = YLeft + dc->w.DCOrgY; + } + ret = EngBitBlt(SurfObj, + NULL, + NULL, + NULL, + NULL, + &DestRect, + NULL, + NULL, + BrushObj, + NULL, + PATCOPY); + } + GDIOBJ_UnlockObj( dc->w.hBrush, GO_PEN_MAGIC ); + return(ret); } BOOL STDCALL W32kSetBrushOrgEx(HDC hDC, diff --git a/reactos/subsys/win32k/objects/cliprgn.c b/reactos/subsys/win32k/objects/cliprgn.c index 831e2ca587d..2439268ef5e 100644 --- a/reactos/subsys/win32k/objects/cliprgn.c +++ b/reactos/subsys/win32k/objects/cliprgn.c @@ -11,6 +11,25 @@ // #define NDEBUG #include +VOID +CLIPPING_UpdateGCRegion(DC* Dc) +{ + if (Dc->w.hGCClipRgn == NULL) + { + Dc->w.hGCClipRgn = W32kCreateRectRgn(0, 0, 0, 0); + } + + if (Dc->w.hClipRgn == NULL) + { + W32kCombineRgn(Dc->w.hGCClipRgn, Dc->w.hVisRgn, 0, RGN_COPY); + } + else + { + W32kCombineRgn(Dc->w.hGCClipRgn, Dc->w.hClipRgn, Dc->w.hVisRgn, + RGN_AND); + } +} + HRGN WINAPI SaveVisRgn(HDC hdc) { HRGN copy; @@ -35,7 +54,8 @@ HRGN WINAPI SaveVisRgn(HDC hdc) return copy; } -INT WINAPI SelectVisRgn(HDC hdc, HRGN hrgn) +INT WINAPI +W32kSelectVisRgn(HDC hdc, HRGN hrgn) { int retval; DC *dc; @@ -46,7 +66,7 @@ INT WINAPI SelectVisRgn(HDC hdc, HRGN hrgn) dc->w.flags &= ~DC_DIRTY; retval = W32kCombineRgn(dc->w.hVisRgn, hrgn, 0, RGN_COPY); - //ei CLIPPING_UpdateGCRegion(dc); + CLIPPING_UpdateGCRegion(dc); return retval; } @@ -74,7 +94,7 @@ int STDCALL W32kGetClipBox(HDC hDC, DC *dc; if (!(dc = DC_HandleToPtr(hDC))) return ERROR; - retval = W32kGetRgnBox(dc->w.hGCClipRgn, rc); + retval = UnsafeW32kGetRgnBox(dc->w.hGCClipRgn, rc); rc->left -= dc->w.DCOrgX; rc->right -= dc->w.DCOrgX; rc->top -= dc->w.DCOrgY; diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index a2a2d08b7df..96f4f58c8ab 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -1,4 +1,4 @@ -/* $Id: dc.c,v 1.35 2002/08/19 21:49:45 ei Exp $ +/* $Id: dc.c,v 1.36 2002/09/01 20:39:56 dwelch Exp $ * * DC.C - Device context functions * @@ -307,7 +307,8 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver, /* Initialize the DC state */ DC_InitDC(hNewDC); - W32kSetTextColor(hNewDC, RGB(0xff, 0xff, 0xff)); + NewDC->w.hVisRgn = W32kCreateRectRgn(0, 0, 640, 480); + W32kSetTextColor(hNewDC, RGB(0, 0, 0)); W32kSetTextAlign(hNewDC, TA_BASELINE); DC_ReleasePtr( hNewDC ); return hNewDC; @@ -940,7 +941,8 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj) if( PalGDI ){ XlateObj = (PXLATEOBJ)EngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL); brush = GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC); - brush->iSolidColor = XLATEOBJ_iXlate(XlateObj, brush->iSolidColor); + brush->iSolidColor = XLATEOBJ_iXlate(XlateObj, + brush->logbrush.lbColor); GDIOBJ_UnlockObj( dc->w.hBrush, GO_BRUSH_MAGIC); } break; @@ -1150,6 +1152,16 @@ HDC DC_AllocDC(LPCWSTR Driver) wcscpy(NewDC->DriverName, Driver); } + NewDC->w.xformWorld2Wnd.eM11 = 1.0f; + NewDC->w.xformWorld2Wnd.eM12 = 0.0f; + NewDC->w.xformWorld2Wnd.eM21 = 0.0f; + NewDC->w.xformWorld2Wnd.eM22 = 1.0f; + NewDC->w.xformWorld2Wnd.eDx = 0.0f; + NewDC->w.xformWorld2Wnd.eDy = 0.0f; + NewDC->w.xformWorld2Vport = NewDC->w.xformWorld2Wnd; + NewDC->w.xformVport2World = NewDC->w.xformWorld2Wnd; + NewDC->w.vport2WorldValid = TRUE; + GDIOBJ_UnlockObj( hDC, GO_DC_MAGIC ); return hDC; } diff --git a/reactos/subsys/win32k/objects/fillshap.c b/reactos/subsys/win32k/objects/fillshap.c index df72e91da22..a7f10517dc0 100644 --- a/reactos/subsys/win32k/objects/fillshap.c +++ b/reactos/subsys/win32k/objects/fillshap.c @@ -5,6 +5,7 @@ #include #include #include +#include // #define NDEBUG #include @@ -78,11 +79,12 @@ W32kRectangle(HDC hDC, int BottomRect) { DC *dc = DC_HandleToPtr(hDC); - SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject(dc->Surface); + SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface); PBRUSHOBJ BrushObj; BOOL ret; PRECTL RectBounds; PENOBJ * pen; + RECTL DestRect; if(!dc) return FALSE; @@ -94,10 +96,15 @@ W32kRectangle(HDC hDC, ret = PATH_Rectangle(hDC, LeftRect, TopRect, RightRect, BottomRect); } else { // Draw the rectangle with the current pen - pen = (PENOBJ*) GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC); - ASSERT(pen); - BrushObj = (PBRUSHOBJ)PenToBrushObj(dc, pen); - GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC ); + pen = (PENOBJ*) GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC); + ASSERT(pen); + BrushObj = (PBRUSHOBJ)PenToBrushObj(dc, pen); + GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC ); + + LeftRect += dc->w.DCOrgX; + RightRect += dc->w.DCOrgX; + TopRect += dc->w.DCOrgY; + BottomRect += dc->w.DCOrgY; ret = EngLineTo(SurfObj, NULL, // ClipObj, @@ -127,7 +134,27 @@ W32kRectangle(HDC hDC, RectBounds, // Bounding rectangle dc->w.ROPmode); // MIX */ - ExFreePool(BrushObj); + BrushObj = (BRUSHOBJ*) GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC); + assert(BrushObj); + if (BrushObj->logbrush.lbStyle != BS_NULL) + { + DestRect.left = LeftRect + 1; + DestRect.right = RightRect - 1; + DestRect.top = TopRect + 1; + DestRect.bottom = BottomRect - 1; + ret = EngBitBlt(SurfObj, + NULL, + NULL, + NULL, + NULL, + &DestRect, + NULL, + NULL, + BrushObj, + NULL, + PATCOPY); + } + GDIOBJ_UnlockObj( dc->w.hBrush, GO_PEN_MAGIC ); } // FIXME: Move current position in DC? diff --git a/reactos/subsys/win32k/objects/gdiobj.c b/reactos/subsys/win32k/objects/gdiobj.c index 4895c840cb6..1028c2746ec 100644 --- a/reactos/subsys/win32k/objects/gdiobj.c +++ b/reactos/subsys/win32k/objects/gdiobj.c @@ -1,7 +1,7 @@ /* * GDIOBJ.C - GDI object manipulation routines * - * $Id: gdiobj.c,v 1.15 2002/08/04 18:21:59 ei Exp $ + * $Id: gdiobj.c,v 1.16 2002/09/01 20:39:56 dwelch Exp $ * */ @@ -252,7 +252,8 @@ PGDIOBJ GDIOBJ_LockObj( HGDIOBJ hObj, WORD Magic ) DPRINT("GDIOBJ_LockObj: hObj: %d, magic: %x, \n handleEntry: %x, mag %x\n", hObj, Magic, handleEntry, handleEntry->wMagic); if (handleEntry == 0 || (handleEntry->wMagic != Magic && handleEntry->wMagic != GO_MAGIC_DONTCARE ) - || handleEntry->hProcessId != PsGetCurrentProcessId () ) + || (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF && + handleEntry->hProcessId != PsGetCurrentProcessId ())) return NULL; objectHeader = (PGDIOBJHDR) handleEntry->pObject; @@ -273,7 +274,8 @@ BOOL GDIOBJ_UnlockObj( HGDIOBJ hObj, WORD Magic ) DPRINT("GDIOBJ_UnlockObj: hObj: %d, magic: %x, \n handleEntry: %x\n", hObj, Magic, handleEntry); if (handleEntry == 0 || (handleEntry->wMagic != Magic && handleEntry->wMagic != GO_MAGIC_DONTCARE ) - || handleEntry->hProcessId != PsGetCurrentProcessId ()) + || (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF && + handleEntry->hProcessId != PsGetCurrentProcessId ())) return FALSE; objectHeader = (PGDIOBJHDR) handleEntry->pObject; @@ -375,6 +377,20 @@ PGDIOBJ GDIOBJ_HandleToPtr (HGDIOBJ ObjectHandle, WORD Magic) } */ +VOID GDIOBJ_MarkObjectGlobal(HGDIOBJ ObjectHandle) +{ + PGDI_HANDLE_ENTRY handleEntry; + + if (ObjectHandle == NULL) + return; + + handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD)ObjectHandle & 0xffff); + if (handleEntry == 0) + return; + + handleEntry->hProcessId = (HANDLE)0xFFFFFFFF; +} + WORD GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle) { PGDI_HANDLE_ENTRY handleEntry; @@ -384,7 +400,8 @@ WORD GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle) handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD)ObjectHandle & 0xffff); if (handleEntry == 0 || - handleEntry->hProcessId != PsGetCurrentProcessId ()) + (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF && + handleEntry->hProcessId != PsGetCurrentProcessId ())) return 0; return handleEntry->wMagic; @@ -409,22 +426,38 @@ VOID CreateStockObjects(void) // Create GDI Stock Objects from the logical structures we've defined StockObjects[WHITE_BRUSH] = W32kCreateBrushIndirect(&WhiteBrush); + GDIOBJ_MarkObjectGlobal(StockObjects[WHITE_BRUSH]); StockObjects[LTGRAY_BRUSH] = W32kCreateBrushIndirect(&LtGrayBrush); + GDIOBJ_MarkObjectGlobal(StockObjects[LTGRAY_BRUSH]); StockObjects[GRAY_BRUSH] = W32kCreateBrushIndirect(&GrayBrush); + GDIOBJ_MarkObjectGlobal(StockObjects[GRAY_BRUSH]); StockObjects[DKGRAY_BRUSH] = W32kCreateBrushIndirect(&DkGrayBrush); + GDIOBJ_MarkObjectGlobal(StockObjects[DKGRAY_BRUSH]); StockObjects[BLACK_BRUSH] = W32kCreateBrushIndirect(&BlackBrush); + GDIOBJ_MarkObjectGlobal(StockObjects[BLACK_BRUSH]); StockObjects[NULL_BRUSH] = W32kCreateBrushIndirect(&NullBrush); + GDIOBJ_MarkObjectGlobal(StockObjects[NULL_BRUSH]); StockObjects[WHITE_PEN] = W32kCreatePenIndirect(&WhitePen); + GDIOBJ_MarkObjectGlobal(StockObjects[WHITE_PEN]); StockObjects[BLACK_PEN] = W32kCreatePenIndirect(&BlackPen); + GDIOBJ_MarkObjectGlobal(StockObjects[BLACK_PEN]); StockObjects[NULL_PEN] = W32kCreatePenIndirect(&NullPen); + GDIOBJ_MarkObjectGlobal(StockObjects[NULL_PEN]); StockObjects[OEM_FIXED_FONT] = W32kCreateFontIndirect(&OEMFixedFont); + GDIOBJ_MarkObjectGlobal(StockObjects[OEM_FIXED_FONT]); StockObjects[ANSI_FIXED_FONT] = W32kCreateFontIndirect(&AnsiFixedFont); + GDIOBJ_MarkObjectGlobal(StockObjects[ANSI_FIXED_FONT]); StockObjects[SYSTEM_FONT] = W32kCreateFontIndirect(&SystemFont); - StockObjects[DEVICE_DEFAULT_FONT] = W32kCreateFontIndirect(&DeviceDefaultFont); + GDIOBJ_MarkObjectGlobal(StockObjects[SYSTEM_FONT]); + StockObjects[DEVICE_DEFAULT_FONT] = + W32kCreateFontIndirect(&DeviceDefaultFont); + GDIOBJ_MarkObjectGlobal(StockObjects[DEVICE_DEFAULT_FONT]); StockObjects[SYSTEM_FIXED_FONT] = W32kCreateFontIndirect(&SystemFixedFont); + GDIOBJ_MarkObjectGlobal(StockObjects[SYSTEM_FIXED_FONT]); StockObjects[DEFAULT_GUI_FONT] = W32kCreateFontIndirect(&DefaultGuiFont); + GDIOBJ_MarkObjectGlobal(StockObjects[DEFAULT_GUI_FONT]); StockObjects[DEFAULT_PALETTE] = (HGDIOBJ*)PALETTE_Init(); } diff --git a/reactos/subsys/win32k/objects/rect.c b/reactos/subsys/win32k/objects/rect.c index b6ff9b0a49d..3c88969c160 100644 --- a/reactos/subsys/win32k/objects/rect.c +++ b/reactos/subsys/win32k/objects/rect.c @@ -88,6 +88,6 @@ W32kIntersectRect(PRECT Dest, const RECT* Src1, const RECT* Src2) Dest->left = max(Src1->left, Src2->left); Dest->right = min(Src1->right, Src2->right); Dest->top = max(Src1->top, Src2->top); - Dest->bottom = min(Src1->right, Src2->right); + Dest->bottom = min(Src1->bottom, Src2->bottom); return(TRUE); } diff --git a/reactos/subsys/win32k/objects/region.c b/reactos/subsys/win32k/objects/region.c index 992e9eef89a..dc4959a64b6 100644 --- a/reactos/subsys/win32k/objects/region.c +++ b/reactos/subsys/win32k/objects/region.c @@ -1682,29 +1682,47 @@ W32kFrameRgn(HDC hDC, UNIMPLEMENTED; } - -INT -STDCALL -W32kGetRgnBox(HRGN hRgn, - LPRECT pRect) +INT STDCALL +UnsafeW32kGetRgnBox(HRGN hRgn, + LPRECT pRect) { PROSRGNDATA rgn = RGNDATA_LockRgn(hRgn); DWORD ret; - if( rgn ){ - RECT SafeRect; - SafeRect.left = rgn->rdh.rcBound.left; - SafeRect.top = rgn->rdh.rcBound.top; - SafeRect.right = rgn->rdh.rcBound.right; - SafeRect.bottom = rgn->rdh.rcBound.bottom; - ret = rgn->rdh.iType; - RGNDATA_UnlockRgn( hRgn ); + if (rgn) + { + *pRect = rgn->rdh.rcBound; + ret = rgn->rdh.iType; + RGNDATA_UnlockRgn( hRgn ); + + return ret; + } + return 0; //if invalid region return zero +} - if(!NT_SUCCESS(MmCopyToCaller(pRect, &SafeRect, sizeof(RECT)))) - return 0; - return ret; - } +INT STDCALL +W32kGetRgnBox(HRGN hRgn, + LPRECT pRect) +{ + PROSRGNDATA rgn = RGNDATA_LockRgn(hRgn); + DWORD ret; + + if (rgn) + { + RECT SafeRect; + SafeRect.left = rgn->rdh.rcBound.left; + SafeRect.top = rgn->rdh.rcBound.top; + SafeRect.right = rgn->rdh.rcBound.right; + SafeRect.bottom = rgn->rdh.rcBound.bottom; + ret = rgn->rdh.iType; + RGNDATA_UnlockRgn( hRgn ); + + if(!NT_SUCCESS(MmCopyToCaller(pRect, &SafeRect, sizeof(RECT)))) + return 0; + + return ret; + } return 0; //if invalid region return zero } diff --git a/reactos/subsys/win32k/objects/text.c b/reactos/subsys/win32k/objects/text.c index de4a959ff00..a50faaa5cc5 100644 --- a/reactos/subsys/win32k/objects/text.c +++ b/reactos/subsys/win32k/objects/text.c @@ -580,7 +580,7 @@ W32kTextOut(HDC hDC, int error, glyph_index, n, load_flags = FT_LOAD_RENDER, i, j, sx, sy, scc; FT_Face face; FT_GlyphSlot glyph; - ULONG TextLeft = XStart, TextTop = YStart, SpaceBetweenChars = 2, pitch, previous; + ULONG TextLeft, TextTop, SpaceBetweenChars = 2, pitch, previous; FT_Bool use_kerning; RECTL DestRect, MaskRect; POINTL SourcePoint, BrushOrigin; @@ -601,6 +601,11 @@ W32kTextOut(HDC hDC, if( !dc ) return FALSE; + XStart += dc->w.DCOrgX; + YStart += dc->w.DCOrgY; + TextLeft = XStart; + TextTop = YStart; + TextObj = TEXTOBJ_LockText(dc->w.hFont); for(i=0; i