Commit in reactos on win32k_user_rewrite
include/napi/win32.h+2-21.18 -> 1.18.14.1
include/win32k/bitmaps.h+4-41.24 -> 1.24.6.1
              /brush.h+4-31.16 -> 1.16.4.1
              /dc.h+3-31.37 -> 1.37.4.1
              /gdiobj.h+43-231.24 -> 1.24.6.1
              /pen.h+3-31.9 -> 1.9.16.1
              /region.h+3-31.23 -> 1.23.6.1
              /text.h+4-41.21 -> 1.21.16.1
lib/user32/include/user32.h+25-91.29 -> 1.29.4.1
                  /window.h+27-41.10 -> 1.10.16.1
lib/user32/misc/dllmain.c+11.43 -> 1.43.4.1
               /stubs.c+1-161.65 -> 1.65.4.1
lib/user32/windows/defwnd.c+73-1461.144 -> 1.144.4.1
+193-220
13 modified files
rewrote the gdi handle table that behaves similar 2k/XP and works without global locks (part 2)

reactos/include/napi
win32.h 1.18 -> 1.18.14.1
diff -u -r1.18 -r1.18.14.1
--- win32.h	22 May 2004 21:12:14 -0000	1.18
+++ win32.h	12 Sep 2004 21:23:24 -0000	1.18.14.1
@@ -34,8 +34,8 @@
   struct _WINSTATION_OBJECT* WindowStation;
   HANDLE hWindowStation;
   ULONG Flags;
-  WORD GDIObjects;
-  WORD UserObjects;
+  LONG GDIObjects;
+  LONG UserObjects;
 } W32PROCESS, *PW32PROCESS;
 
 PW32THREAD STDCALL

reactos/include/win32k
bitmaps.h 1.24 -> 1.24.6.1
diff -u -r1.24 -r1.24.6.1
--- bitmaps.h	3 Jul 2004 13:55:35 -0000	1.24
+++ bitmaps.h	12 Sep 2004 21:23:25 -0000	1.24.6.1
@@ -26,11 +26,11 @@
 /*  Internal interface  */
 
 #define  BITMAPOBJ_AllocBitmap()  \
-  ((HBITMAP) GDIOBJ_AllocObj (sizeof (BITMAPOBJ), GDI_OBJECT_TYPE_BITMAP, (GDICLEANUPPROC) Bitmap_InternalDelete))
+  ((HBITMAP) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BITMAP))
 #define  BITMAPOBJ_FreeBitmap(hBMObj)  \
-  GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP, GDIOBJFLAG_DEFAULT)
+  GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
 #define  BITMAPOBJ_LockBitmap(hBMObj) GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
-#define  BITMAPOBJ_UnlockBitmap(hBMObj) GDIOBJ_UnlockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
+#define  BITMAPOBJ_UnlockBitmap(BMObj) GDIOBJ_UnlockObj((PGDIOBJ) BMObj)
 
 INT     FASTCALL BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp);
 HBITMAP FASTCALL BITMAPOBJ_CopyBitmap (HBITMAP  hBitmap);
@@ -38,7 +38,7 @@
 int     STDCALL  DIB_GetDIBImageBytes (INT  width, INT  height, INT  depth);
 INT     FASTCALL DIB_BitmapInfoSize (const BITMAPINFO * info, WORD coloruse);
 INT     STDCALL  BITMAP_GetObject(BITMAPOBJ * bmp, INT count, LPVOID buffer);
-BOOL    FASTCALL Bitmap_InternalDelete( PBITMAPOBJ pBmp );
+BOOL    FASTCALL BITMAP_Cleanup(PBITMAPOBJ pBmp);
 HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice);
 
 HBITMAP FASTCALL IntCreateCompatibleBitmap(PDC Dc, INT Width, INT Height);

reactos/include/win32k
brush.h 1.16 -> 1.16.4.1
diff -u -r1.16 -r1.16.4.1
--- brush.h	14 Jul 2004 20:48:56 -0000	1.16
+++ brush.h	12 Sep 2004 21:23:25 -0000	1.16.4.1
@@ -68,10 +68,11 @@
 #define GDIBRUSH_IS_MASKING		0x8000 /* Pattern bitmap is used as transparent mask (?) */
 #define GDIBRUSH_CACHED_IS_SOLID	0x80000000 
 
-#define  BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (sizeof(GDIBRUSHOBJ), GDI_OBJECT_TYPE_BRUSH, (GDICLEANUPPROC) Brush_InternalDelete))
-#define  BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH, GDIOBJFLAG_DEFAULT)
+#define  BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BRUSH))
+#define  BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)
 #define  BRUSHOBJ_LockBrush(hBrush) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH))
-#define  BRUSHOBJ_UnlockBrush(hBrush) GDIOBJ_UnlockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)
+#define  BRUSHOBJ_UnlockBrush(BrushObj) GDIOBJ_UnlockObj((PGDIOBJ)BrushObj)
+BOOL FASTCALL BRUSH_Cleanup(PGDIBRUSHOBJ pBrush);
 
 #ifdef __USE_W32API
 typedef struct _PATRECT {

reactos/include/win32k
dc.h 1.37 -> 1.37.4.1
diff -u -r1.37 -r1.37.4.1
--- dc.h	14 Jul 2004 20:48:56 -0000	1.37
+++ dc.h	12 Sep 2004 21:23:25 -0000	1.37.4.1
@@ -140,8 +140,8 @@
 
 #define  DC_LockDc(hDC)  \
   ((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC))
-#define  DC_UnlockDc(hDC)  \
-  GDIOBJ_UnlockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC)
+#define  DC_UnlockDc(DC)  \
+  GDIOBJ_UnlockObj ((PGDIOBJ) DC)
 
 HDC  FASTCALL RetrieveDisplayHDC(VOID);
 HDC  FASTCALL DC_AllocDC(PUNICODE_STRING  Driver);
@@ -150,7 +150,7 @@
 VOID FASTCALL DC_FreeDC(HDC  DCToFree);
 HDC  FASTCALL DC_GetNextDC (PDC pDC);
 VOID FASTCALL DC_SetNextDC (PDC pDC, HDC hNextDC);
-BOOL FASTCALL DC_InternalDeleteDC( PDC DCToDelete );
+BOOL FASTCALL DC_Cleanup(PDC pDc);
 VOID FASTCALL DC_SetOwnership(HDC DC, PEPROCESS Owner);
 
 VOID FASTCALL DC_UpdateXforms(PDC  dc);

reactos/include/win32k
gdiobj.h 1.24 -> 1.24.6.1
diff -u -r1.24 -r1.24.6.1
--- gdiobj.h	4 Jul 2004 12:00:37 -0000	1.24
+++ gdiobj.h	12 Sep 2004 21:23:25 -0000	1.24.6.1
@@ -8,6 +8,26 @@
 
 #include <ddk/ntddk.h>
 
+/* base address where the handle table is mapped to */
+#define GDI_HANDLE_TABLE_BASE_ADDRESS (0x400000)
+
+/* gdi handle table can hold 0x4000 handles */
+#define GDI_HANDLE_COUNT 0x4000
+
+#define GDI_GLOBAL_PROCESS (0x0)
+
+#define GDI_HANDLE_INDEX_MASK (GDI_HANDLE_COUNT - 1)
+#define GDI_HANDLE_TYPE_MASK  0x007f0000
+#define GDI_HANDLE_STOCK_MASK 0x00800000
+
+#define GDI_HANDLE_CREATE(i, t)    ((HANDLE)(((i) & GDI_HANDLE_INDEX_MASK) | ((t) & GDI_HANDLE_TYPE_MASK)))
+#define GDI_HANDLE_GET_INDEX(h)    (((DWORD)(h)) & GDI_HANDLE_INDEX_MASK)
+#define GDI_HANDLE_GET_TYPE(h)     (((DWORD)(h)) & GDI_HANDLE_TYPE_MASK)
+#define GDI_HANDLE_IS_TYPE(h, t)   ((t) == (((DWORD)(h)) & GDI_HANDLE_TYPE_MASK))
+#define GDI_HANDLE_IS_STOCKOBJ(h)  (0 != (((DWORD)(h)) & GDI_HANDLE_STOCK_MASK))
+#define GDI_HANDLE_SET_STOCKOBJ(h) ((h) = (HANDLE)(((DWORD)(h)) | GDI_HANDLE_STOCK_MASK))
+
+
 /*! \defgroup GDI object types
  *
  *  GDI object types
@@ -37,26 +57,18 @@
 
 typedef BOOL (FASTCALL *GDICLEANUPPROC)(PGDIOBJ Obj);
 
-#define GDIOBJ_USE_FASTMUTEX
-
 /*!
  * GDI object header. This is a part of any GDI object
 */
 typedef struct _GDIOBJHDR
 {
-  DWORD dwCount; 		/* reference count for the object */
-  HANDLE hProcessId;
-  GDICLEANUPPROC CleanupProc;
-  WORD wTableIndex;
-  WORD Magic;
+  LONG RefCount; /* reference count for the object */
+  struct _W32THREAD *LockingThread; /* only assigned if a thread is holding the lock! */
+  ULONG Type;
+  PPAGED_LOOKASIDE_LIST LookasideList; /* FIXME - remove this */
+#ifdef GDI_DEBUG
   const char* lockfile;
   int lockline;
-#ifdef GDIOBJ_USE_FASTMUTEX
-  FAST_MUTEX Lock;
-  DWORD RecursiveLockCount;
-#else
-  DWORD LockTid;
-  DWORD LockCount;
 #endif
 } GDIOBJHDR, *PGDIOBJHDR;
 
@@ -67,32 +79,40 @@
   DWORD	ObjectType;
 } GDIMULTILOCK, *PGDIMULTILOCK;
 
-HGDIOBJ FASTCALL GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProcPtr);
-BOOL    STDCALL  GDIOBJ_FreeObj (HGDIOBJ Obj, DWORD ObjectType, DWORD Flag);
+HGDIOBJ FASTCALL GDIOBJ_AllocObj(ULONG ObjectType);
+BOOL    FASTCALL GDIOBJ_FreeObj (HGDIOBJ Obj, DWORD ObjectType);
 PGDIOBJ FASTCALL GDIOBJ_LockObj (HGDIOBJ Obj, DWORD ObjectType);
 BOOL    FASTCALL GDIOBJ_LockMultipleObj(PGDIMULTILOCK pList, INT nObj);
-BOOL    FASTCALL GDIOBJ_UnlockObj (HGDIOBJ Obj, DWORD ObjectType);
 BOOL    FASTCALL GDIOBJ_UnlockMultipleObj(PGDIMULTILOCK pList, INT nObj);
-DWORD   FASTCALL GDIOBJ_GetObjectType(HGDIOBJ ObjectHandle);
 BOOL    FASTCALL GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle);
 void    FASTCALL GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS Owner);
 void    FASTCALL GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo);
+BOOL    FASTCALL GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj);
 BOOL    FASTCALL GDIOBJ_LockMultipleObj(PGDIMULTILOCK pList, INT nObj);
 
+#define GDIOBJ_GetObjectType(Handle) \
+  GDI_HANDLE_GET_TYPE(Handle)
+
+#ifdef GDI_DEBUG
+
 /* a couple macros for debugging GDIOBJ locking */
 #define GDIOBJ_LockObj(obj,ty) GDIOBJ_LockObjDbg(__FILE__,__LINE__,obj,ty)
-#define GDIOBJ_UnlockObj(obj,ty) GDIOBJ_UnlockObjDbg(__FILE__,__LINE__,obj,ty)
+#define GDIOBJ_UnlockObj(obj) GDIOBJ_UnlockObjDbg(__FILE__,__LINE__,obj)
 
-#ifdef GDIOBJ_LockObj
 PGDIOBJ FASTCALL GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ Obj, DWORD ObjectType);
-#endif /* GDIOBJ_LockObj */
+BOOL FASTCALL GDIOBJ_UnlockObjDbg (const char* file, int line, PGDIOBJ Object);
+
+#else /* !GDI_DEBUG */
 
-#ifdef GDIOBJ_UnlockObj
-BOOL FASTCALL GDIOBJ_UnlockObjDbg (const char* file, int line, HGDIOBJ Obj, DWORD ObjectType);
-#endif /* GDIOBJ_UnlockObj */
+PGDIOBJ FASTCALL GDIOBJ_LockObj (HGDIOBJ Obj, DWORD ObjectType);
+BOOL    FASTCALL GDIOBJ_UnlockObj (PGDIOBJ Object);
+
+#endif /* GDI_DEBUG */
 
 #define GDIOBJFLAG_DEFAULT	(0x0)
 #define GDIOBJFLAG_IGNOREPID 	(0x1)
 #define GDIOBJFLAG_IGNORELOCK 	(0x2)
 
+PVOID   FASTCALL GDI_MapHandleTable(HANDLE hProcess);
+
 #endif

reactos/include/win32k
pen.h 1.9 -> 1.9.16.1
diff -u -r1.9 -r1.9.16.1
--- pen.h	5 Apr 2004 21:26:24 -0000	1.9
+++ pen.h	12 Sep 2004 21:23:25 -0000	1.9.16.1
@@ -6,10 +6,10 @@
 
 /* Internal interface */
 
-#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(sizeof(GDIBRUSHOBJ), GDI_OBJECT_TYPE_PEN, NULL))
-#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN, GDIOBJFLAG_DEFAULT)
+#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PEN))
+#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)
 #define PENOBJ_LockPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN))
-#define PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)
+#define PENOBJ_UnlockPen(BMObj) GDIOBJ_UnlockObj((PGDIOBJ) BMObj)
 
 HPEN STDCALL
 NtGdiCreatePen(

reactos/include/win32k
region.h 1.23 -> 1.23.6.1
diff -u -r1.23 -r1.23.6.1
--- region.h	28 Jun 2004 21:03:08 -0000	1.23
+++ region.h	12 Sep 2004 21:23:25 -0000	1.23.6.1
@@ -11,12 +11,12 @@
 } ROSRGNDATA, *PROSRGNDATA, *LPROSRGNDATA;
 
 
-#define  RGNDATA_FreeRgn(hRgn)  GDIOBJ_FreeObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION, GDIOBJFLAG_DEFAULT)
+#define  RGNDATA_FreeRgn(hRgn)  GDIOBJ_FreeObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)
 #define  RGNDATA_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION))
-#define  RGNDATA_UnlockRgn(hRgn) GDIOBJ_UnlockObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)
+#define  RGNDATA_UnlockRgn(Rgn) GDIOBJ_UnlockObj((PGDIOBJ)Rgn)
 HRGN FASTCALL RGNDATA_AllocRgn(INT n);
 
-BOOL FASTCALL RGNDATA_InternalDelete( PROSRGNDATA Obj );
+BOOL FASTCALL RGNDATA_Cleanup(PROSRGNDATA pRgn);
 
 /*  User entry points */
 HRGN STDCALL

reactos/include/win32k
text.h 1.21 -> 1.21.16.1
diff -u -r1.21 -r1.21.16.1
--- text.h	23 Mar 2004 07:59:47 -0000	1.21
+++ text.h	12 Sep 2004 21:23:25 -0000	1.21.16.1
@@ -6,16 +6,16 @@
 typedef struct
 {
    LOGFONTW   logfont;
-   HFONT      GDIFontHandle;
+   FONTOBJ    *Font;
 } TEXTOBJ, *PTEXTOBJ;
 
 /*  Internal interface  */
 
 #define  TEXTOBJ_AllocText() \
-  ((HFONT) GDIOBJ_AllocObj (sizeof (TEXTOBJ), GDI_OBJECT_TYPE_FONT, NULL))
-#define  TEXTOBJ_FreeText(hBMObj)  GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT, GDIOBJFLAG_DEFAULT)
+  ((HFONT) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_FONT))
+#define  TEXTOBJ_FreeText(hBMObj)  GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT)
 #define  TEXTOBJ_LockText(hBMObj) ((PTEXTOBJ) GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT))
-#define  TEXTOBJ_UnlockText(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT)
+#define  TEXTOBJ_UnlockText(BMObj) GDIOBJ_UnlockObj ((PGDIOBJ) BMObj)
 
 NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle);
 NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont);

reactos/lib/user32/include
user32.h 1.29 -> 1.29.4.1
diff -u -r1.29 -r1.29.4.1
--- user32.h	15 Aug 2004 21:36:27 -0000	1.29
+++ user32.h	12 Sep 2004 21:23:25 -0000	1.29.4.1
@@ -30,10 +30,22 @@
   BYTE Showing;
 } THRDCARETINFO, *PTHRDCARETINFO;
 
+void InitStockObjects(void);
 VOID CreateFrameBrushes(VOID);
 VOID DeleteFrameBrushes(VOID);
 void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo);
 
+LONG WINAPI RegCloseKey(HKEY);
+LONG WINAPI RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY);
+LONG WINAPI RegQueryValueExW(HKEY,LPCWSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
+
+#ifdef __USE_W32API
+NTSTATUS STDCALL ZwCallbackReturn(PVOID Result,
+				  ULONG ResultLength,
+				  NTSTATUS Status);
+#endif
+
+
 #define NtUserAnyPopup() \
   (BOOL)NtUserCallNoParam(NOPARAM_ROUTINE_ANYPOPUP)
 
@@ -61,6 +73,19 @@
 #define NtUserRegisterLogonProcess(hproc, x) \
   (BOOL)NtUserCallTwoParam((DWORD)hproc, (DWORD)x, TWOPARAM_ROUTINE_REGISTERLOGONPROC)
 
+#define NtUserGetSysColorBrushes(HBrushes, count) \
+  (BOOL)NtUserCallTwoParam((DWORD)(HBrushes), (DWORD)(count), TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES)
+
+#define NtUserGetSysColorPens(HPens, count) \
+  (BOOL)NtUserCallTwoParam((DWORD)(HPens), (DWORD)(count), TWOPARAM_ROUTINE_GETSYSCOLORPENS)
+
+#define NtUserGetSysColors(ColorRefs, count) \
+  (BOOL)NtUserCallTwoParam((DWORD)(ColorRefs), (DWORD)(count), TWOPARAM_ROUTINE_GETSYSCOLORS)
+
+#define NtUserSetSysColors(ColorRefs, count) \
+  (BOOL)NtUserCallTwoParam((DWORD)(ColorRefs), (DWORD)(count), TWOPARAM_ROUTINE_SETSYSCOLORS)
+
+
 #define NtUserSetCaretBlinkTime(uMSeconds) \
   (BOOL)NtUserCallOneParam((DWORD)uMSeconds, ONEPARAM_ROUTINE_SETCARETBLINKTIME)
 
@@ -100,12 +125,3 @@
 #define NtUserEnableProcessWindowGhosting(bEnable) \
   NtUserCallOneParam((DWORD)bEnable, ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING)
 
-LONG WINAPI RegCloseKey(HKEY);
-LONG WINAPI RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY);
-LONG WINAPI RegQueryValueExW(HKEY,LPCWSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
-
-#ifdef __USE_W32API
-NTSTATUS STDCALL ZwCallbackReturn(PVOID Result,
-				  ULONG ResultLength,
-				  NTSTATUS Status);
-#endif

reactos/lib/user32/include
window.h 1.10 -> 1.10.16.1
diff -u -r1.10 -r1.10.16.1
--- window.h	15 Mar 2004 23:49:28 -0000	1.10
+++ window.h	12 Sep 2004 21:23:25 -0000	1.10.16.1
@@ -7,14 +7,37 @@
 #include <windows.h>
 #include <user32/wininternal.h>
 
+extern COLORREF SysColors[];
+extern HPEN SysPens[];
+extern HBRUSH SysBrushes[];
+
+#define NUM_SYSCOLORS 31
+
 #define IS_ATOM(x) \
   (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
 
+#define UserHasAnyFrameStyle(Style, ExStyle)                                   \
+  (((Style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) ||                    \
+   ((ExStyle) & WS_EX_DLGMODALFRAME) ||                                        \
+   (!((Style) & (WS_CHILD | WS_POPUP))))
+
+#define UserHasDlgFrameStyle(Style, ExStyle)                                   \
+ (((ExStyle) & WS_EX_DLGMODALFRAME) ||                                         \
+  (((Style) & WS_DLGFRAME) && (!((Style) & WS_THICKFRAME))))
+
+#define UserHasThickFrameStyle(Style, ExStyle)                                 \
+  (((Style) & WS_THICKFRAME) &&                                                \
+   (!(((Style) & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)))
+
+#define UserHasThinFrameStyle(Style, ExStyle)                                  \
+  (((Style) & WS_BORDER) || (!((Style) & (WS_CHILD | WS_POPUP))))
+
+#define UserHasBigFrameStyle(Style, ExStyle)                                   \
+  (((Style) & (WS_THICKFRAME | WS_DLGFRAME)) ||                                \
+   ((ExStyle) & WS_EX_DLGMODALFRAME))
+
+
 BOOL UserDrawSysMenuButton( HWND hWnd, HDC hDC, LPRECT, BOOL down );
-ULONG
-UserHasDlgFrameStyle(ULONG Style, ULONG ExStyle);
-ULONG
-UserHasThickFrameStyle(ULONG Style, ULONG ExStyle);
 void
 UserGetFrameSize(ULONG Style, ULONG ExStyle, SIZE *Size);
 void

reactos/lib/user32/misc
dllmain.c 1.43 -> 1.43.4.1
diff -u -r1.43 -r1.43.4.1
--- dllmain.c	16 Aug 2004 17:28:46 -0000	1.43
+++ dllmain.c	12 Sep 2004 21:23:25 -0000	1.43.4.1
@@ -76,6 +76,7 @@
   InitializeCriticalSection(&gcsMPH);
 
   GdiDllInitialize(NULL, DLL_PROCESS_ATTACH, NULL);
+  InitStockObjects();
 }
 
 VOID

reactos/lib/user32/misc
stubs.c 1.65 -> 1.65.4.1
diff -u -r1.65 -r1.65.4.1
--- stubs.c	15 Aug 2004 21:36:28 -0000	1.65
+++ stubs.c	12 Sep 2004 21:23:25 -0000	1.65.4.1
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.65 2004/08/15 21:36:28 chorns Exp $
+/* $Id: stubs.c,v 1.65.4.1 2004/09/12 21:23:25 weiden Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS user32.dll
@@ -190,21 +190,6 @@
  */
 BOOL
 STDCALL
-SetSysColors(
-  int cElements,
-  CONST INT *lpaElements,
-  CONST COLORREF *lpaRgbValues)
-{
-  UNIMPLEMENTED;
-  return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
 TrackMouseEvent(
   LPTRACKMOUSEEVENT lpEventTrack)
 {

reactos/lib/user32/windows
defwnd.c 1.144 -> 1.144.4.1
diff -u -r1.144 -r1.144.4.1
--- defwnd.c	15 Aug 2004 21:36:29 -0000	1.144
+++ defwnd.c	12 Sep 2004 21:23:25 -0000	1.144.4.1
@@ -1,4 +1,4 @@
-/* $Id: defwnd.c,v 1.144 2004/08/15 21:36:29 chorns Exp $
+/* $Id: defwnd.c,v 1.144.4.1 2004/09/12 21:23:25 weiden Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS user32.dll
@@ -41,70 +41,47 @@
 
 /* GLOBALS *******************************************************************/
 
-/* TODO:  widgets will be cached here.
-static HBITMAP hbClose;
-static HBITMAP hbCloseD;
-static HBITMAP hbMinimize;
-static HBITMAP hbMinimizeD;
-static HBITMAP hbRestore;
-static HBITMAP hbRestoreD;
-static HBITMAP hbMaximize;
-static HBITMAP hbScrUp;
-static HBITMAP hbScrDwn;
-static HBITMAP hbScrLeft;
-static HBITMAP hbScrRight;
-*/
-
-
-static COLORREF SysColors[] =
-{
-  RGB(212, 208, 200), /* COLOR_SCROLLBAR  */
-  RGB(58, 110, 165),  /* COLOR_BACKGROUND  */
-  RGB(10, 36, 106),   /* COLOR_ACTIVECAPTION  */
-  RGB(128, 128, 128), /* COLOR_INACTIVECAPTION  */
-  RGB(212, 208, 200), /* COLOR_MENU  */
-  RGB(255, 255, 255), /* COLOR_WINDOW  */
-  RGB(0, 0, 0),       /* COLOR_WINDOWFRAME  */
-  RGB(0, 0, 0),       /* COLOR_MENUTEXT  */
-  RGB(0, 0, 0),       /* COLOR_WINDOWTEXT  */
-  RGB(255, 255, 255), /* COLOR_CAPTIONTEXT  */
-  RGB(212, 208, 200), /* COLOR_ACTIVEBORDER  */
-  RGB(212, 208, 200), /* COLOR_INACTIVEBORDER  */
-  RGB(128, 128, 128), /* COLOR_APPWORKSPACE  */
-  RGB(10, 36, 106),   /* COLOR_HIGHLIGHT  */
-  RGB(255, 255, 255), /* COLOR_HIGHLIGHTTEXT  */
-  RGB(212, 208, 200), /* COLOR_BTNFACE  */
-  RGB(128, 128, 128), /* COLOR_BTNSHADOW  */
-  RGB(128, 128, 128), /* COLOR_GRAYTEXT  */
-  RGB(0, 0, 0),       /* COLOR_BTNTEXT  */
-  RGB(212, 208, 200), /* COLOR_INACTIVECAPTIONTEXT  */
-  RGB(255, 255, 255), /* COLOR_BTNHIGHLIGHT  */
-  RGB(64, 64, 64),    /* COLOR_3DDKSHADOW  */
-  RGB(212, 208, 200), /* COLOR_3DLIGHT  */
-  RGB(0, 0, 0),       /* COLOR_INFOTEXT  */
-  RGB(255, 255, 225), /* COLOR_INFOBK  */
-  RGB(181, 181, 181), /* COLOR_UNKNOWN  */
-  RGB(0, 0, 128),     /* COLOR_HOTLIGHT  */
-  RGB(166, 202, 240), /* COLOR_GRADIENTACTIVECAPTION  */
-  RGB(192, 192, 192), /* COLOR_GRADIENTINACTIVECAPTION  */
-  RGB(49, 106, 197),  /* COLOR_MENUHILIGHT  */
-  RGB(236, 233, 216)  /* COLOR_MENUBAR  */
-};
-
-#define NUM_SYSCOLORS (sizeof(SysColors) / sizeof(SysColors[0]))
+static COLORREF SysColors[NUM_SYSCOLORS] = {0};
+static HPEN SysPens[NUM_SYSCOLORS] = {0};
+static HBRUSH SysBrushes[NUM_SYSCOLORS] = {0};
 
 /* Bits in the dwKeyData */
 #define KEYDATA_ALT   0x2000
 
 /* FUNCTIONS *****************************************************************/
 
+void
+InitStockObjects(void)
+{
+  /* FIXME - Instead of copying the stuff to usermode we should map the tables to
+             userland. The current implementation has one big flaw: the system color
+             table doesn't get updated when another process changes them. That's why
+             we should rather map the table into usermode. But it only affects the
+             SysColors table - the pens, brushes and stock objects are not affected
+             as their handles never change. But it'd be faster to map them, too. */
+  if(SysBrushes[0] == NULL)
+  {
+    /* only initialize once */
+    NtUserGetSysColors(SysColors, NUM_SYSCOLORS);
+    NtUserGetSysColorPens(SysPens, NUM_SYSCOLORS);
+    NtUserGetSysColorBrushes(SysBrushes, NUM_SYSCOLORS);
+  }
+}
+
+
 /*
  * @implemented
  */
 DWORD STDCALL
 GetSysColor(int nIndex)
 {
+  if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
+  {
     return SysColors[nIndex];
+  }
+  
+  SetLastError(ERROR_INVALID_PARAMETER);
+  return 0;
 }
 
 /*
@@ -113,22 +90,13 @@
 HPEN STDCALL
 GetSysColorPen(int nIndex)
 {
-  static HPEN SysPens[NUM_SYSCOLORS];
-
-  if (nIndex < 0 || NUM_SYSCOLORS < nIndex)
-    {
-      SetLastError(ERROR_INVALID_PARAMETER);
-      return NULL;
-    }
-
-  /* FIXME should register this object with DeleteObject() so it
-     can't be deleted */
-  if (NULL == SysPens[nIndex])
-    {
-      SysPens[nIndex] = CreatePen(PS_SOLID, 1, SysColors[nIndex]);
-    }
-
-  return SysPens[nIndex];
+  if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
+  {
+    return SysPens[nIndex];
+  }
+  
+  SetLastError(ERROR_INVALID_PARAMETER);
+  return NULL;
 }
 
 /*
@@ -137,89 +105,48 @@
 HBRUSH STDCALL
 GetSysColorBrush(int nIndex)
 {
-  static HBRUSH SysBrushes[NUM_SYSCOLORS];
-
-  if (nIndex < 0 || NUM_SYSCOLORS < nIndex)
-    {
-      SetLastError(ERROR_INVALID_PARAMETER);
-      return NULL;
-    }
-
-  /* FIXME should register this object with DeleteObject() so it
-     can't be deleted */
-  if (NULL == SysBrushes[nIndex])
-    {
-      SysBrushes[nIndex] = (HBRUSH) ((DWORD) CreateSolidBrush(SysColors[nIndex]) | 0x00800000);
-    }
-
-  return SysBrushes[nIndex];
-}
-
-/*
- * @unimplemented
- */
-/*
-LRESULT STDCALL
-DefFrameProcA( HWND hWnd,
-	      HWND hWndMDIClient,
-	      UINT uMsg,
-	      WPARAM wParam,
-	      LPARAM lParam )
-{
-    UNIMPLEMENTED;
-    return ((LRESULT)0);
-}
-*/
-
-/*
- * @unimplemented
- */
-/*
-LRESULT STDCALL
-DefFrameProcW(HWND hWnd,
-	      HWND hWndMDIClient,
-	      UINT uMsg,
-	      WPARAM wParam,
-	      LPARAM lParam)
-{
-    UNIMPLEMENTED;
-    return ((LRESULT)0);
-}
-*/
-
-ULONG
-UserHasAnyFrameStyle(ULONG Style, ULONG ExStyle)
-{
-    return ((Style & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) ||
-            (ExStyle & WS_EX_DLGMODALFRAME) ||
-            (!(Style & (WS_CHILD | WS_POPUP))));
-}
-
-ULONG
-UserHasDlgFrameStyle(ULONG Style, ULONG ExStyle)
-{
-    return ((ExStyle & WS_EX_DLGMODALFRAME) ||
-            ((Style & WS_DLGFRAME) && (!(Style & WS_THICKFRAME))));
+  if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
+  {
+    return SysBrushes[nIndex];
+  }
+  
+  SetLastError(ERROR_INVALID_PARAMETER);
+  return NULL;
 }
 
-ULONG
-UserHasThickFrameStyle(ULONG Style, ULONG ExStyle)
+BOOL
+STDCALL
+SetSysColors(
+  int cElements,
+  CONST INT *lpaElements,
+  CONST COLORREF *lpaRgbValues)
 {
-    return ((Style & WS_THICKFRAME) &&
-            (!((Style & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)));
-}
+  BOOL Ret;
+  struct
+  {
+    INT *Elements;
+    COLORREF *Colors;
+  } ChangeSysColors;
+  
+  ChangeSysColors.Elements = (INT*)lpaElements;
+  ChangeSysColors.Colors = (COLORREF*)lpaRgbValues;
 
-ULONG
-UserHasThinFrameStyle(ULONG Style, ULONG ExStyle)
-{
-    return ((Style & WS_BORDER) || (!(Style & (WS_CHILD | WS_POPUP))));
-}
+  if(cElements > 0)
+  {
+    Ret = NtUserSetSysColors(&ChangeSysColors, cElements);
+    if(Ret)
+    {
+      /* FIXME - just change it in the usermode structure, too, instead of asking win32k again */
+      NtUserGetSysColors(SysColors, NUM_SYSCOLORS);
+    }
+  }
+  else
+  {
+    SetLastError(ERROR_INVALID_PARAMETER);
+    Ret = FALSE;
+  }
 
-ULONG
-UserHasBigFrameStyle(ULONG Style, ULONG ExStyle)
-{
-    return ((Style & (WS_THICKFRAME | WS_DLGFRAME)) ||
-            (ExStyle & WS_EX_DLGMODALFRAME));
+  return Ret;
 }
 
 void
CVSspam 0.2.8