1 added + 4 removed + 61 modified, total 66 files
reactos
diff -u -r1.27 -r1.28
--- config 20 Nov 2004 17:48:37 -0000 1.27
+++ config 12 Dec 2004 01:40:35 -0000 1.28
@@ -25,7 +25,7 @@
#
# Whether to compile for debugging
#
-DBG := 0
+DBG := 1
#
# Whether to compile with optimizations
reactos/include/napi
diff -u -r1.21 -r1.22
--- win32.h 20 Nov 2004 16:46:04 -0000 1.21
+++ win32.h 12 Dec 2004 01:40:36 -0000 1.22
@@ -32,8 +32,8 @@
LIST_ENTRY CursorIconListHead;
struct _KBDTABLES* KeyboardLayout;
ULONG Flags;
- WORD GDIObjects;
- WORD UserObjects;
+ LONG GDIObjects;
+ LONG UserObjects;
} W32PROCESS, *PW32PROCESS;
PW32THREAD STDCALL
reactos/include/win32k
diff -u -r1.26 -r1.27
--- bitmaps.h 12 Sep 2004 19:47:48 -0000 1.26
+++ bitmaps.h 12 Dec 2004 01:40:36 -0000 1.27
@@ -26,11 +26,12 @@
/* 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(hBMObj) GDIOBJ_UnlockObj((HGDIOBJ) hBMObj)
+BOOL INTERNAL_CALL BITMAP_Cleanup(PVOID ObjectBody);
INT FASTCALL BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp);
HBITMAP FASTCALL BITMAPOBJ_CopyBitmap (HBITMAP hBitmap);
@@ -38,7 +39,6 @@
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 );
HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice);
HBITMAP FASTCALL IntCreateCompatibleBitmap(PDC Dc, INT Width, INT Height);
reactos/include/win32k
diff -u -r1.18 -r1.19
--- brush.h 12 Sep 2004 19:47:48 -0000 1.18
+++ brush.h 12 Dec 2004 01:40:36 -0000 1.19
@@ -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(hBrush) GDIOBJ_UnlockObj((HGDIOBJ)hBrush)
+BOOL INTERNAL_CALL BRUSH_Cleanup(PVOID ObjectBody);
#ifdef __USE_W32API
typedef struct _PATRECT {
reactos/include/win32k
diff -u -r1.39 -r1.40
--- dc.h 12 Sep 2004 19:47:48 -0000 1.39
+++ dc.h 12 Dec 2004 01:40:36 -0000 1.40
@@ -108,6 +108,26 @@
WIN_DC_INFO w;
} DC, *PDC;
+typedef struct _GDIPOINTER
+{
+ BOOL Enabled;
+ POINTL Pos;
+ SIZEL Size;
+ POINTL HotSpot;
+
+ PGD_MOVEPOINTER MovePointer;
+
+ XLATEOBJ *XlateObject;
+ HSURF ColorSurface;
+ HSURF MaskSurface;
+ HSURF SaveSurface;
+
+ ULONG Status;
+
+ BOOL SafetySwitch;
+ UINT SafetyRemoveCount;
+} GDIPOINTER, *PGDIPOINTER;
+
typedef struct
{
HANDLE Handle;
@@ -119,21 +139,7 @@
DRIVER_FUNCTIONS DriverFunctions;
PFILE_OBJECT VideoFileObject;
- PGD_MOVEPOINTER MovePointer;
-
- struct {
- BOOL Enable;
- LONG Column;
- LONG Row;
- LONG Width;
- LONG Height;
- } PointerAttributes;
- XLATEOBJ *PointerXlateObject;
- HSURF PointerColorSurface;
- HSURF PointerMaskSurface;
- HSURF PointerSaveSurface;
- POINTL PointerHotSpot;
- ULONG PointerStatus;
+ GDIPOINTER Pointer;
} GDIDEVICE;
/* Internal functions */
@@ -141,16 +147,16 @@
#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)
+ GDIOBJ_UnlockObj ((HGDIOBJ) hDC)
HDC FASTCALL RetrieveDisplayHDC(VOID);
HDC FASTCALL DC_AllocDC(PUNICODE_STRING Driver);
VOID FASTCALL DC_InitDC(HDC DCToInit);
HDC FASTCALL DC_FindOpenDC(PUNICODE_STRING Driver);
VOID FASTCALL DC_FreeDC(HDC DCToFree);
+BOOL INTERNAL_CALL DC_Cleanup(PVOID ObjectBody);
HDC FASTCALL DC_GetNextDC (PDC pDC);
VOID FASTCALL DC_SetNextDC (PDC pDC, HDC hNextDC);
-BOOL FASTCALL DC_InternalDeleteDC( PDC DCToDelete );
VOID FASTCALL DC_SetOwnership(HDC DC, PEPROCESS Owner);
VOID FASTCALL DC_UpdateXforms(PDC dc);
reactos/include/win32k
diff -u -r1.26 -r1.27
--- gdiobj.h 12 Sep 2004 19:47:48 -0000 1.26
+++ gdiobj.h 12 Dec 2004 01:40:36 -0000 1.27
@@ -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
@@ -35,28 +55,18 @@
typedef PVOID PGDIOBJ;
-typedef BOOL (FASTCALL *GDICLEANUPPROC)(PGDIOBJ Obj);
-
-#define GDIOBJ_USE_FASTMUTEX
+typedef BOOL (INTERNAL_CALL *GDICLEANUPPROC)(PVOID ObjectBody);
/*!
* 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;
+ PETHREAD LockingThread; /* only assigned if a thread is holding the lock! */
+ ULONG Locks;
+#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 +77,41 @@
DWORD ObjectType;
} GDIMULTILOCK, *PGDIMULTILOCK;
-HGDIOBJ FASTCALL GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProcPtr);
-BOOL STDCALL GDIOBJ_FreeObj (HGDIOBJ Obj, DWORD ObjectType, DWORD Flag);
-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_LockMultipleObj(PGDIMULTILOCK pList, INT nObj);
+HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObj(ULONG ObjectType);
+BOOL INTERNAL_CALL GDIOBJ_LockMultipleObj(PGDIMULTILOCK pList, INT nObj);
+BOOL INTERNAL_CALL GDIOBJ_UnlockMultipleObj(PGDIMULTILOCK pList, INT nObj);
+BOOL INTERNAL_CALL GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle);
+void INTERNAL_CALL GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS Owner);
+void INTERNAL_CALL GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo);
+BOOL INTERNAL_CALL GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj);
+BOOL INTERNAL_CALL 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_FreeObj(obj,ty) GDIOBJ_FreeObjDbg(__FILE__,__LINE__,obj,ty)
#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)
+
+BOOL INTERNAL_CALL GDIOBJ_FreeObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);
+PGDIOBJ INTERNAL_CALL GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);
+BOOL INTERNAL_CALL GDIOBJ_UnlockObjDbg (const char* file, int line, HGDIOBJ hObj);
-#ifdef GDIOBJ_LockObj
-PGDIOBJ FASTCALL GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ Obj, DWORD ObjectType);
-#endif /* GDIOBJ_LockObj */
-
-#ifdef GDIOBJ_UnlockObj
-BOOL FASTCALL GDIOBJ_UnlockObjDbg (const char* file, int line, HGDIOBJ Obj, DWORD ObjectType);
-#endif /* GDIOBJ_UnlockObj */
+#else /* !GDI_DEBUG */
+
+BOOL INTERNAL_CALL GDIOBJ_FreeObj (HGDIOBJ hObj, DWORD ObjectType);
+PGDIOBJ INTERNAL_CALL GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType);
+BOOL INTERNAL_CALL GDIOBJ_UnlockObj (HGDIOBJ hObj);
+
+#endif /* GDI_DEBUG */
#define GDIOBJFLAG_DEFAULT (0x0)
#define GDIOBJFLAG_IGNOREPID (0x1)
#define GDIOBJFLAG_IGNORELOCK (0x2)
+PVOID INTERNAL_CALL GDI_MapHandleTable(HANDLE hProcess);
+
#endif
reactos/include/win32k
diff -u -r1.9 -r1.10
--- kapi.h 10 May 2004 17:07:16 -0000 1.9
+++ kapi.h 12 Dec 2004 01:40:36 -0000 1.10
@@ -1,5 +1,10 @@
#ifndef _WIN32K_KAPI_H
#define _WIN32K_KAPI_H
+
+#ifndef INTERNAL_CALL
+#define INTERNAL_CALL STDCALL
+#endif
+
#include <win32k/bitmaps.h>
#include <win32k/brush.h>
#include <win32k/cliprgn.h>
reactos/include/win32k
diff -u -r1.140 -r1.141
--- ntuser.h 6 Dec 2004 02:23:05 -0000 1.140
+++ ntuser.h 12 Dec 2004 01:40:36 -0000 1.141
@@ -212,6 +212,10 @@
#define TWOPARAM_ROUTINE_SETCARETPOS 0x60
#define TWOPARAM_ROUTINE_GETWINDOWINFO 0x61
#define TWOPARAM_ROUTINE_REGISTERLOGONPROC 0x62
+#define TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES 0x63
+#define TWOPARAM_ROUTINE_GETSYSCOLORPENS 0x64
+#define TWOPARAM_ROUTINE_GETSYSCOLORS 0x65
+#define TWOPARAM_ROUTINE_SETSYSCOLORS 0x66
DWORD
STDCALL
NtUserCallTwoParam(
@@ -1805,17 +1809,13 @@
} Value;
} KMDDELPARAM, *PKMDDELPARAM;
-#include <pshpack1.h>
typedef struct _GDI_TABLE_ENTRY
{
- PVOID KernelData; /* Points to the kernel mode structure */
- unsigned short ProcessId; /* process id that created the object, 0 for stock objects */
- unsigned short Count; /* we don't use this field, only NT4 uses it */
- unsigned short Upper; /* copy of the upper 16 bit of the handle, contains the object type */
- unsigned short nType; /* object type */
- PVOID UserData; /* Points to the user mode structure, usually NULL though */
+ PVOID KernelData; /* Points to the kernel mode structure */
+ LONG ProcessId; /* process id that created the object, 0 for stock objects */
+ LONG Type; /* the first 16 bit is the object type including the stock obj flag, the last 16 bits is just the object type */
+ PVOID UserData; /* Points to the user mode structure, usually NULL though */
} GDI_TABLE_ENTRY, *PGDI_TABLE_ENTRY;
-#include <poppack.h>
#endif /* __WIN32K_NTUSER_H */
reactos/include/win32k
diff -u -r1.11 -r1.12
--- pen.h 12 Sep 2004 19:47:48 -0000 1.11
+++ pen.h 12 Dec 2004 01:40:36 -0000 1.12
@@ -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(hBMObj) GDIOBJ_UnlockObj((HGDIOBJ) hBMObj)
HPEN STDCALL
NtGdiCreatePen(
reactos/include/win32k
diff -u -r1.25 -r1.26
--- region.h 12 Sep 2004 19:47:48 -0000 1.25
+++ region.h 12 Dec 2004 01:40:36 -0000 1.26
@@ -11,12 +11,11 @@
} 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(hRgn) GDIOBJ_UnlockObj((HGDIOBJ)hRgn)
HRGN FASTCALL RGNDATA_AllocRgn(INT n);
-
-BOOL FASTCALL RGNDATA_InternalDelete( PROSRGNDATA Obj );
+BOOL INTERNAL_CALL RGNDATA_Cleanup(PVOID ObjectBody);
/* User entry points */
HRGN STDCALL
reactos/include/win32k
diff -u -r1.23 -r1.24
--- text.h 12 Sep 2004 19:47:48 -0000 1.23
+++ text.h 12 Dec 2004 01:40:36 -0000 1.24
@@ -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(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj)
NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle);
NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont);
reactos/lib/user32/include
diff -u -r1.31 -r1.32
--- user32.h 12 Sep 2004 19:47:49 -0000 1.31
+++ user32.h 12 Dec 2004 01:40:36 -0000 1.32
@@ -30,10 +30,21 @@
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 +72,18 @@
#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 +123,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
diff -u -r1.12 -r1.13
--- window.h 12 Sep 2004 19:47:49 -0000 1.12
+++ window.h 12 Dec 2004 01:40:36 -0000 1.13
@@ -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
diff -u -r1.45 -r1.46
--- dllmain.c 12 Sep 2004 19:47:49 -0000 1.45
+++ dllmain.c 12 Dec 2004 01:40:36 -0000 1.46
@@ -76,6 +76,7 @@
InitializeCriticalSection(&gcsMPH);
GdiDllInitialize(NULL, DLL_PROCESS_ATTACH, NULL);
+ InitStockObjects();
}
VOID
reactos/lib/user32/misc
diff -u -r1.68 -r1.69
--- stubs.c 16 Nov 2004 16:27:48 -0000 1.68
+++ stubs.c 12 Dec 2004 01:40:36 -0000 1.69
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.68 2004/11/16 16:27:48 blight Exp $
+/* $Id: stubs.c,v 1.69 2004/12/12 01:40:36 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@@ -148,21 +148,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
diff -u -r1.147 -r1.148
--- defwnd.c 19 Nov 2004 23:07:09 -0000 1.147
+++ defwnd.c 12 Dec 2004 01:40:36 -0000 1.148
@@ -1,4 +1,4 @@
-/* $Id: defwnd.c,v 1.147 2004/11/19 23:07:09 gvg Exp $
+/* $Id: defwnd.c,v 1.148 2004/12/12 01:40:36 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@@ -41,70 +41,46 @@
/* 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 +89,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]);
- }
+ if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
+ {
+ return SysPens[nIndex];
+ }
- return SysPens[nIndex];
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
}
/*
@@ -137,89 +104,51 @@
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);
- }
+ if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
+ {
+ return SysBrushes[nIndex];
+ }
- return SysBrushes[nIndex];
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
}
/*
- * @unimplemented
- */
-/*
-LRESULT STDCALL
-DefFrameProcA( HWND hWnd,
- HWND hWndMDIClient,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam )
-{
- UNIMPLEMENTED;
- return ((LRESULT)0);
-}
-*/
-
-/*
- * @unimplemented
+ * @implemented
*/
-/*
-LRESULT STDCALL
-DefFrameProcW(HWND hWnd,
- HWND hWndMDIClient,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
+BOOL
+STDCALL
+SetSysColors(
+ int cElements,
+ CONST INT *lpaElements,
+ CONST COLORREF *lpaRgbValues)
{
- 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))));
-}
-
-ULONG
-UserHasThickFrameStyle(ULONG Style, ULONG ExStyle)
-{
- return ((Style & WS_THICKFRAME) &&
- (!((Style & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)));
-}
-
-ULONG
-UserHasThinFrameStyle(ULONG Style, ULONG ExStyle)
-{
- return ((Style & WS_BORDER) || (!(Style & (WS_CHILD | WS_POPUP))));
-}
+ BOOL Ret;
+ struct
+ {
+ INT *Elements;
+ COLORREF *Colors;
+ } ChangeSysColors;
-ULONG
-UserHasBigFrameStyle(ULONG Style, ULONG ExStyle)
-{
- return ((Style & (WS_THICKFRAME | WS_DLGFRAME)) ||
- (ExStyle & WS_EX_DLGMODALFRAME));
+ ChangeSysColors.Elements = (INT*)lpaElements;
+ ChangeSysColors.Colors = (COLORREF*)lpaRgbValues;
+
+ 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;
+ }
+
+ return Ret;
}
void
reactos/subsys/win32k/eng
diff -u -r1.58 -r1.59
--- bitblt.c 14 Jul 2004 20:48:57 -0000 1.58
+++ bitblt.c 12 Dec 2004 01:40:36 -0000 1.59
@@ -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: bitblt.c,v 1.58 2004/07/14 20:48:57 navaraf Exp $
+/* $Id: bitblt.c,v 1.59 2004/12/12 01:40:36 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -89,8 +89,9 @@
static BYTE maskbit[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
/* Pattern brushes */
PGDIBRUSHINST GdiBrush = NULL;
- HBITMAP PatternSurface = NULL;
+ HBITMAP PatternSurface;
SURFOBJ *PatternObj = NULL;
+ PBITMAPOBJ PatternBitmap;
ULONG PatternWidth = 0, PatternHeight = 0, PatternY = 0;
if (Mask == NULL)
@@ -103,8 +104,6 @@
if (Brush->iSolidColor == 0xFFFFFFFF)
{
- PBITMAPOBJ PatternBitmap;
-
GdiBrush = CONTAINING_RECORD(
Brush,
GDIBRUSHINST,
@@ -112,11 +111,15 @@
PatternSurface = GdiBrush->GdiBrushObject->hbmPattern;
PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->GdiBrushObject->hbmPattern);
-
- PatternObj = &PatternBitmap->SurfObj;
- PatternWidth = PatternObj->sizlBitmap.cx;
- PatternHeight = PatternObj->sizlBitmap.cy;
+ if(PatternBitmap != NULL)
+ {
+ PatternObj = &PatternBitmap->SurfObj;
+ PatternWidth = PatternObj->sizlBitmap.cx;
+ PatternHeight = PatternObj->sizlBitmap.cy;
+ }
}
+ else
+ PatternBitmap = NULL;
tMask = Mask->pvScan0 + SourcePoint->y * Mask->lDelta + (SourcePoint->x >> 3);
for (j = 0; j < dy; j++)
@@ -124,14 +127,14 @@
lMask = tMask;
c8 = SourcePoint->x & 0x07;
- if(PatternSurface)
+ if(PatternBitmap != NULL)
PatternY = (DestRect->top + j) % PatternHeight;
for (i = 0; i < dx; i++)
{
if (0 != (*lMask & maskbit[c8]))
{
- if (PatternSurface == NULL)
+ if (PatternBitmap == NULL)
{
DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_PutPixel(
Dest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor);
@@ -153,7 +156,7 @@
tMask += Mask->lDelta;
}
- if (PatternSurface != NULL)
+ if (PatternBitmap != NULL)
BITMAPOBJ_UnlockBitmap(PatternSurface);
return TRUE;
@@ -222,15 +225,25 @@
if (ROP_USES_PATTERN(Rop4) && Brush->iSolidColor == 0xFFFFFFFF)
{
GdiBrush = CONTAINING_RECORD(Brush, GDIBRUSHINST, BrushObject);
- bmPattern = BITMAPOBJ_LockBitmap(GdiBrush->GdiBrushObject->hbmPattern);
- BltInfo.PatternSurface = &bmPattern->SurfObj;
+ if((bmPattern = BITMAPOBJ_LockBitmap(GdiBrush->GdiBrushObject->hbmPattern)))
+ {
+ BltInfo.PatternSurface = &bmPattern->SurfObj;
+ }
+ else
+ {
+ /* FIXME - What to do here? */
+ }
BltInfo.XlatePatternToDest = GdiBrush->XlateObject;
}
+ else
+ {
+ bmPattern = NULL;
+ }
Result = DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_BitBlt(&BltInfo);
/* Pattern brush */
- if (ROP_USES_PATTERN(Rop4) && Brush->iSolidColor == 0xFFFFFFFF)
+ if (bmPattern != NULL)
{
BITMAPOBJ_UnlockBitmap(BltInfo.PatternSurface->hsurf);
}
reactos/subsys/win32k/eng
diff -u -r1.22 -r1.23
--- clip.c 30 May 2004 14:01:12 -0000 1.22
+++ clip.c 12 Dec 2004 01:40:36 -0000 1.23
@@ -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: clip.c,v 1.22 2004/05/30 14:01:12 weiden Exp $
+/* $Id: clip.c,v 1.23 2004/12/12 01:40:36 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -28,83 +28,7 @@
*/
#include <w32k.h>
-VOID STDCALL IntEngDeleteClipRegion(CLIPOBJ *ClipObj)
-{
- HCLIP HClip = AccessHandleFromUserObject(ClipObj);
- FreeGDIHandle(HClip);
-}
-
-CLIPOBJ* STDCALL
-IntEngCreateClipRegion(ULONG count, PRECTL pRect, PRECTL rcBounds)
-{
- HCLIP hClip;
- CLIPGDI* clipInt;
- CLIPOBJ* clipUser;
-
- DPRINT("IntEngCreateClipRegion count: %d\n", count);
- if (1 < count)
- {
- hClip = (HCLIP) CreateGDIHandle(sizeof(CLIPGDI) + count * sizeof(RECTL),
- sizeof(CLIPOBJ), (PVOID*)&clipInt, (PVOID*)&clipUser);
-
- if (hClip)
- {
- RtlCopyMemory(clipInt->EnumRects.arcl, pRect, count * sizeof(RECTL));
- clipInt->EnumRects.c = count;
- clipInt->EnumOrder = CD_ANY;
-
- clipUser->iDComplexity = DC_COMPLEX;
- clipUser->iFComplexity = (count <= 4) ? FC_RECT4: FC_COMPLEX;
- clipUser->iMode = TC_RECTANGLES;
- RtlCopyMemory(&(clipUser->rclBounds), rcBounds, sizeof(RECTL));
-
- return clipUser;
- }
- }
- else
- {
- hClip = (HCLIP) CreateGDIHandle(sizeof(CLIPGDI),
- sizeof(CLIPOBJ),
- (PVOID)&clipInt, (PVOID)&clipUser);
- if (hClip)
- {
- RtlCopyMemory(clipInt->EnumRects.arcl, rcBounds, sizeof(RECTL));
- clipInt->EnumRects.c = 1;
- clipInt->EnumOrder = CD_ANY;
-
- clipUser->iDComplexity = ((rcBounds->top==rcBounds->bottom)
- && (rcBounds->left==rcBounds->right))
- ? DC_TRIVIAL : DC_RECT;
- clipUser->iFComplexity = FC_RECT;
- clipUser->iMode = TC_RECTANGLES;
- DPRINT("IntEngCreateClipRegion: iDComplexity: %d\n", clipUser->iDComplexity);
- RtlCopyMemory(&(clipUser->rclBounds), rcBounds, sizeof(RECTL));
- return clipUser;
- }
- }
-
- return NULL;
-}
-
-/*
- * @implemented
- */
-CLIPOBJ * STDCALL
-EngCreateClip(VOID)
-{
- return EngAllocMem(FL_ZERO_MEMORY, sizeof(CLIPOBJ), 0);
-}
-
-/*
- * @implemented
- */
-VOID STDCALL
-EngDeleteClip(CLIPOBJ *ClipRegion)
-{
- EngFreeMem(ClipRegion);
-}
-
-static int
+static inline int
CompareRightDown(const PRECT r1, const PRECT r2)
{
int Cmp;
@@ -117,7 +41,7 @@
{
Cmp = +1;
}
- else
+ else
{
ASSERT(r1->bottom == r2->bottom);
if (r1->left < r2->left)
@@ -138,7 +62,7 @@
return Cmp;
}
-static int
+static inline int
CompareRightUp(const PRECT r1, const PRECT r2)
{
int Cmp;
@@ -151,7 +75,7 @@
{
Cmp = -1;
}
- else
+ else
{
ASSERT(r1->top == r2->top);
if (r1->left < r2->left)
@@ -172,7 +96,7 @@
return Cmp;
}
-static int
+static inline int
CompareLeftDown(const PRECT r1, const PRECT r2)
{
int Cmp;
@@ -185,7 +109,7 @@
{
Cmp = +1;
}
- else
+ else
{
ASSERT(r1->bottom == r2->bottom);
if (r1->right < r2->right)
@@ -206,7 +130,7 @@
return Cmp;
}
-static int
+static inline int
CompareLeftUp(const PRECT r1, const PRECT r2)
{
int Cmp;
@@ -219,7 +143,7 @@
{
Cmp = -1;
}
- else
+ else
{
ASSERT(r1->top == r2->top);
if (r1->right < r2->right)
@@ -240,6 +164,122 @@
return Cmp;
}
+static inline int
+CompareSpans(const PSPAN Span1, const PSPAN Span2)
+{
+ int Cmp;
+
+ if (Span1->Y < Span2->Y)
+ {
+ Cmp = -1;
+ }
+ else if (Span2->Y < Span1->Y)
+ {
+ Cmp = +1;
+ }
+ else
+ {
+ if (Span1->X < Span2->X)
+ {
+ Cmp = -1;
+ }
+ else if (Span2->X < Span1->X)
+ {
+ Cmp = +1;
+ }
+ else
+ {
+ Cmp = 0;
+ }
+ }
+
+ return Cmp;
+}
+
+VOID FASTCALL
+IntEngDeleteClipRegion(CLIPOBJ *ClipObj)
+{
+ EngFreeMem(ObjToGDI(ClipObj, CLIP));
+}
+
+CLIPOBJ* FASTCALL
+IntEngCreateClipRegion(ULONG count, PRECTL pRect, PRECTL rcBounds)
+{
+ CLIPGDI *Clip;
+
+ if(count > 1)
+ {
+ RECTL *dest;
+
+ Clip = EngAllocMem(0, sizeof(CLIPGDI) + ((count - 1) * sizeof(RECTL)), TAG_CLIPOBJ);
+
+ if(Clip != NULL)
+ {
+ Clip->EnumRects.c = count;
+ Clip->EnumOrder = CD_ANY;
+ for(dest = Clip->EnumRects.arcl;
+ count > 0;
+ count--, dest++, pRect++)
+ {
+ *dest = *pRect;
+ }
+
+ Clip->ClipObj.iDComplexity = DC_COMPLEX;
+ Clip->ClipObj.iFComplexity = ((Clip->EnumRects.c <= 4) ? FC_RECT4 : FC_COMPLEX);
+ Clip->ClipObj.iMode = TC_RECTANGLES;
+ Clip->ClipObj.rclBounds = *rcBounds;
+
+ return GDIToObj(Clip, CLIP);
+ }
+ }
+ else
+ {
+ Clip = EngAllocMem(0, sizeof(CLIPGDI), TAG_CLIPOBJ);
+
+ if(Clip != NULL)
+ {
+ Clip->EnumRects.c = 1;
+ Clip->EnumOrder = CD_ANY;
+ Clip->EnumRects.arcl[0] = *rcBounds;
+
+ Clip->ClipObj.iDComplexity = (((rcBounds->top == rcBounds->bottom) &&
+ (rcBounds->left == rcBounds->right))
+ ? DC_TRIVIAL : DC_RECT);
+ Clip->ClipObj.iFComplexity = FC_RECT;
+ Clip->ClipObj.iMode = TC_RECTANGLES;
+ Clip->ClipObj.rclBounds = *rcBounds;
+
+ return GDIToObj(Clip, CLIP);
+ }
+ }
+
+ return NULL;
+}
+
+/*
+ * @implemented
+ */
+CLIPOBJ * STDCALL
+EngCreateClip(VOID)
+{
+ CLIPGDI *Clip = EngAllocMem(FL_ZERO_MEMORY, sizeof(CLIPOBJ), TAG_CLIPOBJ);
+ if(Clip != NULL)
+ {
+ return GDIToObj(Clip, CLIP);
+ }
+
+ return NULL;
+}
+
+/*
+ * @implemented
+ */
+VOID STDCALL
+EngDeleteClip(CLIPOBJ *ClipRegion)
+{
+ EngFreeMem(ObjToGDI(ClipRegion, CLIP));
+}
+
/*
* @implemented
*/
@@ -250,7 +290,7 @@
IN ULONG BuildOrder,
IN ULONG MaxRects)
{
- CLIPGDI *ClipGDI = (CLIPGDI*)AccessInternalObjectFromUserObject(ClipObj);
+ CLIPGDI *ClipGDI = ObjToGDI(ClipObj, CLIP);
SORTCOMP CompareFunc;
ClipGDI->EnumPos = 0;
@@ -305,8 +345,9 @@
IN ULONG ObjSize,
OUT ULONG *EnumRects)
{
- CLIPGDI *ClipGDI = (CLIPGDI*)AccessInternalObjectFromUserObject(ClipObj);
- ULONG nCopy;
+ RECTL *dest, *src;
+ CLIPGDI *ClipGDI = ObjToGDI(ClipObj, CLIP);
+ ULONG nCopy, i;
ENUMRECTS* pERects = (ENUMRECTS*)EnumRects;
//calculate how many rectangles we should copy
@@ -317,8 +358,16 @@
{
return FALSE;
}
- RtlCopyMemory( pERects->arcl, ClipGDI->EnumRects.arcl + ClipGDI->EnumPos,
- nCopy * sizeof(RECTL) );
+
+ /* copy rectangles */
+ src = ClipGDI->EnumRects.arcl + ClipGDI->EnumPos;
+ for(i = 0, dest = pERects->arcl;
+ i < nCopy;
+ i++, dest++, src++)
+ {
+ *dest = *src;
+ }
+
pERects->c = nCopy;
ClipGDI->EnumPos+=nCopy;
@@ -326,38 +375,6 @@
return ClipGDI->EnumPos < ClipGDI->EnumRects.c;
}
-static int
-CompareSpans(const PSPAN Span1, const PSPAN Span2)
-{
- int Cmp;
-
- if (Span1->Y < Span2->Y)
- {
- Cmp = -1;
- }
- else if (Span2->Y < Span1->Y)
- {
- Cmp = +1;
- }
- else
- {
- if (Span1->X < Span2->X)
- {
- Cmp = -1;
- }
- else if (Span2->X < Span1->X)
- {
- Cmp = +1;
- }
- else
- {
- Cmp = 0;
- }
- }
-
- return Cmp;
-}
-
BOOLEAN FASTCALL
ClipobjToSpans(PSPAN *Spans, UINT *Count, CLIPOBJ *ClipRegion, PRECTL Boundary)
{
@@ -418,7 +435,14 @@
}
if (0 != *Count)
{
- RtlCopyMemory(NewSpans, *Spans, *Count * sizeof(SPAN));
+ PSPAN dest, src;
+ UINT i = *Count;
+ for(dest = NewSpans, src = *Spans;
+ i > 0;
+ i--)
+ {
+ *dest++ = *src++;
+ }
ExFreePool(*Spans);
}
*Spans = NewSpans;
reactos/subsys/win32k/eng
diff -u -r1.77 -r1.78
--- mouse.c 30 Jul 2004 09:42:11 -0000 1.77
+++ mouse.c 12 Dec 2004 01:40:36 -0000 1.78
@@ -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: mouse.c,v 1.77 2004/07/30 09:42:11 weiden Exp $
+/* $Id: mouse.c,v 1.78 2004/12/12 01:40:36 weiden Exp $
*
* PROJECT: ReactOS kernel
* PURPOSE: Mouse
@@ -30,64 +30,7 @@
/* FUNCTIONS *****************************************************************/
-BOOL FASTCALL
-IntIsPrimarySurface(SURFOBJ *SurfObj);
-
-VOID FASTCALL
-EnableMouse(HDC hDisplayDC)
-{
- PDC dc;
- BITMAPOBJ *BitmapObj;
- GDIDEVICE *GdiDev;
- PSYSTEM_CURSORINFO CurInfo = IntGetSysCursorInfo(InputWindowStation);
-
- if( hDisplayDC && InputWindowStation)
- {
- if(!IntGetWindowStationObject(InputWindowStation))
- {
- CurInfo->Enabled = FALSE;
- return;
- }
-
- dc = DC_LockDc(hDisplayDC);
- ASSERT(dc);
- BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
- ASSERT(BitmapObj);
-
- /* Move the cursor to the screen center */
- DPRINT("Setting Cursor up at 0x%x, 0x%x\n", SurfObj->sizlBitmap.cx / 2, SurfObj->sizlBitmap.cy / 2);
- ExAcquireFastMutex(&CurInfo->CursorMutex);
- CurInfo->x = BitmapObj->SurfObj.sizlBitmap.cx / 2;
- CurInfo->y = BitmapObj->SurfObj.sizlBitmap.cy / 2;
- ExReleaseFastMutex(&CurInfo->CursorMutex);
-
- GdiDev = GDIDEV(&BitmapObj->SurfObj);
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- DC_UnlockDc( hDisplayDC );
-
- IntSetCursor(InputWindowStation, NULL, TRUE);
-
- CurInfo->Enabled = (SPS_ACCEPT_EXCLUDE == GdiDev->PointerStatus ||
- SPS_ACCEPT_NOEXCLUDE == GdiDev->PointerStatus);
-
- IntLoadDefaultCursors();
-
- ObDereferenceObject(InputWindowStation);
- }
- else
- {
- if(IntGetWindowStationObject(InputWindowStation))
- {
- IntSetCursor(InputWindowStation, NULL, TRUE);
- CurInfo->Enabled = FALSE;
- CurInfo->CursorClipInfo.IsClipped = FALSE;
- ObDereferenceObject(InputWindowStation);
- return;
- }
- }
-}
-
-INT FASTCALL
+INT INTERNAL_CALL
MouseSafetyOnDrawStart(SURFOBJ *SurfObj, LONG HazardX1,
LONG HazardY1, LONG HazardX2, LONG HazardY2)
/*
@@ -96,45 +39,25 @@
*/
{
LONG tmp;
- PSYSTEM_CURSORINFO CurInfo;
- BOOL MouseEnabled = FALSE;
- PCURICON_OBJECT Cursor;
+ GDIDEVICE *ppdev;
+ GDIPOINTER *pgp;
+ POINTL pt;
+ ASSERT(SurfObj != NULL);
- /* Mouse is not allowed to move if GDI is busy drawing */
-
- if(IntGetWindowStationObject(InputWindowStation))
- {
- CurInfo = IntGetSysCursorInfo(InputWindowStation);
-
- MouseEnabled = CurInfo->Enabled && CurInfo->ShowingCursor;
- }
- else
- return FALSE;
-
- if (SurfObj == NULL)
- {
- ObDereferenceObject(InputWindowStation);
- return(FALSE);
- }
- if (!IntIsPrimarySurface(SurfObj) || MouseEnabled == FALSE)
+ ppdev = GDIDEV(SurfObj);
+
+ if(ppdev == NULL)
{
- ObDereferenceObject(InputWindowStation);
return(FALSE);
}
+
+ pgp = &ppdev->Pointer;
- if (SPS_ACCEPT_NOEXCLUDE == GDIDEV(SurfObj)->PointerStatus)
+ if (SPS_ACCEPT_NOEXCLUDE == pgp->Status)
{
- /* Hardware cursor, no need to remove it */
- ObDereferenceObject(InputWindowStation);
return(FALSE);
}
-
- if(!(Cursor = CurInfo->CurrentCursorObject))
- {
- ObDereferenceObject(InputWindowStation);
- return(FALSE);
- }
if (HazardX1 > HazardX2)
{
@@ -145,182 +68,174 @@
tmp = HazardY2; HazardY2 = HazardY1; HazardY1 = tmp;
}
- if (CurInfo->PointerRectRight >= HazardX1
- && CurInfo->PointerRectLeft <= HazardX2
- && CurInfo->PointerRectBottom >= HazardY1
- && CurInfo->PointerRectTop <= HazardY2)
+ pt.x = pgp->Pos.x - pgp->HotSpot.x;
+ pt.y = pgp->Pos.y - pgp->HotSpot.y;
+
+ if (pt.x + pgp->Size.cx >= HazardX1
+ && pt.x <= HazardX2
+ && pt.y + pgp->Size.cy >= HazardY1
+ && pt.y <= HazardY2)
{
- /* Mouse is not allowed to move if GDI is busy drawing */
- ExAcquireFastMutex(&CurInfo->CursorMutex);
- if (0 != CurInfo->SafetyRemoveCount++)
+ if (0 != pgp->SafetyRemoveCount++)
{
- /* Was already removed */
- ExReleaseFastMutex(&CurInfo->CursorMutex);
- ObDereferenceObject(InputWindowStation);
return FALSE;
}
- CurInfo->SafetySwitch = TRUE;
- if (GDIDEVFUNCS(SurfObj).MovePointer)
- GDIDEVFUNCS(SurfObj).MovePointer(SurfObj, -1, -1, NULL);
+ pgp->SafetySwitch = TRUE;
+ if (pgp->MovePointer)
+ pgp->MovePointer(SurfObj, -1, -1, NULL);
else
- EngMovePointer(SurfObj, -1, -1, NULL);
- ExReleaseFastMutex(&CurInfo->CursorMutex);
+ EngMovePointer(SurfObj, -1, -1, NULL);
}
-
- ObDereferenceObject(InputWindowStation);
- return(TRUE);
-}
-VOID FASTCALL
-SetPointerRect(PSYSTEM_CURSORINFO CurInfo, PRECTL PointerRect)
-{
- CurInfo->PointerRectLeft = PointerRect->left;
- CurInfo->PointerRectRight = PointerRect->right;
- CurInfo->PointerRectTop = PointerRect->top;
- CurInfo->PointerRectBottom = PointerRect->bottom;
+ return(TRUE);
}
-INT FASTCALL
+INT INTERNAL_CALL
MouseSafetyOnDrawEnd(SURFOBJ *SurfObj)
/*
* FUNCTION: Notify the mouse driver that drawing has finished on a surface.
*/
{
- PSYSTEM_CURSORINFO CurInfo;
- BOOL MouseEnabled = FALSE;
- RECTL PointerRect;
-
- if(IntGetWindowStationObject(InputWindowStation))
- {
- CurInfo = IntGetSysCursorInfo(InputWindowStation);
- }
- else
- return FALSE;
-
- ExAcquireFastMutex(&CurInfo->CursorMutex);
- if(SurfObj == NULL)
- {
- ExReleaseFastMutex(&CurInfo->CursorMutex);
- ObDereferenceObject(InputWindowStation);
- return FALSE;
- }
+ GDIDEVICE *ppdev;
+ GDIPOINTER *pgp;
+
+ ASSERT(SurfObj != NULL);
+
+ ppdev = GDIDEV(SurfObj);
- MouseEnabled = CurInfo->Enabled && CurInfo->ShowingCursor;
- if (!IntIsPrimarySurface(SurfObj) || MouseEnabled == FALSE)
+ if(ppdev == NULL)
{
- ExReleaseFastMutex(&CurInfo->CursorMutex);
- ObDereferenceObject(InputWindowStation);
return(FALSE);
}
- if (SPS_ACCEPT_NOEXCLUDE == GDIDEV(SurfObj)->PointerStatus)
- {
- /* Hardware cursor, it wasn't removed so need to restore it */
- ExReleaseFastMutex(&CurInfo->CursorMutex);
- ObDereferenceObject(InputWindowStation);
- return(FALSE);
- }
-
- if (CurInfo->SafetySwitch)
+ pgp = &ppdev->Pointer;
+
+ if(SPS_ACCEPT_NOEXCLUDE == pgp->Status)
+ {
+ return FALSE;
+ }
+
+ if (pgp->SafetySwitch)
{
- if (1 < CurInfo->SafetyRemoveCount--)
+ if (1 < pgp->SafetyRemoveCount--)
{
/* Someone else removed it too, let them restore it */
- ExReleaseFastMutex(&CurInfo->CursorMutex);
- ObDereferenceObject(InputWindowStation);
return FALSE;
}
- if (GDIDEVFUNCS(SurfObj).MovePointer)
- GDIDEVFUNCS(SurfObj).MovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
+ if (pgp->MovePointer)
+ pgp->MovePointer(SurfObj, pgp->Pos.x, pgp->Pos.y, NULL);
else
- EngMovePointer(SurfObj, CurInfo->x, CurInfo->y, &PointerRect);
- SetPointerRect(CurInfo, &PointerRect);
- CurInfo->SafetySwitch = FALSE;
+ EngMovePointer(SurfObj, pgp->Pos.x, pgp->Pos.y, NULL);
+ pgp->SafetySwitch = FALSE;
}
- ExReleaseFastMutex(&CurInfo->CursorMutex);
- ObDereferenceObject(InputWindowStation);
return(TRUE);
}
/* SOFTWARE MOUSE POINTER IMPLEMENTATION **************************************/
-VOID FASTCALL
+VOID INTERNAL_CALL
IntHideMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
{
- if (ppdev->PointerAttributes.Enable == FALSE)
+ GDIPOINTER *pgp;
+ POINTL pt;
+
+ ASSERT(ppdev);
+ ASSERT(DestSurface);
+
+ pgp = &ppdev->Pointer;
+
+ if (!pgp->Enabled)
{
return;
}
- ppdev->PointerAttributes.Enable = FALSE;
-
- if (ppdev->PointerAttributes.Column + ppdev->PointerHotSpot.x == -1)
+ pgp->Enabled = FALSE;
+
+ if(pgp->Pos.x == -1)
{
return;
}
+
+ pt.x = pgp->Pos.x - pgp->HotSpot.x;
+ pt.y = pgp->Pos.y - pgp->HotSpot.y;
- if (ppdev->PointerSaveSurface != NULL)
+ if (pgp->SaveSurface != NULL)
{
RECTL DestRect;
POINTL SrcPoint;
SURFOBJ *SaveSurface;
SURFOBJ *MaskSurface;
- DestRect.left = max(ppdev->PointerAttributes.Column, 0);
- DestRect.top = max(ppdev->PointerAttributes.Row, 0);
+ DestRect.left = max(pt.x, 0);
+ DestRect.top = max(pt.y, 0);
DestRect.right = min(
- ppdev->PointerAttributes.Column + ppdev->PointerAttributes.Width,
+ pt.x + pgp->Size.cx,
DestSurface->sizlBitmap.cx);
DestRect.bottom = min(
- ppdev->PointerAttributes.Row + ppdev->PointerAttributes.Height,
+ pt.y + pgp->Size.cy,
DestSurface->sizlBitmap.cy);
- SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0);
- SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0);
+ SrcPoint.x = max(-pt.x, 0);
+ SrcPoint.y = max(-pt.y, 0);
- SaveSurface = EngLockSurface(ppdev->PointerSaveSurface);
- MaskSurface = EngLockSurface(ppdev->PointerMaskSurface);
- EngBitBlt(DestSurface, SaveSurface, MaskSurface, NULL, NULL,
- &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, SRCCOPY);
- EngUnlockSurface(MaskSurface);
- EngUnlockSurface(SaveSurface);
+ if((SaveSurface = EngLockSurface(pgp->SaveSurface)))
+ {
+ if((MaskSurface = EngLockSurface(pgp->MaskSurface)))
+ {
+ EngBitBlt(DestSurface, SaveSurface, MaskSurface, NULL, NULL,
+ &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, SRCCOPY);
+ EngUnlockSurface(MaskSurface);
+ }
+ EngUnlockSurface(SaveSurface);
+ }
}
}
-VOID FASTCALL
+VOID INTERNAL_CALL
IntShowMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
{
- if (ppdev->PointerAttributes.Enable == TRUE)
+ GDIPOINTER *pgp;
+ SURFOBJ *SaveSurface;
+ POINTL pt;
+
+ ASSERT(ppdev);
+ ASSERT(DestSurface);
+
+ pgp = &ppdev->Pointer;
+
+ if (pgp->Enabled)
{
return;
}
- ppdev->PointerAttributes.Enable = TRUE;
+ pgp->Enabled = TRUE;
+
+ pt.x = pgp->Pos.x - pgp->HotSpot.x;
+ pt.y = pgp->Pos.y - pgp->HotSpot.y;
/*
* Copy the pixels under the cursor to temporary surface.
*/
-
- if (ppdev->PointerSaveSurface != NULL)
+
+ if (pgp->SaveSurface != NULL &&
+ (SaveSurface = EngLockSurface(pgp->SaveSurface)))
{
RECTL DestRect;
POINTL SrcPoint;
- SURFOBJ *SaveSurface;
- SrcPoint.x = max(ppdev->PointerAttributes.Column, 0);
- SrcPoint.y = max(ppdev->PointerAttributes.Row, 0);
+ SrcPoint.x = max(pt.x, 0);
+ SrcPoint.y = max(pt.y, 0);
- DestRect.left = SrcPoint.x - ppdev->PointerAttributes.Column;
- DestRect.top = SrcPoint.y - ppdev->PointerAttributes.Row;
+ DestRect.left = SrcPoint.x - pt.x;
+ DestRect.top = SrcPoint.y - pt.y;
DestRect.right = min(
- ppdev->PointerAttributes.Width,
- DestSurface->sizlBitmap.cx - ppdev->PointerAttributes.Column);
+ pgp->Size.cx,
+ DestSurface->sizlBitmap.cx - pt.x);
DestRect.bottom = min(
- ppdev->PointerAttributes.Height,
- DestSurface->sizlBitmap.cy - ppdev->PointerAttributes.Row);
+ pgp->Size.cy,
+ DestSurface->sizlBitmap.cy - pt.y);
- SaveSurface = EngLockSurface(ppdev->PointerSaveSurface);
EngBitBlt(SaveSurface, DestSurface, NULL, NULL, NULL,
&DestRect, &SrcPoint, NULL, NULL, NULL, SRCCOPY);
EngUnlockSurface(SaveSurface);
@@ -336,35 +251,40 @@
SURFOBJ *ColorSurf;
SURFOBJ *MaskSurf;
- DestRect.left = max(ppdev->PointerAttributes.Column, 0);
- DestRect.top = max(ppdev->PointerAttributes.Row, 0);
+ DestRect.left = max(pt.x, 0);
+ DestRect.top = max(pt.y, 0);
DestRect.right = min(
- ppdev->PointerAttributes.Column + ppdev->PointerAttributes.Width,
+ pt.x + pgp->Size.cx,
DestSurface->sizlBitmap.cx);
DestRect.bottom = min(
- ppdev->PointerAttributes.Row + ppdev->PointerAttributes.Height,
+ pt.y + pgp->Size.cy,
DestSurface->sizlBitmap.cy);
- SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0);
- SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0);
+ SrcPoint.x = max(-pt.x, 0);
+ SrcPoint.y = max(-pt.y, 0);
- MaskSurf = EngLockSurface(ppdev->PointerMaskSurface);
- if (ppdev->PointerColorSurface != NULL)
+ MaskSurf = EngLockSurface(pgp->MaskSurface);
+ if (MaskSurf != NULL)
{
- ColorSurf = EngLockSurface(ppdev->PointerColorSurface);
- EngBitBlt(DestSurface, ColorSurf, MaskSurf, NULL, ppdev->PointerXlateObject,
- &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, 0xAACC);
- EngUnlockSurface(ColorSurf);
- }
- else
- {
- EngBitBlt(DestSurface, MaskSurf, NULL, NULL, ppdev->PointerXlateObject,
- &DestRect, &SrcPoint, NULL, NULL, NULL, SRCAND);
- SrcPoint.y += ppdev->PointerAttributes.Height;
- EngBitBlt(DestSurface, MaskSurf, NULL, NULL, ppdev->PointerXlateObject,
- &DestRect, &SrcPoint, NULL, NULL, NULL, SRCINVERT);
+ if (pgp->ColorSurface != NULL)
+ {
+ if((ColorSurf = EngLockSurface(pgp->ColorSurface)))
+ {
+ EngBitBlt(DestSurface, ColorSurf, MaskSurf, NULL, pgp->XlateObject,
+ &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, 0xAACC);
+ EngUnlockSurface(ColorSurf);
+ }
+ }
+ else
+ {
+ EngBitBlt(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
+ &DestRect, &SrcPoint, NULL, NULL, NULL, SRCAND);
+ SrcPoint.y += pgp->Size.cy;
+ EngBitBlt(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
+ &DestRect, &SrcPoint, NULL, NULL, NULL, SRCINVERT);
+ }
+ EngUnlockSurface(MaskSurf);
}
- EngUnlockSurface(MaskSurf);
}
}
@@ -385,45 +305,55 @@
IN RECTL *prcl,
IN FLONG fl)
{
- GDIDEVICE *ppdev = (GDIDEVICE *)pso->hdev;
+ GDIDEVICE *ppdev;
SURFOBJ *TempSurfObj;
-
+ GDIPOINTER *pgp;
+
+ ASSERT(pso);
+
+ ppdev = GDIDEV(pso);
+ pgp = &ppdev->Pointer;
+
IntHideMousePointer(ppdev, pso);
- if (ppdev->PointerColorSurface != NULL)
+ if (pgp->ColorSurface != NULL)
{
/* FIXME: Is this really needed? */
- TempSurfObj = EngLockSurface(ppdev->PointerColorSurface);
- EngFreeMem(TempSurfObj->pvBits);
- TempSurfObj->pvBits = 0;
- EngUnlockSurface(TempSurfObj);
+ if((TempSurfObj = EngLockSurface(pgp->ColorSurface)))
+ {
+ EngFreeMem(TempSurfObj->pvBits);
+ TempSurfObj->pvBits = 0;
+ EngUnlockSurface(TempSurfObj);
+ }
- EngDeleteSurface(ppdev->PointerColorSurface);
- ppdev->PointerMaskSurface = NULL;
+ EngDeleteSurface(pgp->ColorSurface);
+ pgp->MaskSurface = NULL;
}
- if (ppdev->PointerMaskSurface != NULL)
+ if (pgp->MaskSurface != NULL)
{
/* FIXME: Is this really needed? */
- TempSurfObj = EngLockSurface(ppdev->PointerMaskSurface);
- EngFreeMem(TempSurfObj->pvBits);
- TempSurfObj->pvBits = 0;
- EngUnlockSurface(TempSurfObj);
+ if((TempSurfObj = EngLockSurface(pgp->MaskSurface)))
+ {
+ EngFreeMem(TempSurfObj->pvBits);
+ TempSurfObj->pvBits = 0;
+ EngUnlockSurface(TempSurfObj);
+ }
- EngDeleteSurface(ppdev->PointerMaskSurface);
- ppdev->PointerMaskSurface = NULL;
+ EngDeleteSurface(pgp->MaskSurface);
+ pgp->MaskSurface = NULL;
}
- if (ppdev->PointerSaveSurface != NULL)
+ if (pgp->SaveSurface != NULL)
{
- EngDeleteSurface(ppdev->PointerSaveSurface);
- ppdev->PointerSaveSurface = NULL;
+ EngDeleteSurface(pgp->SaveSurface);
+ pgp->SaveSurface = NULL;
}
- if (ppdev->PointerXlateObject != NULL)
+ if (pgp->XlateObject != NULL)
{
- EngDeleteXlate(ppdev->PointerXlateObject);
- ppdev->PointerXlateObject = NULL;
+ EngDeleteXlate(pgp->XlateObject);
+ pgp->XlateObject = NULL;
}
/*
@@ -435,51 +365,49 @@
return SPS_ACCEPT_NOEXCLUDE;
}
- ppdev->PointerHotSpot.x = xHot;
- ppdev->PointerHotSpot.y = yHot;
+ pgp->HotSpot.x = xHot;
+ pgp->HotSpot.y = yHot;
- ppdev->PointerAttributes.Column = x - xHot;
- ppdev->PointerAttributes.Row = y - yHot;
- ppdev->PointerAttributes.Width = abs(psoMask->lDelta) << 3;
- ppdev->PointerAttributes.Height = (psoMask->cjBits / abs(psoMask->lDelta)) >> 1;
+ pgp->Pos.x = x;
+ pgp->Pos.y = y;
+ pgp->Size.cx = abs(psoMask->lDelta) << 3;
+ pgp->Size.cy = (psoMask->cjBits / abs(psoMask->lDelta)) >> 1;
if (prcl != NULL)
{
- prcl->left = ppdev->PointerAttributes.Column;
- prcl->top = ppdev->PointerAttributes.Row;
- prcl->right = prcl->left + ppdev->PointerAttributes.Width;
- prcl->bottom = prcl->top + ppdev->PointerAttributes.Height;
+ /* FIXME - right rectangle when x == -1? */
+ prcl->left = pgp->Pos.x - pgp->HotSpot.x;
+ prcl->top = pgp->Pos.y - pgp->HotSpot.x;
+ prcl->right = prcl->left + pgp->Size.cx;
+ prcl->bottom = prcl->top + pgp->Size.cy;
}
if (psoColor != NULL)
{
- SIZEL Size;
PBYTE Bits;
- Size.cx = ppdev->PointerAttributes.Width;
- Size.cy = ppdev->PointerAttributes.Height;
Bits = EngAllocMem(0, psoColor->cjBits, TAG_MOUSE);
memcpy(Bits, psoColor->pvBits, psoColor->cjBits);
- ppdev->PointerColorSurface = (HSURF)EngCreateBitmap(Size,
+ pgp->ColorSurface = (HSURF)EngCreateBitmap(pgp->Size,
psoColor->lDelta, psoColor->iBitmapFormat,
psoColor->lDelta < 0 ? 0 : BMF_TOPDOWN, Bits);
}
else
{
- ppdev->PointerColorSurface = NULL;
+ pgp->ColorSurface = NULL;
}
{
SIZEL Size;
PBYTE Bits;
- Size.cx = ppdev->PointerAttributes.Width;
- Size.cy = ppdev->PointerAttributes.Height << 1;
+ Size.cx = pgp->Size.cx;
+ Size.cy = pgp->Size.cy << 1;
Bits = EngAllocMem(0, psoMask->cjBits, TAG_MOUSE);
memcpy(Bits, psoMask->pvBits, psoMask->cjBits);
- ppdev->PointerMaskSurface = (HSURF)EngCreateBitmap(Size,
+ pgp->MaskSurface = (HSURF)EngCreateBitmap(Size,
psoMask->lDelta, psoMask->iBitmapFormat,
psoMask->lDelta < 0 ? 0 : BMF_TOPDOWN, Bits);
}
@@ -493,20 +421,18 @@
{
HPALETTE BWPalette, DestPalette;
ULONG BWColors[] = {0, 0xFFFFFF};
- PDC Dc;
BWPalette = EngCreatePalette(PAL_INDEXED, sizeof(BWColors) / sizeof(ULONG),
BWColors, 0, 0, 0);
- Dc = DC_LockDc(IntGetScreenDC());
- DestPalette = Dc->w.hPalette;
- DC_UnlockDc(IntGetScreenDC());
- ppdev->PointerXlateObject = IntEngCreateXlate(0, PAL_INDEXED,
+
+ DestPalette = ppdev->DevInfo.hpalDefault;
+ pgp->XlateObject = IntEngCreateXlate(0, PAL_INDEXED,
DestPalette, BWPalette);
EngDeletePalette(BWPalette);
}
else
{
- ppdev->PointerXlateObject = pxlo;
+ pgp->XlateObject = pxlo;
}
/*
@@ -514,28 +440,41 @@
*/
{
- SIZEL Size;
LONG lDelta;
- Size.cx = ppdev->PointerAttributes.Width;
- Size.cy = ppdev->PointerAttributes.Height;
-
switch (pso->iBitmapFormat)
{
- case BMF_1BPP: lDelta = Size.cx >> 3; break;
- case BMF_4BPP: lDelta = Size.cx >> 1; break;
- case BMF_8BPP: lDelta = Size.cx; break;
- case BMF_16BPP: lDelta = Size.cx << 1; break;
- case BMF_24BPP: lDelta = Size.cx * 3; break;
- case BMF_32BPP: lDelta = Size.cx << 2; break;
- default: lDelta = 0; break;
+ case BMF_1BPP:
+ lDelta = pgp->Size.cx >> 3;
+ break;
+ case BMF_4BPP:
+ lDelta = pgp->Size.cx >> 1;
+ break;
+ case BMF_8BPP:
+ lDelta = pgp->Size.cx;
+ break;
+ case BMF_16BPP:
+ lDelta = pgp->Size.cx << 1;
+ break;
+ case BMF_24BPP:
+ lDelta = pgp->Size.cx * 3;
+ break;
+ case BMF_32BPP:
+ lDelta = pgp->Size.cx << 2;
+ break;
+ default:
+ lDelta = 0;
+ break;
}
- ppdev->PointerSaveSurface = (HSURF)EngCreateBitmap(
- Size, lDelta, pso->iBitmapFormat, BMF_TOPDOWN | BMF_NOZEROINIT, NULL);
+ pgp->SaveSurface = (HSURF)EngCreateBitmap(
+ pgp->Size, lDelta, pso->iBitmapFormat, BMF_TOPDOWN | BMF_NOZEROINIT, NULL);
}
- IntShowMousePointer(ppdev, pso);
+ if(x != -1)
+ {
+ IntShowMousePointer(ppdev, pso);
+ }
return SPS_ACCEPT_EXCLUDE;
}
@@ -551,22 +490,33 @@
IN LONG y,
IN RECTL *prcl)
{
- GDIDEVICE *ppdev = (GDIDEVICE *)pso->hdev;
+ GDIDEVICE *ppdev;
+ GDIPOINTER *pgp;
+ ASSERT(pso);
+
+ ppdev = GDIDEV(pso);
+
+ ASSERT(ppdev);
+
+ pgp = &ppdev->Pointer;
+
+
IntHideMousePointer(ppdev, pso);
- ppdev->PointerAttributes.Column = x - ppdev->PointerHotSpot.x;
- ppdev->PointerAttributes.Row = y - ppdev->PointerHotSpot.y;
if (x != -1)
{
- IntShowMousePointer(ppdev, pso);
+ pgp->Pos.x = x;
+ pgp->Pos.y = y;
+ IntShowMousePointer(ppdev, pso);
}
if (prcl != NULL)
{
- prcl->left = ppdev->PointerAttributes.Column;
- prcl->top = ppdev->PointerAttributes.Row;
- prcl->right = prcl->left + ppdev->PointerAttributes.Width;
- prcl->bottom = prcl->top + ppdev->PointerAttributes.Height;
+ /* FIXME - right rectangle when x == -1? */
+ prcl->left = pgp->Pos.x - pgp->HotSpot.x;
+ prcl->top = pgp->Pos.y - pgp->HotSpot.x;
+ prcl->right = prcl->left + pgp->Size.cx;
+ prcl->bottom = prcl->top + pgp->Size.cy;
}
}
reactos/subsys/win32k/eng
diff -u -r1.32 -r1.33
--- objects.h 3 Jul 2004 13:55:35 -0000 1.32
+++ objects.h 12 Dec 2004 01:40:36 -0000 1.33
@@ -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: objects.h,v 1.32 2004/07/03 13:55:35 navaraf Exp $
+/* $Id: objects.h,v 1.33 2004/12/12 01:40:36 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -34,8 +34,6 @@
/* Structure of internal gdi objects that win32k manages for ddi engine:
|---------------------------------|
- | EngObj |
- |---------------------------------|
| Public part |
| accessed from engine |
|---------------------------------|
@@ -45,21 +43,8 @@
---------------------------------------------------------------------------*/
-typedef struct _ENGOBJ {
- ULONG hObj;
- ULONG InternalSize;
- ULONG UserSize;
-} ENGOBJ, *PENGOBJ;
-
typedef struct _CLIPGDI {
- ENGOBJ Header;
- CLIPOBJ ClipObj;
- /* ei what were these for?
- ULONG NumRegionRects;
- ULONG NumIntersectRects;
- RECTL *RegionRects;
- RECTL *IntersectRects;
- */
+ CLIPOBJ ClipObj;
ULONG EnumPos;
ULONG EnumOrder;
ULONG EnumMax;
@@ -73,12 +58,11 @@
} DRVFUNCTIONSGDI;
typedef struct _FLOATGDI {
-
+ ULONG Dummy;
} FLOATGDI;
typedef struct _FONTGDI {
- ENGOBJ Header;
- FONTOBJ FontObj;
+ FONTOBJ FontObj;
LPCWSTR Filename;
FT_Face face;
@@ -86,13 +70,11 @@
} FONTGDI, *PFONTGDI;
typedef struct _PATHGDI {
- ENGOBJ Header;
- PATHOBJ PathObj;
+ PATHOBJ PathObj;
} PATHGDI;
typedef struct _STRGDI {
- ENGOBJ Header;
- STROBJ StrObj;
+ STROBJ StrObj;
} STRGDI;
typedef BOOL STDCALL (*PFN_BitBlt)(SURFOBJ *, SURFOBJ *, SURFOBJ *, CLIPOBJ *,
@@ -141,12 +123,11 @@
typedef BOOL STDCALL (*PFN_GradientFill)(SURFOBJ*, CLIPOBJ*, XLATEOBJ*, TRIVERTEX*, ULONG, PVOID, ULONG, RECTL*, POINTL*, ULONG);
typedef struct _XFORMGDI {
- ENGOBJ Header;
+ ULONG Dummy;
/* XFORMOBJ has no public members */
} XFORMGDI;
typedef struct _XLATEGDI {
- ENGOBJ Header;
XLATEOBJ XlateObj;
HPALETTE DestPal;
HPALETTE SourcePal;
@@ -170,4 +151,10 @@
// };
} XLATEGDI;
+/* as the *OBJ structures are located at the beginning of the *GDI structures
+ we can simply typecast the pointer */
+#define ObjToGDI(ClipObj, Type) (Type##GDI *)(ClipObj)
+#define GDIToObj(ClipGDI, Type) (Type##OBJ *)(ClipGDI)
+
+
#endif //__ENG_OBJECTS_H
reactos/subsys/win32k/eng
diff -u -r1.44 -r1.45
--- surface.c 7 Jul 2004 16:33:44 -0000 1.44
+++ surface.c 12 Dec 2004 01:40:36 -0000 1.45
@@ -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: surface.c,v 1.44 2004/07/07 16:33:44 navaraf Exp $
+/* $Id: surface.c,v 1.45 2004/12/12 01:40:36 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -481,7 +481,13 @@
SURFOBJ * STDCALL
EngLockSurface(IN HSURF Surface)
{
- return &((BITMAPOBJ*)BITMAPOBJ_LockBitmap(Surface))->SurfObj;
+ BITMAPOBJ *bmp = (BITMAPOBJ*)BITMAPOBJ_LockBitmap(Surface);
+ if(bmp != NULL)
+ {
+ return &bmp->SurfObj;
+ }
+
+ return NULL;
}
/*
@@ -490,6 +496,7 @@
VOID STDCALL
EngUnlockSurface(IN SURFOBJ *Surface)
{
- BITMAPOBJ_UnlockBitmap ( Surface->hsurf );
+ ASSERT (Surface);
+ BITMAPOBJ_UnlockBitmap (Surface->hsurf);
}
/* EOF */
reactos/subsys/win32k/eng
diff -u -r1.42 -r1.43
--- xlate.c 15 Jul 2004 21:14:51 -0000 1.42
+++ xlate.c 12 Dec 2004 01:40:36 -0000 1.43
@@ -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: xlate.c,v 1.42 2004/07/15 21:14:51 navaraf Exp $
+/* $Id: xlate.c,v 1.43 2004/12/12 01:40:36 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -29,7 +29,8 @@
#include <w32k.h>
-static ULONG FASTCALL ShiftAndMask(XLATEGDI *XlateGDI, ULONG Color)
+static inline ULONG
+ShiftAndMask(XLATEGDI *XlateGDI, ULONG Color)
{
ULONG TranslatedColor;
@@ -50,62 +51,65 @@
}
-ULONG STDCALL
+static inline ULONG
ClosestColorMatch(XLATEGDI *XlateGDI, LPPALETTEENTRY SourceColor,
PALETTEENTRY *DestColors, ULONG NumColors)
{
ULONG SourceRed, SourceGreen, SourceBlue;
- ULONG cxRed, cxGreen, cxBlue, Rating, BestMatch = 16777215;
+ ULONG cxRed, cxGreen, cxBlue, Rating, BestMatch = 0xFFFFFF;
ULONG CurrentIndex, BestIndex = 0;
SourceRed = SourceColor->peRed;
SourceGreen = SourceColor->peGreen;
SourceBlue = SourceColor->peBlue;
- for (CurrentIndex = 0; CurrentIndex < NumColors; CurrentIndex++)
+ for (CurrentIndex = 0; CurrentIndex < NumColors; CurrentIndex++, DestColors++)
{
- cxRed = abs((SHORT)SourceRed - (SHORT)DestColors[CurrentIndex].peRed);
+ cxRed = abs((SHORT)SourceRed - (SHORT)DestColors->peRed);
cxRed *= cxRed;
- cxGreen = abs((SHORT)SourceGreen - (SHORT)DestColors[CurrentIndex].peGreen);
+ cxGreen = abs((SHORT)SourceGreen - (SHORT)DestColors->peGreen);
cxGreen *= cxGreen;
- cxBlue = abs((SHORT)SourceBlue - (SHORT)DestColors[CurrentIndex].peBlue);
+ cxBlue = abs((SHORT)SourceBlue - (SHORT)DestColors->peBlue);
cxBlue *= cxBlue;
Rating = cxRed + cxGreen + cxBlue;
+
+ if (Rating == 0)
+ {
+ /* Exact match */
+ BestIndex = CurrentIndex;
+ break;
+ }
if (Rating < BestMatch)
{
BestIndex = CurrentIndex;
BestMatch = Rating;
}
-
- /* Exact match */
- if (Rating == 0)
- break;
}
return BestIndex;
}
-static VOID STDCALL
+static inline VOID
BitMasksFromPal(USHORT PalType, PPALGDI Palette,
PULONG RedMask, PULONG BlueMask, PULONG GreenMask)
{
- static const union { PALETTEENTRY Color; ULONG Mask; } Red = {{255, 0, 0}};
- static const union { PALETTEENTRY Color; ULONG Mask; } Green = {{0, 255, 0}};
- static const union { PALETTEENTRY Color; ULONG Mask; } Blue = {{0, 0, 255}};
+ static const union { PALETTEENTRY Color; ULONG Mask; } Red = {{0xFF, 0x00, 0x00}};
+ static const union { PALETTEENTRY Color; ULONG Mask; } Green = {{0x00, 0xFF, 0x00}};
+ static const union { PALETTEENTRY Color; ULONG Mask; } Blue = {{0x00, 0x00, 0xFF}};
switch (PalType)
{
case PAL_RGB:
- *RedMask = RGB(255, 0, 0);
- *GreenMask = RGB(0, 255, 0);
- *BlueMask = RGB(0, 0, 255);
+ *RedMask = RGB(0xFF, 0x00, 0x00);
+ *GreenMask = RGB(0x00, 0xFF, 0x00);
+ *BlueMask = RGB(0x00, 0x00, 0xFF);
break;
case PAL_BGR:
- *RedMask = RGB(0, 0, 255);
- *GreenMask = RGB(0, 255, 0);
- *BlueMask = RGB(255, 0, 0);
+ *RedMask = RGB(0x00, 0x00, 0xFF);
+ *GreenMask = RGB(0x00, 0xFF, 0x00);
+ *BlueMask = RGB(0xFF, 0x00, 0x00);
break;
case PAL_BITFIELDS:
*RedMask = Palette->RedMask;
@@ -124,7 +128,8 @@
* Calculate the number of bits Mask must be shift to the left to get a
* 1 in the most significant bit position
*/
-static INT FASTCALL CalculateShift(ULONG Mask)
+static inline INT
+CalculateShift(ULONG Mask)
{
ULONG Shift = 0;
ULONG LeftmostBit = 1 << (8 * sizeof(ULONG) - 1);
@@ -138,11 +143,10 @@
return Shift;
}
-XLATEOBJ* STDCALL
+XLATEOBJ* FASTCALL
IntEngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
HPALETTE PaletteDest, HPALETTE PaletteSource)
{
- ULONG NewXlate;
XLATEOBJ *XlateObj;
XLATEGDI *XlateGDI;
PALGDI *SourcePalGDI = 0;
@@ -151,9 +155,13 @@
ULONG DestRedMask, DestGreenMask, DestBlueMask;
ULONG i;
- NewXlate = CreateGDIHandle(sizeof(XLATEGDI), sizeof(XLATEOBJ), (PVOID*)&XlateGDI, (PVOID*)&XlateObj);
- if (!ValidEngHandle(NewXlate))
+ XlateGDI = EngAllocMem(0, sizeof(XLATEGDI), TAG_XLATEOBJ);
+ if (XlateGDI == NULL)
+ {
+ DPRINT1("Failed to allocate memory for a XLATE structure!\n");
return NULL;
+ }
+ XlateObj = GDIToObj(XlateGDI, XLATE);
if (PaletteSource != NULL)
SourcePalGDI = PALETTE_LockPalette(PaletteSource);
@@ -270,20 +278,25 @@
return XlateObj;
}
-XLATEOBJ * STDCALL IntEngCreateMonoXlate(
+XLATEOBJ* FASTCALL
+IntEngCreateMonoXlate(
USHORT SourcePalType, HPALETTE PaletteDest, HPALETTE PaletteSource,
ULONG BackgroundColor)
{
- ULONG NewXlate;
XLATEOBJ *XlateObj;
XLATEGDI *XlateGDI;
PALGDI *SourcePalGDI;
- NewXlate = CreateGDIHandle(sizeof(XLATEGDI), sizeof(XLATEOBJ), (PVOID*)&XlateGDI, (PVOID*)&XlateObj);
- if (!ValidEngHandle(NewXlate))
+ XlateGDI = EngAllocMem(0, sizeof(XLATEGDI), TAG_XLATEOBJ);
+ if (XlateGDI == NULL)
+ {
+ DPRINT1("Failed to allocate memory for a XLATE structure!\n");
return NULL;
+ }
+ XlateObj = GDIToObj(XlateGDI, XLATE);
SourcePalGDI = PALETTE_LockPalette(PaletteSource);
+ /* FIXME - SourcePalGDI can be NULL!!! Handle this case instead of ASSERT! */
ASSERT(SourcePalGDI);
if (SourcePalType == 0)
@@ -329,12 +342,11 @@
return XlateObj;
}
-XLATEOBJ * STDCALL
+XLATEOBJ* FASTCALL
IntEngCreateSrcMonoXlate(HPALETTE PaletteDest,
ULONG ForegroundColor,
ULONG BackgroundColor)
{
- ULONG NewXlate;
XLATEOBJ *XlateObj;
XLATEGDI *XlateGDI;
PALGDI *DestPalGDI;
@@ -343,14 +355,20 @@
if (DestPalGDI == NULL)
return NULL;
- NewXlate = CreateGDIHandle(sizeof(XLATEGDI), sizeof(XLATEOBJ), (PVOID*)&XlateGDI, (PVOID*)&XlateObj);
- if (!ValidEngHandle(NewXlate))
+ XlateGDI = EngAllocMem(0, sizeof(XLATEGDI), TAG_XLATEOBJ);
+ if (XlateGDI == NULL)
+ {
+ PALETTE_UnlockPalette(PaletteDest);
+ DPRINT1("Failed to allocate memory for a XLATE structure!\n");
return NULL;
+ }
+ XlateObj = GDIToObj(XlateGDI, XLATE);
XlateGDI->translationTable = EngAllocMem(0, sizeof(ULONG) * 2, 0);
if (XlateGDI->translationTable == NULL)
{
- FreeGDIHandle(NewXlate);
+ PALETTE_UnlockPalette(PaletteDest);
+ EngFreeMem(XlateGDI);
return NULL;
}
@@ -368,9 +386,9 @@
BitMasksFromPal(DestPalGDI->Mode, DestPalGDI, &XlateGDI->RedMask,
&XlateGDI->BlueMask, &XlateGDI->GreenMask);
- XlateGDI->RedShift = CalculateShift(RGB(255, 0, 0)) - CalculateShift(XlateGDI->RedMask);
- XlateGDI->GreenShift = CalculateShift(RGB(0, 255, 0)) - CalculateShift(XlateGDI->GreenMask);
- XlateGDI->BlueShift = CalculateShift(RGB(0, 0, 255)) - CalculateShift(XlateGDI->BlueMask);
+ XlateGDI->RedShift = CalculateShift(RGB(0xFF, 0x00, 0x00)) - CalculateShift(XlateGDI->RedMask);
+ XlateGDI->GreenShift = CalculateShift(RGB(0x00, 0xFF, 0x00)) - CalculateShift(XlateGDI->GreenMask);
+ XlateGDI->BlueShift = CalculateShift(RGB(0x00, 0x00, 0xFF)) - CalculateShift(XlateGDI->BlueMask);
XlateGDI->translationTable[0] = ShiftAndMask(XlateGDI, BackgroundColor);
XlateGDI->translationTable[1] = ShiftAndMask(XlateGDI, ForegroundColor);
@@ -403,7 +421,6 @@
EngDeleteXlate(XLATEOBJ *XlateObj)
{
XLATEGDI *XlateGDI;
- HANDLE HXlate;
if (XlateObj == NULL)
{
@@ -411,8 +428,7 @@
return;
}
- XlateGDI = (XLATEGDI *)AccessInternalObjectFromUserObject(XlateObj);
- HXlate = (HANDLE)AccessHandleFromUserObject(XlateObj);
+ XlateGDI = ObjToGDI(XlateObj, XLATE);
if ((XlateObj->flXlate & XO_TABLE) &&
XlateGDI->translationTable != NULL)
@@ -420,7 +436,7 @@
EngFreeMem(XlateGDI->translationTable);
}
- FreeGDIHandle((ULONG)HXlate);
+ EngFreeMem(XlateGDI);
}
/*
@@ -429,7 +445,7 @@
PULONG STDCALL
XLATEOBJ_piVector(XLATEOBJ *XlateObj)
{
- XLATEGDI *XlateGDI = (XLATEGDI*)AccessInternalObjectFromUserObject(XlateObj);
+ XLATEGDI *XlateGDI = ObjToGDI(XlateObj, XLATE);
if (XlateObj->iSrcType == PAL_INDEXED)
{
@@ -459,7 +475,7 @@
if (XlateObj->flXlate & XO_TABLE)
return XlateObj->pulXlate[Color];
- XlateGDI = (XLATEGDI *)AccessInternalObjectFromUserObject(XlateObj);
+ XlateGDI = ObjToGDI(XlateObj, XLATE);
if (XlateObj->flXlate & XO_TO_MONO)
return Color == XlateGDI->BackgroundColor;
@@ -472,17 +488,19 @@
{
/* FIXME: should we cache colors used often? */
/* FIXME: won't work if destination isn't indexed */
-
- /* Extract the destination palette. */
- PalGDI = PALETTE_LockPalette(XlateGDI->DestPal);
-
+
/* Convert the source color to the palette RGB format. */
Color = ShiftAndMask(XlateGDI, Color);
- /* Return closest match for the given color. */
- Closest = ClosestColorMatch(XlateGDI, (LPPALETTEENTRY)&Color, PalGDI->IndexedColors, PalGDI->NumColors);
- PALETTE_UnlockPalette(XlateGDI->DestPal);
- return Closest;
+ /* Extract the destination palette. */
+ PalGDI = PALETTE_LockPalette(XlateGDI->DestPal);
+ if(PalGDI != NULL)
+ {
+ /* Return closest match for the given color. */
+ Closest = ClosestColorMatch(XlateGDI, (LPPALETTEENTRY)&Color, PalGDI->IndexedColors, PalGDI->NumColors);
+ PALETTE_UnlockPalette(XlateGDI->DestPal);
+ return Closest;
+ }
}
return 0;
@@ -498,8 +516,9 @@
HPALETTE hPalette;
XLATEGDI *XlateGDI;
PALGDI *PalGDI;
+ ULONG *InPal;
- XlateGDI = (XLATEGDI*)AccessInternalObjectFromUserObject(XlateObj);
+ XlateGDI = ObjToGDI(XlateObj, XLATE);
if (PalOutType == XO_SRCPALETTE)
hPalette = XlateGDI->SourcePal;
else if (PalOutType == XO_DESTPALETTE)
@@ -508,10 +527,23 @@
UNIMPLEMENTED;
PalGDI = PALETTE_LockPalette(hPalette);
- RtlCopyMemory(OutPal, PalGDI->IndexedColors, sizeof(ULONG) * cPal);
- PALETTE_UnlockPalette(hPalette);
+ if(PalGDI != NULL)
+ {
+ /* copy the indexed colors into the buffer */
- return cPal;
+ for(InPal = (ULONG*)PalGDI->IndexedColors;
+ cPal > 0;
+ cPal--, InPal++, OutPal++)
+ {
+ *OutPal = *InPal;
+ }
+
+ PALETTE_UnlockPalette(hPalette);
+
+ return cPal;
+ }
+
+ return 0;
}
/* EOF */
reactos/subsys/win32k/eng
diff -N clip.h
--- clip.h 14 May 2004 22:56:18 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,44 +0,0 @@
-/*
- * ReactOS kernel
- * Copyright (C) 1998, 1999, 2000, 2001 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.
- */
-#ifndef __WIN32K_CLIP_H
-#define __WIN32K_CLIP_H
-
-typedef ULONG HCLIP;
-CLIPOBJ* STDCALL IntEngCreateClipRegion( ULONG count, PRECTL pRect, PRECTL rcBounds );
-VOID STDCALL IntEngDeleteClipRegion(CLIPOBJ *ClipObj);
-
-
-#define ENUM_RECT_LIMIT 50
-
-typedef struct _RECT_ENUM
-{
- ULONG c;
- RECTL arcl[ENUM_RECT_LIMIT];
-} RECT_ENUM;
-
-typedef struct tagSPAN
-{
- LONG Y;
- LONG X;
- ULONG Width;
-} SPAN, *PSPAN;
-
-BOOLEAN FASTCALL ClipobjToSpans(PSPAN *Spans, UINT *Count, CLIPOBJ *ClipRegion, PRECTL Boundary);
-
-#endif
reactos/subsys/win32k/eng
diff -N handle.c
--- handle.c 30 May 2004 14:01:12 -0000 1.16
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,134 +0,0 @@
-/*
- * 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.
- */
-/* $Id: handle.c,v 1.16 2004/05/30 14:01:12 weiden Exp $
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Manage GDI Handles
- * FILE: subsys/win32k/eng/handle.c
- * PROGRAMER: Jason Filby
- * REVISION HISTORY:
- * 29/8/1999: Created
- */
-#include <w32k.h>
-
-static int LastHandle = MAX_GDI_HANDLES;
-static GDI_HANDLE GDIHandles[MAX_GDI_HANDLES];
-
-ULONG FASTCALL CreateGDIHandle(ULONG InternalSize, ULONG UserSize, PVOID *InternalObject, PVOID *UserObject)
-{
- PENGOBJ pObj;
- int i;
-
- /* internal size includes header and user portions */
- pObj = EngAllocMem( FL_ZERO_MEMORY, InternalSize, 0 );
-
- if( !pObj )
- return 0;
-
- #if 0
- /* not used at the moment */
- pObj->InternalSize = InternalSize;
- pObj->UserSize = UserSize;
- #endif
-
- for( i = (MAX_GDI_HANDLES - 1 <= LastHandle ? 1 : LastHandle + 1); i != LastHandle;
- i = (MAX_GDI_HANDLES - 1 <= i ? 1 : i + 1) ){
- if( GDIHandles[ i ].pEngObj == NULL ){
- pObj->hObj = i;
- GDIHandles[ i ].pEngObj = pObj;
-
- *InternalObject = pObj;
- *UserObject = (PVOID)( (PCHAR)pObj + sizeof( ENGOBJ ) );
-
- DPRINT("CreateGDIHandle: obj: %x, handle: %d, usersize: %d\n", pObj, i, UserSize );
- LastHandle = i;
- return i;
- }
- }
- DPRINT1("CreateGDIHandle: Out of available handles!!!\n");
- EngFreeMem( pObj );
- return 0;
-}
-
-VOID FASTCALL FreeGDIHandle(ULONG Handle)
-{
- if( Handle == 0 || Handle >= MAX_GDI_HANDLES ){
- DPRINT1("FreeGDIHandle: invalid handle!!!!\n");
- return;
- }
- DPRINT("FreeGDIHandle: handle: %d\n", Handle);
- EngFreeMem( GDIHandles[Handle].pEngObj );
- GDIHandles[Handle].pEngObj = NULL;
-}
-
-PVOID FASTCALL AccessInternalObject(ULONG Handle)
-{
- PENGOBJ pEngObj;
-
- if (Handle == 0 || Handle >= MAX_GDI_HANDLES
- || !(pEngObj = GDIHandles[Handle].pEngObj))
- {
- DPRINT1("AccessInternalObject: invalid handle: %d!!!!\n", Handle);
- return NULL;
- }
-
- return (PVOID)pEngObj;
-}
-
-PVOID FASTCALL AccessUserObject(ULONG Handle)
-{
- PENGOBJ pEngObj;
-
- if (Handle == 0 || Handle >= MAX_GDI_HANDLES
- || !(pEngObj = GDIHandles[Handle].pEngObj))
- {
- DPRINT1("AccessUserObject: invalid handle: %d!!!!\n", Handle);
- return NULL;
- }
-
- return (PVOID)( (PCHAR)pEngObj + sizeof( ENGOBJ ) );
-}
-
-ULONG FASTCALL AccessHandleFromUserObject(PVOID UserObject)
-{
- PENGOBJ pEngObj;
- ULONG Handle;
-
- if( !UserObject )
- return INVALID_HANDLE;
-
- pEngObj = (PENGOBJ)((PCHAR) UserObject - sizeof( ENGOBJ ));
- Handle = pEngObj->hObj;
-
- if( Handle == 0 || Handle >= MAX_GDI_HANDLES ){
- DPRINT1("AccessHandleFromUserObject: inv handle: %d, obj: %x!!!!\n", Handle, pEngObj);
- return INVALID_HANDLE;
- }
- return Handle;
-}
-
-VOID FASTCALL InitEngHandleTable( void )
-{
- ULONG i;
- for( i=1; i < MAX_GDI_HANDLES; i++ ){
- GDIHandles[ i ].pEngObj = NULL;
- }
-}
-/* EOF */
reactos/subsys/win32k/eng
diff -N handle.h
--- handle.h 30 May 2004 14:01:12 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,44 +0,0 @@
-/*
- * ReactOS kernel
- * Copyright (C) 1998, 1999, 2000, 2001 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.
- */
-/* $Id: handle.h,v 1.6 2004/05/30 14:01:12 weiden Exp $
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Manage GDI Handle definitions
- * FILE: subsys/win32k/eng/handle.h
- * PROGRAMER: Jason Filby
- * REVISION HISTORY:
- * 29/8/1999: Created
- */
-#ifndef __ENG_HANDLE_H
-#define __ENG_HANDLE_H
-
-#include "objects.h"
-#include <include/object.h>
-
-typedef struct _GDI_HANDLE {
- PENGOBJ pEngObj;
-} GDI_HANDLE, *PGDI_HANDLE;
-
-#define INVALID_HANDLE 0
-#define MAX_GDI_HANDLES 4096
-
-#define ValidEngHandle( x ) (!( (x) == INVALID_HANDLE ))
-
-#endif
reactos/subsys/win32k/include
diff -N intddraw.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ intddraw.h 12 Dec 2004 01:40:37 -0000 1.2
@@ -0,0 +1,67 @@
+#ifndef _INT_W32k_DDRAW
+#define _INT_W32k_DDRAW
+
+#define GDI_OBJECT_TYPE_DIRECTDRAW 0x00600000
+#define GDI_OBJECT_TYPE_DD_SURFACE 0x00610000
+#define GDI_OBJECT_TYPE_DD_VIDEOPORT 0x00620000
+#define GDI_OBJECT_TYPE_DD_PALETTE 0x00630000
+#define GDI_OBJECT_TYPE_DD_CLIPPER 0x00640000
+#define GDI_OBJECT_TYPE_DD_MOTIONCOMP 0x00650000
+
+typedef struct
+{
+ DD_SURFACE_LOCAL Local;
+ DD_SURFACE_MORE More;
+ DD_SURFACE_GLOBAL Global;
+ DD_ATTACHLIST AttachList;
+ DD_ATTACHLIST AttachListFrom;
+ BOOL bComplete;
+} DD_SURFACE, *PDD_SURFACE;
+
+typedef struct
+{
+ DD_DIRECTDRAW_LOCAL Local;
+ DD_DIRECTDRAW_GLOBAL Global;
+ // Drv callbacks
+ PGD_GETDIRECTDRAWINFO DrvGetDirectDrawInfo;
+ PGD_DISABLEDIRECTDRAW DrvDisableDirectDraw;
+ // DD callbacks
+ PDD_CREATESURFACE DdCreateSurface;
+ PDD_SETCOLORKEY DdDrvSetColorKey; // ?????
+ PDD_WAITFORVERTICALBLANK DdWaitForVerticalBlank;
+ PDD_CANCREATESURFACE DdCanCreateSurface;
+ PDD_CREATEPALETTE DdCreatePalette;
+ PDD_GETSCANLINE DdGetScanLine;
+ PDD_MAPMEMORY DdMapMemory;
+ // Surface callbacks
+ PDD_SURFCB_DESTROYSURFACE DdDestroySurface;
+ PDD_SURFCB_FLIP DdFlip;
+ PDD_SURFCB_SETCLIPLIST DdSetClipList;
+ PDD_SURFCB_LOCK DdLock;
+ PDD_SURFCB_UNLOCK DdUnlock;
+ PDD_SURFCB_BLT DdBlt;
+ PDD_SURFCB_SETCOLORKEY DdSetColorKey;
+ PDD_SURFCB_ADDATTACHEDSURFACE DdAddAttachedSurface;
+ PDD_SURFCB_GETBLTSTATUS DdGetBltStatus;
+ PDD_SURFCB_GETFLIPSTATUS DdGetFlipStatus;
+ PDD_SURFCB_UPDATEOVERLAY DdUpdateOverlay;
+ PDD_SURFCB_SETOVERLAYPOSITION DdSetOverlayPosition;
+ PDD_SURFCB_SETPALETTE DdSetPalette;
+ // Palette callbacks
+ PDD_PALCB_DESTROYPALETTE DdDestroyPalette;
+ PDD_PALCB_SETENTRIES DdSetEntries;
+ // D3D Device context callbacks
+ PD3DNTHAL_CONTEXTCREATECB D3dContextCreate;
+ PD3DNTHAL_CONTEXTDESTROYCB D3dContextDestroy;
+ // D3D Buffer callbacks
+ PDD_CANCREATESURFACE DdCanCreateD3DBuffer;
+ PDD_CREATESURFACE DdCreateD3DBuffer;
+ PDD_SURFCB_DESTROYSURFACE DdDestroyD3DBuffer;
+ PDD_SURFCB_LOCK DdLockD3DBuffer;
+ PDD_SURFCB_UNLOCK DdUnlockD3DBuffer;
+} DD_DIRECTDRAW, *PDD_DIRECTDRAW;
+
+BOOL FASTCALL DD_Cleanup(PDD_DIRECTDRAW pDD);
+BOOL FASTCALL DDSURF_Cleanup(PDD_SURFACE pDDSurf);
+
+#endif /* _INT_W32k_DDRAW */
reactos/subsys/win32k/include
diff -u -r1.8 -r1.9
--- cursoricon.h 14 May 2004 23:57:32 -0000 1.8
+++ cursoricon.h 12 Dec 2004 01:40:37 -0000 1.9
@@ -31,12 +31,6 @@
BOOL SwapButtons;
UINT ButtonsDown;
LONG x, y;
- BOOL SafetySwitch;
- UINT SafetyRemoveCount;
- LONG PointerRectLeft;
- LONG PointerRectTop;
- LONG PointerRectRight;
- LONG PointerRectBottom;
FAST_MUTEX CursorMutex;
CURSORCLIP_INFO CursorClipInfo;
PCURICON_OBJECT CurrentCursorObject;
reactos/subsys/win32k/include
diff -u -r1.14 -r1.15
--- dce.h 4 Feb 2004 22:59:04 -0000 1.14
+++ dce.h 12 Dec 2004 01:40:37 -0000 1.15
@@ -37,10 +37,11 @@
} DCE; /* PDCE already declared at top of file */
#define DCEOBJ_AllocDCE() \
- ((HDCE) GDIOBJ_AllocObj (sizeof (DCE), GDI_OBJECT_TYPE_DCE, (GDICLEANUPPROC) DCE_InternalDelete))
-#define DCEOBJ_FreeDCE(hDCE) GDIOBJ_FreeObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE, GDIOBJFLAG_DEFAULT)
+ ((HDCE) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_DCE))
+#define DCEOBJ_FreeDCE(hDCE) GDIOBJ_FreeObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE)
#define DCEOBJ_LockDCE(hDCE) ((PDCE)GDIOBJ_LockObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE))
-#define DCEOBJ_UnlockDCE(hDCE) GDIOBJ_UnlockObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE)
+#define DCEOBJ_UnlockDCE(hDCE) GDIOBJ_UnlockObj((HGDIOBJ)hDCE)
+BOOL INTERNAL_CALL DCE_Cleanup(PVOID ObjectBody);
PDCE FASTCALL DceAllocDCE(HWND hWnd, DCE_TYPE Type);
PDCE FASTCALL DCE_FreeDCE(PDCE dce);
@@ -48,9 +49,8 @@
HRGN STDCALL DceGetVisRgn(HWND hWnd, ULONG Flags, HWND hWndChild, ULONG CFlags);
INT FASTCALL DCE_ExcludeRgn(HDC, HWND, HRGN);
BOOL FASTCALL DCE_InvalidateDCE(HWND, const PRECTL);
-BOOL FASTCALL DCE_InternalDelete(PDCE dce);
HWND FASTCALL IntWindowFromDC(HDC hDc);
-PDCE FASTCALL DceFreeDCE(PDCE dce);
+PDCE FASTCALL DceFreeDCE(PDCE dce, BOOLEAN Force);
void FASTCALL DceFreeWindowDCE(PWINDOW_OBJECT Window);
void FASTCALL DceEmptyCache(void);
VOID FASTCALL DceResetActiveDCEs(PWINDOW_OBJECT Window, int DeltaX, int DeltaY);
reactos/subsys/win32k/include
diff -u -r1.15 -r1.16
--- inteng.h 14 Jul 2004 20:48:57 -0000 1.15
+++ inteng.h 12 Dec 2004 01:40:37 -0000 1.16
@@ -1,6 +1,23 @@
#ifndef _WIN32K_INTENG_H
#define _WIN32K_INTENG_H
+typedef ULONG HCLIP;
+
+#define ENUM_RECT_LIMIT 50
+
+typedef struct _RECT_ENUM
+{
+ ULONG c;
+ RECTL arcl[ENUM_RECT_LIMIT];
+} RECT_ENUM;
+
+typedef struct tagSPAN
+{
+ LONG Y;
+ LONG X;
+ ULONG Width;
+} SPAN, *PSPAN;
+
#define ROP_NOOP 0x00AA0029
/* Definitions of IntEngXxx functions */
@@ -54,19 +71,19 @@
POINTL *pptlDitherOrg,
ULONG ulMode);
-XLATEOBJ * STDCALL
+XLATEOBJ* FASTCALL
IntEngCreateXlate(USHORT DestPalType,
USHORT SourcePalType,
HPALETTE PaletteDest,
HPALETTE PaletteSource);
-XLATEOBJ * STDCALL
+XLATEOBJ* FASTCALL
IntEngCreateMonoXlate(USHORT SourcePalType,
HPALETTE PaletteDest,
HPALETTE PaletteSource,
ULONG BackgroundColor);
-XLATEOBJ * STDCALL
+XLATEOBJ* FASTCALL
IntEngCreateSrcMonoXlate(HPALETTE PaletteDest,
ULONG ForegroundColor,
ULONG BackgroundColor);
@@ -79,11 +96,20 @@
LONG dCount,
MIX mix);
-CLIPOBJ* STDCALL
+CLIPOBJ* FASTCALL
IntEngCreateClipRegion(ULONG count,
PRECTL pRect,
PRECTL rcBounds);
+VOID FASTCALL
+IntEngDeleteClipRegion(CLIPOBJ *ClipObj);
+
+BOOLEAN FASTCALL
+ClipobjToSpans(PSPAN *Spans,
+ UINT *Count,
+ CLIPOBJ *ClipRegion,
+ PRECTL Boundary);
+
BOOL FASTCALL
IntEngTransparentBlt(BITMAPOBJ *Dest,
BITMAPOBJ *Source,
reactos/subsys/win32k/include
diff -u -r1.16 -r1.17
--- intgdi.h 15 Nov 2004 23:10:42 -0000 1.16
+++ intgdi.h 12 Dec 2004 01:40:37 -0000 1.17
@@ -165,5 +165,19 @@
BOOL FASTCALL
IntGdiIntersectRect(PRECT Dest, const RECT* Src1, const RECT* Src2);
+/* Stock objects */
+
+BOOL FASTCALL
+IntSetSysColors(UINT nColors, INT *Elements, COLORREF *Colors);
+
+BOOL FASTCALL
+IntGetSysColorBrushes(HBRUSH *Brushes, UINT nBrushes);
+
+BOOL FASTCALL
+IntGetSysColorPens(HPEN *Pens, UINT nPens);
+
+BOOL FASTCALL
+IntGetSysColors(COLORREF *Colors, UINT nColors);
+
#endif /* _WIN32K_INTGDI_H */
reactos/subsys/win32k/include
diff -u -r1.13 -r1.14
--- mouse.h 3 Jul 2004 13:55:36 -0000 1.13
+++ mouse.h 12 Dec 2004 01:40:37 -0000 1.14
@@ -5,14 +5,8 @@
#include <include/winsta.h>
//#include <ddk/ntddmou.h>
-BOOL FASTCALL IntCheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo);
-BOOL FASTCALL IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap);
-INT FASTCALL MouseSafetyOnDrawStart(SURFOBJ *SurfObj, LONG HazardX1, LONG HazardY1, LONG HazardX2, LONG HazardY2);
-INT FASTCALL MouseSafetyOnDrawEnd(SURFOBJ *SurfObj);
-BOOL FASTCALL MouseMoveCursor(LONG X, LONG Y);
-VOID FASTCALL EnableMouse(HDC hDisplayDC);
-VOID MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount);
-VOID FASTCALL SetPointerRect(PSYSTEM_CURSORINFO CurInfo, PRECTL PointerRect);
+INT INTERNAL_CALL MouseSafetyOnDrawStart(SURFOBJ *SurfObj, LONG HazardX1, LONG HazardY1, LONG HazardX2, LONG HazardY2);
+INT INTERNAL_CALL MouseSafetyOnDrawEnd(SURFOBJ *SurfObj);
#ifndef XBUTTON1
#define XBUTTON1 (0x01)
reactos/subsys/win32k/include
diff -u -r1.25 -r1.26
--- object.h 16 Nov 2004 17:36:37 -0000 1.25
+++ object.h 12 Dec 2004 01:40:37 -0000 1.26
@@ -113,23 +113,10 @@
VOID FASTCALL ObmDestroyHandleTable (PUSER_HANDLE_TABLE HandleTable);
-ULONG FASTCALL CreateGDIHandle (ULONG InternalSize, ULONG UserSize, PVOID *InternalObject, PVOID *UserObject);
-VOID FASTCALL FreeGDIHandle (ULONG Handle);
-
-PVOID FASTCALL AccessUserObject (ULONG Handle);
-PVOID FASTCALL AccessInternalObject (ULONG Handle);
-
-ULONG FASTCALL AccessHandleFromUserObject (PVOID UserObject);
-
-#define AccessInternalObjectFromUserObject(UserObj) \
- ((PVOID)( (PCHAR)(UserObj) - sizeof( ENGOBJ ) ) )
-
-VOID FASTCALL InitEngHandleTable (VOID);
-VOID FASTCALL InitGdiObjectHandleTable (VOID);
+VOID INTERNAL_CALL InitGdiObjectHandleTable (VOID);
VOID FASTCALL CreateStockObjects (VOID);
-
-BOOL FASTCALL CleanupForProcess (struct _EPROCESS *Process, INT Pid);
+VOID FASTCALL CreateSysColorObjects (VOID);
PPOINT FASTCALL GDI_Bezier (const POINT *Points, INT count, PINT nPtsOut);
reactos/subsys/win32k/include
diff -u -r1.9 -r1.10
--- palette.h 22 Jun 2004 20:08:16 -0000 1.9
+++ palette.h 12 Dec 2004 01:40:37 -0000 1.10
@@ -35,9 +35,10 @@
ULONG Blue);
HPALETTE FASTCALL PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
CONST RGBQUAD *Colors);
-#define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE, GDIOBJFLAG_DEFAULT)
+#define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)
#define PALETTE_LockPalette(hPalette) ((PPALGDI)GDIOBJ_LockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE))
-#define PALETTE_UnlockPalette(hPalette) GDIOBJ_UnlockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)
+#define PALETTE_UnlockPalette(hPalette) GDIOBJ_UnlockObj((HGDIOBJ)hPalette)
+BOOL INTERNAL_CALL PALETTE_Cleanup(PVOID ObjectBody);
HPALETTE FASTCALL PALETTE_Init (VOID);
VOID FASTCALL PALETTE_ValidateFlags (PALETTEENTRY* lpPalE, INT size);
reactos/subsys/win32k/include
diff -u -r1.6 -r1.7
--- tags.h 20 Aug 2004 22:38:49 -0000 1.6
+++ tags.h 12 Dec 2004 01:40:37 -0000 1.7
@@ -42,9 +42,15 @@
#define TAG_PRINT TAG('P', 'R', 'N', 'T') /* print */
#define TAG_REGION TAG('R', 'G', 'N', 'O') /* region */
#define TAG_GDITEXT TAG('T', 'X', 'T', 'O') /* text */
-#define TAG_FONT TAG('F', 'N', 'T', 'O') /* font entry */
+
+/* Eng objects */
+#define TAG_CLIPOBJ TAG('C', 'L', 'P', 'O') /* clip object */
+#define TAG_XLATEOBJ TAG('X', 'L', 'A', 'O') /* xlate object */
+#define TAG_FONT TAG('F', 'N', 'T', 'E') /* font entry */
+#define TAG_FONTOBJ TAG('F', 'N', 'T', 'O') /* font object */
/* misc */
-#define TAG_DRIVER TAG('G', 'D', 'R', 'V') /* video drivers */
+#define TAG_DRIVER TAG('G', 'D', 'R', 'V') /* video drivers */
+#define TAG_FNTFILE TAG('F', 'N', 'T', 'F') /* font file */
#endif /* _WIN32K_TAGS_H */
reactos/subsys/win32k/main
diff -u -r1.82 -r1.83
--- dllmain.c 20 Nov 2004 16:46:05 -0000 1.82
+++ dllmain.c 12 Dec 2004 01:40:37 -0000 1.83
@@ -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: dllmain.c,v 1.82 2004/11/20 16:46:05 weiden Exp $
+/* $Id: dllmain.c,v 1.83 2004/12/12 01:40:37 weiden Exp $
*
* Entry Point for win32k.sys
*/
@@ -45,6 +45,8 @@
ULONG W32ProcessSize);
#endif
+BOOL INTERNAL_CALL GDI_CleanupForProcess (struct _EPROCESS *Process);
+
extern SSDT Win32kSSDT[];
extern SSPT Win32kSSPT[];
extern ULONG Win32kNumberOfSysCalls;
@@ -85,7 +87,7 @@
IntCleanupCurIcons(Process, Win32Process);
CleanupMonitorImpl();
- CleanupForProcess(Process, Process->UniqueProcessId);
+ GDI_CleanupForProcess(Process);
IntGraphicsCheck(FALSE);
@@ -331,6 +333,7 @@
/* Create stock objects, ie. precreated objects commonly
used by win32 applications */
CreateStockObjects();
+ CreateSysColorObjects();
PREPARE_TESTS
reactos/subsys/win32k
diff -u -r1.106 -r1.107
--- makefile 3 Dec 2004 23:37:43 -0000 1.106
+++ makefile 12 Dec 2004 01:40:37 -0000 1.107
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.106 2004/12/03 23:37:43 blight Exp $
+# $Id: makefile,v 1.107 2004/12/12 01:40:37 weiden Exp $
PATH_TO_TOP = ../..
@@ -40,6 +40,7 @@
-DUNICODE \
-Wall -Werror \
-D__USE_W32API -D_WIN32_WINNT=0x0501 \
+ -DGDI_DEBUG \
-DWINVER=0x600 -D_WIN32K_ \
$(CFLAGS_OPT)
@@ -49,7 +50,7 @@
--disable-stdcall-fixup
ENG_OBJECTS= eng/debug.o eng/error.o eng/mem.o eng/brush.o eng/bitblt.o \
- eng/clip.o eng/copybits.o eng/device.o eng/handle.o eng/lineto.o \
+ eng/clip.o eng/copybits.o eng/device.o eng/lineto.o \
eng/paint.o eng/palette.o eng/perfcnt.o eng/semaphor.o eng/surface.o \
eng/xlate.o eng/transblt.o eng/mouse.o eng/misc.o eng/sort.o \
eng/gradient.o eng/event.o eng/float.o
@@ -61,7 +62,7 @@
LDR_OBJECTS = ldr/loader.o
NTUSER_OBJECTS = ntuser/accelerator.o ntuser/callback.o ntuser/caret.o ntuser/class.o \
- ntuser/clipboard.o ntuser/csr.o ntuser/focus.o ntuser/desktop.o \
+ ntuser/clipboard.o ntuser/csr.o ntuser/cursoricon.o ntuser/focus.o ntuser/desktop.o \
ntuser/guicheck.o ntuser/hook.o ntuser/hotkey.o ntuser/input.o \
ntuser/keyboard.o ntuser/menu.o ntuser/message.o ntuser/metric.o \
ntuser/misc.o ntuser/monitor.o ntuser/msgqueue.o ntuser/painting.o \
@@ -70,13 +71,13 @@
ntuser/winpos.o ntuser/winsta.o
OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \
- objects/color.o objects/coord.o objects/dc.o \
- objects/fillshap.o objects/gdiobj.o objects/icm.o \
- objects/line.o objects/metafile.o objects/paint.o \
+ objects/color.o objects/coord.o \
+ objects/dc.o objects/fillshap.o objects/gdiobj.o \
+ objects/icm.o objects/line.o objects/metafile.o objects/paint.o \
objects/path.o objects/pen.o objects/print.o \
objects/region.o objects/text.o objects/wingl.o \
objects/bezier.o objects/dib.o objects/palette.o \
- objects/rect.o objects/polyfill.o objects/cursoricon.o
+ objects/rect.o objects/polyfill.o objects/stockobj.o
DIB_OBJECTS = dib/dib.o dib/dib1bpp.o dib/dib4bpp.o dib/dib8bpp.o dib/dib16bpp.o \
dib/dib24bpp.o dib/dib32bpp.o
reactos/subsys/win32k
diff -u -r1.6 -r1.7
--- w32k.h 16 Nov 2004 16:27:49 -0000 1.6
+++ w32k.h 12 Dec 2004 01:40:37 -0000 1.7
@@ -74,8 +74,6 @@
#include <eng/objects.h>
#include <eng/misc.h>
-#include <eng/handle.h>
-#include <eng/clip.h>
#include <dib/dib.h>
reactos/subsys/win32k/misc
diff -u -r1.12 -r1.13
--- object.c 20 Jun 2004 00:45:36 -0000 1.12
+++ object.c 12 Dec 2004 01:40:37 -0000 1.13
@@ -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: object.c,v 1.12 2004/06/20 00:45:36 navaraf Exp $
+/* $Id: object.c,v 1.13 2004/12/12 01:40:37 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -29,8 +29,7 @@
*/
/* INCLUDES ******************************************************************/
-#include <ddk/ntddk.h>
-#include <include/object.h>
+#include <w32k.h>
#define NDEBUG
#include <debug.h>
reactos/subsys/win32k/ntddraw
diff -u -r1.2 -r1.3
--- ddraw.c 10 May 2004 17:07:18 -0000 1.2
+++ ddraw.c 12 Dec 2004 01:40:37 -0000 1.3
@@ -8,71 +8,24 @@
* REVISION HISTORY:
* 25-10-2003 PB Created
*/
+
#include <ddk/ntddk.h>
#include <win32k/ntddraw.h>
#include <win32k/win32k.h>
+#include <include/intddraw.h>
#include <win32k/gdiobj.h>
#define NDEBUG
#include <debug.h>
-#define GDI_OBJECT_TYPE_DIRECTDRAW 0x00600000
-#define GDI_OBJECT_TYPE_DD_SURFACE 0x00610000
-#define GDI_OBJECT_TYPE_DD_VIDEOPORT 0x00620000
-#define GDI_OBJECT_TYPE_DD_PALETTE 0x00630000
-#define GDI_OBJECT_TYPE_DD_CLIPPER 0x00640000
-#define GDI_OBJECT_TYPE_DD_MOTIONCOMP 0x00650000
-
/************************************************************************/
/* DIRECT DRAW OBJECT */
/************************************************************************/
-typedef struct
-{
- DD_DIRECTDRAW_LOCAL Local;
- DD_DIRECTDRAW_GLOBAL Global;
- // Drv callbacks
- PGD_GETDIRECTDRAWINFO DrvGetDirectDrawInfo;
- PGD_DISABLEDIRECTDRAW DrvDisableDirectDraw;
- // DD callbacks
- PDD_CREATESURFACE DdCreateSurface;
- PDD_SETCOLORKEY DdDrvSetColorKey; // ?????
- PDD_WAITFORVERTICALBLANK DdWaitForVerticalBlank;
- PDD_CANCREATESURFACE DdCanCreateSurface;
- PDD_CREATEPALETTE DdCreatePalette;
- PDD_GETSCANLINE DdGetScanLine;
- PDD_MAPMEMORY DdMapMemory;
- // Surface callbacks
- PDD_SURFCB_DESTROYSURFACE DdDestroySurface;
- PDD_SURFCB_FLIP DdFlip;
- PDD_SURFCB_SETCLIPLIST DdSetClipList;
- PDD_SURFCB_LOCK DdLock;
- PDD_SURFCB_UNLOCK DdUnlock;
- PDD_SURFCB_BLT DdBlt;
- PDD_SURFCB_SETCOLORKEY DdSetColorKey;
- PDD_SURFCB_ADDATTACHEDSURFACE DdAddAttachedSurface;
- PDD_SURFCB_GETBLTSTATUS DdGetBltStatus;
- PDD_SURFCB_GETFLIPSTATUS DdGetFlipStatus;
- PDD_SURFCB_UPDATEOVERLAY DdUpdateOverlay;
- PDD_SURFCB_SETOVERLAYPOSITION DdSetOverlayPosition;
- PDD_SURFCB_SETPALETTE DdSetPalette;
- // Palette callbacks
- PDD_PALCB_DESTROYPALETTE DdDestroyPalette;
- PDD_PALCB_SETENTRIES DdSetEntries;
- // D3D Device context callbacks
- PD3DNTHAL_CONTEXTCREATECB D3dContextCreate;
- PD3DNTHAL_CONTEXTDESTROYCB D3dContextDestroy;
- // D3D Buffer callbacks
- PDD_CANCREATESURFACE DdCanCreateD3DBuffer;
- PDD_CREATESURFACE DdCreateD3DBuffer;
- PDD_SURFCB_DESTROYSURFACE DdDestroyD3DBuffer;
- PDD_SURFCB_LOCK DdLockD3DBuffer;
- PDD_SURFCB_UNLOCK DdUnlockD3DBuffer;
-} DD_DIRECTDRAW, *PDD_DIRECTDRAW;
-
-static BOOL FASTCALL DirectDrawCleanup(PDD_DIRECTDRAW pDirectDraw)
+BOOL FASTCALL
+DD_Cleanup(PDD_DIRECTDRAW pDD)
{
- pDirectDraw->DrvDisableDirectDraw(pDirectDraw->Global.dhpdev);
+ pDD->DrvDisableDirectDraw(pDD->Global.dhpdev);
return TRUE;
}
@@ -112,7 +65,7 @@
return NULL;
}
- HANDLE hDirectDraw = GDIOBJ_AllocObj(sizeof(DD_DIRECTDRAW), GDI_OBJECT_TYPE_DIRECTDRAW, (GDICLEANUPPROC)DirectDrawCleanup);
+ HANDLE hDirectDraw = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DIRECTDRAW);
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
pDirectDraw->Global.dhpdev = pDC->PDev;
@@ -121,54 +74,54 @@
pDirectDraw->DrvGetDirectDrawInfo = pDC->DriverFunctions.GetDirectDrawInfo;
pDirectDraw->DrvDisableDirectDraw = pDC->DriverFunctions.DisableDirectDraw;
- if (callbacks.dwFlags && DDHAL_CB32_CREATESURFACE)
+ if (callbacks.dwFlags & DDHAL_CB32_CREATESURFACE)
pDirectDraw->DdCreateSurface = callbacks.CreateSurface;
- if (callbacks.dwFlags && DDHAL_CB32_SETCOLORKEY)
+ if (callbacks.dwFlags & DDHAL_CB32_SETCOLORKEY)
pDirectDraw->DdDrvSetColorKey = callbacks.SetColorKey;
- if (callbacks.dwFlags && DDHAL_CB32_WAITFORVERTICALBLANK)
+ if (callbacks.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK)
pDirectDraw->DdWaitForVerticalBlank = callbacks.WaitForVerticalBlank;
- if (callbacks.dwFlags && DDHAL_CB32_CANCREATESURFACE)
+ if (callbacks.dwFlags & DDHAL_CB32_CANCREATESURFACE)
pDirectDraw->DdCanCreateSurface = callbacks.CanCreateSurface;
- if (callbacks.dwFlags && DDHAL_CB32_CREATEPALETTE)
+ if (callbacks.dwFlags & DDHAL_CB32_CREATEPALETTE)
pDirectDraw->DdCreatePalette = callbacks.CreatePalette;
- if (callbacks.dwFlags && DDHAL_CB32_GETSCANLINE)
+ if (callbacks.dwFlags & DDHAL_CB32_GETSCANLINE)
pDirectDraw->DdGetScanLine = callbacks.GetScanLine;
- if (callbacks.dwFlags && DDHAL_CB32_MAPMEMORY)
+ if (callbacks.dwFlags & DDHAL_CB32_MAPMEMORY)
pDirectDraw->DdMapMemory = callbacks.MapMemory;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_DESTROYSURFACE)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_DESTROYSURFACE)
pDirectDraw->DdDestroySurface = surface_callbacks.DestroySurface;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_FLIP)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_FLIP)
pDirectDraw->DdFlip = surface_callbacks.Flip;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_SETCLIPLIST)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_SETCLIPLIST)
pDirectDraw->DdSetClipList = surface_callbacks.SetClipList;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_LOCK)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_LOCK)
pDirectDraw->DdLock = surface_callbacks.Lock;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_UNLOCK)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_UNLOCK)
pDirectDraw->DdUnlock = surface_callbacks.Unlock;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_BLT)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_BLT)
pDirectDraw->DdBlt = surface_callbacks.Blt;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_SETCOLORKEY)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_SETCOLORKEY)
pDirectDraw->DdSetColorKey = surface_callbacks.SetColorKey;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_ADDATTACHEDSURFACE)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_ADDATTACHEDSURFACE)
pDirectDraw->DdAddAttachedSurface = surface_callbacks.AddAttachedSurface;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_GETBLTSTATUS)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_GETBLTSTATUS)
pDirectDraw->DdGetBltStatus = surface_callbacks.GetBltStatus;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_GETFLIPSTATUS)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_GETFLIPSTATUS)
pDirectDraw->DdGetFlipStatus = surface_callbacks.GetFlipStatus;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_UPDATEOVERLAY)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_UPDATEOVERLAY)
pDirectDraw->DdUpdateOverlay = surface_callbacks.UpdateOverlay;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_SETOVERLAYPOSITION)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_SETOVERLAYPOSITION)
pDirectDraw->DdSetOverlayPosition = surface_callbacks.SetOverlayPosition;
- if (surface_callbacks.dwFlags && DDHAL_SURFCB32_SETPALETTE)
+ if (surface_callbacks.dwFlags & DDHAL_SURFCB32_SETPALETTE)
pDirectDraw->DdSetPalette = surface_callbacks.SetPalette;
- if (palette_callbacks.dwFlags && DDHAL_PALCB32_DESTROYPALETTE)
+ if (palette_callbacks.dwFlags & DDHAL_PALCB32_DESTROYPALETTE)
pDirectDraw->DdDestroyPalette = palette_callbacks.DestroyPalette;
- if (palette_callbacks.dwFlags && DDHAL_PALCB32_SETENTRIES)
+ if (palette_callbacks.dwFlags & DDHAL_PALCB32_SETENTRIES)
pDirectDraw->DdSetEntries = palette_callbacks.SetEntries;
- GDIOBJ_UnlockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
+ GDIOBJ_UnlockObj(hDirectDraw);
DC_UnlockDc(hdc);
return hDirectDraw;
@@ -178,7 +131,7 @@
HANDLE hDirectDrawLocal
)
{
- return GDIOBJ_FreeObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW, 0);
+ return GDIOBJ_FreeObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
}
BOOL STDCALL NtGdiDdQueryDirectDrawObject(
@@ -209,7 +162,7 @@
if (!success)
{
- GDIOBJ_UnlockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ GDIOBJ_UnlockObj(hDirectDrawLocal);
return FALSE;
}
@@ -235,7 +188,7 @@
pDirectDraw->DdUnlockD3DBuffer = puD3dBufferCallbacks->UnlockD3DBuffer;
}
- GDIOBJ_UnlockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ GDIOBJ_UnlockObj(hDirectDrawLocal);
return TRUE;
}
@@ -244,17 +197,8 @@
/* SURFACE OBJECT */
/************************************************************************/
-typedef struct
-{
- DD_SURFACE_LOCAL Local;
- DD_SURFACE_MORE More;
- DD_SURFACE_GLOBAL Global;
- DD_ATTACHLIST AttachList;
- DD_ATTACHLIST AttachListFrom;
- BOOL bComplete;
-} DD_SURFACE, *PDD_SURFACE;
-
-static BOOL FASTCALL DDSurfaceCleanup(PDD_SURFACE pSurface)
+BOOL FASTCALL
+DDSURF_Cleanup(PDD_SURFACE pDDSurf)
{
//FIXME: implement
return TRUE;
@@ -274,10 +218,11 @@
return NULL;
if (!hSurface)
- hSurface = GDIOBJ_AllocObj(sizeof(DD_SURFACE), GDI_OBJECT_TYPE_DD_SURFACE, (GDICLEANUPPROC)DDSurfaceCleanup);
+ hSurface = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DD_SURFACE);
PDD_SURFACE pSurface = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
-
+ /* FIXME - Handle pSurface == NULL!!!! */
+
RtlMoveMemory(&pSurface->Local, puSurfaceLocal, sizeof(DD_SURFACE_LOCAL));
RtlMoveMemory(&pSurface->More, puSurfaceMore, sizeof(DD_SURFACE_MORE));
RtlMoveMemory(&pSurface->Global, puSurfaceGlobal, sizeof(DD_SURFACE_GLOBAL));
@@ -289,8 +234,8 @@
// FIXME: figure out how to use this
pSurface->bComplete = bComplete;
- GDIOBJ_UnlockObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
- GDIOBJ_UnlockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ GDIOBJ_UnlockObj(hSurface);
+ GDIOBJ_UnlockObj(hDirectDrawLocal);
return hSurface;
}
@@ -299,7 +244,7 @@
HANDLE hSurface
)
{
- return GDIOBJ_FreeObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE, 0);
+ return GDIOBJ_FreeObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
}
/*
@@ -314,7 +259,7 @@
PDD_SURFACE pSurfaceTo = GDIOBJ_LockObj(hSurfaceTo, GDI_OBJECT_TYPE_DD_SURFACE);
if (!pSurfaceTo)
{
- GDIOBJ_UnlockObj(hSurfaceTo, GDI_OBJECT_TYPE_DD_SURFACE);
+ GDIOBJ_UnlockObj(hSurfaceFrom);
return FALSE;
}
@@ -323,8 +268,8 @@
pSurfaceFrom->Local.lpAttachListFrom = pSurfaceFrom->AttachListFrom;
}
- GDIOBJ_UnlockObj(hSurfaceFrom, GDI_OBJECT_TYPE_DD_SURFACE);
- GDIOBJ_UnlockObj(hSurfaceTo, GDI_OBJECT_TYPE_DD_SURFACE);
+ GDIOBJ_UnlockObj(hSurfaceFrom);
+ GDIOBJ_UnlockObj(hSurfaceTo);
return TRUE;
}
*/
reactos/subsys/win32k/ntuser
diff -N cursoricon.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ cursoricon.c 12 Dec 2004 01:40:38 -0000 1.1
@@ -0,0 +1,1209 @@
+/*
+ * 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.
+ */
+/* $Id: cursoricon.c,v 1.1 2004/12/12 01:40:38 weiden Exp $ */
+#include <w32k.h>
+
+PCURICON_OBJECT FASTCALL
+IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle)
+{
+ PCURICON_OBJECT Object;
+ NTSTATUS Status;
+
+ Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable,
+ Handle, otCursorIcon, (PVOID*)&Object);
+ if (!NT_SUCCESS(Status))
+ {
+ return NULL;
+ }
+ return Object;
+}
+
+#define COLORCURSORS_ALLOWED FALSE
+HCURSOR FASTCALL
+IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
+ BOOL ForceChange)
+{
+ BITMAPOBJ *BitmapObj;
+ SURFOBJ *SurfObj;
+ PDEVINFO DevInfo;
+ PBITMAPOBJ MaskBmpObj = NULL;
+ PSYSTEM_CURSORINFO CurInfo;
+ PCURICON_OBJECT OldCursor;
+ HCURSOR Ret = (HCURSOR)0;
+ HBITMAP dcbmp, hColor = (HBITMAP)0;
+ HBITMAP hMask = 0;
+ SURFOBJ *soMask = NULL, *soColor = NULL;
+ XLATEOBJ *XlateObj = NULL;
+ HDC Screen;
+
+ CurInfo = IntGetSysCursorInfo(WinStaObject);
+ OldCursor = CurInfo->CurrentCursorObject;
+ if (OldCursor)
+ {
+ Ret = (HCURSOR)OldCursor->Self;
+ }
+
+ if (!ForceChange && OldCursor == NewCursor)
+ {
+ return Ret;
+ }
+ else
+ {
+ if(!(Screen = IntGetScreenDC()))
+ {
+ return (HCURSOR)0;
+ }
+ /* FIXME use the desktop's HDC instead of using ScreenDeviceContext */
+ PDC dc = DC_LockDc(Screen);
+
+ if (!dc)
+ {
+ return Ret;
+ }
+ dcbmp = dc->w.hBitmap;
+ DevInfo = dc->DevInfo;
+ DC_UnlockDc(Screen);
+
+ BitmapObj = BITMAPOBJ_LockBitmap(dcbmp);
+ /* FIXME - BitmapObj can be NULL!!!!! */
+ SurfObj = &BitmapObj->SurfObj;
+ }
+
+ if (!NewCursor && (CurInfo->CurrentCursorObject || ForceChange))
+ {
+ if (NULL != CurInfo->CurrentCursorObject && CurInfo->ShowingCursor)
+ {
+ /* Remove the cursor if it was displayed */
+ if (GDIDEV(SurfObj)->Pointer.MovePointer)
+ GDIDEV(SurfObj)->Pointer.MovePointer(SurfObj, -1, -1, NULL);
+ }
+
+ GDIDEV(SurfObj)->Pointer.Status = SPS_ACCEPT_NOEXCLUDE;
+
+ CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
+ CurInfo->ShowingCursor = 0;
+ BITMAPOBJ_UnlockBitmap(dcbmp);
+ return Ret;
+ }
+
+ if (!NewCursor)
+ {
+ BITMAPOBJ_UnlockBitmap(dcbmp);
+ return Ret;
+ }
+
+ /* TODO: Fixme. Logic is screwed above */
+
+ ASSERT(NewCursor);
+ MaskBmpObj = BITMAPOBJ_LockBitmap(NewCursor->IconInfo.hbmMask);
+ if (MaskBmpObj)
+ {
+ const int maskBpp = BitsPerFormat(MaskBmpObj->SurfObj.iBitmapFormat);
+ BITMAPOBJ_UnlockBitmap(NewCursor->IconInfo.hbmMask);
+ if (maskBpp != 1)
+ {
+ DPRINT1("SetCursor: The Mask bitmap must have 1BPP!\n");
+ BITMAPOBJ_UnlockBitmap(dcbmp);
+ return Ret;
+ }
+
+ if ((DevInfo->flGraphicsCaps2 & GCAPS2_ALPHACURSOR) &&
+ SurfObj->iBitmapFormat >= BMF_16BPP &&
+ SurfObj->iBitmapFormat <= BMF_32BPP &&
+ NewCursor->Shadow && COLORCURSORS_ALLOWED)
+ {
+ /* FIXME - Create a color pointer, only 32bit bitmap, set alpha bits!
+ Do not pass a mask bitmap to DrvSetPointerShape()!
+ Create a XLATEOBJ that describes the colors of the bitmap. */
+ DPRINT1("SetCursor: (Colored) alpha cursors are not supported!\n");
+ }
+ else
+ {
+ if(NewCursor->IconInfo.hbmColor
+ && COLORCURSORS_ALLOWED)
+ {
+ /* FIXME - Create a color pointer, create only one 32bit bitmap!
+ Do not pass a mask bitmap to DrvSetPointerShape()!
+ Create a XLATEOBJ that describes the colors of the bitmap.
+ (16bit bitmaps are propably allowed) */
+ DPRINT1("SetCursor: Cursors with colors are not supported!\n");
+ }
+ else
+ {
+ MaskBmpObj = BITMAPOBJ_LockBitmap(NewCursor->IconInfo.hbmMask);
+ if(MaskBmpObj)
+ {
+ RECTL DestRect = {0, 0, MaskBmpObj->SurfObj.sizlBitmap.cx, MaskBmpObj->SurfObj.sizlBitmap.cy};
+ POINTL SourcePoint = {0, 0};
+
+ /*
+ * NOTE: For now we create the cursor in top-down bitmap,
+ * because VMware driver rejects it otherwise. This should
+ * be fixed later.
+ */
+ hMask = EngCreateBitmap(
+ MaskBmpObj->SurfObj.sizlBitmap, abs(MaskBmpObj->SurfObj.lDelta),
+ MaskBmpObj->SurfObj.iBitmapFormat, BMF_TOPDOWN,
+ NULL);
+ ASSERT(hMask);
+ soMask = EngLockSurface((HSURF)hMask);
+ EngCopyBits(soMask, &MaskBmpObj->SurfObj, NULL, NULL,
+ &DestRect, &SourcePoint);
+ BITMAPOBJ_UnlockBitmap(NewCursor->IconInfo.hbmMask);
+ }
+ }
+ }
+ CurInfo->ShowingCursor = CURSOR_SHOWING;
+ CurInfo->CurrentCursorObject = NewCursor;
+ }
+ else
+ {
+ CurInfo->ShowingCursor = 0;
+ CurInfo->CurrentCursorObject = NULL;
+ }
+
+ if (GDIDEVFUNCS(SurfObj).SetPointerShape)
+ {
+ GDIDEV(SurfObj)->Pointer.Status =
+ GDIDEVFUNCS(SurfObj).SetPointerShape(
+ SurfObj, soMask, soColor, XlateObj,
+ NewCursor->IconInfo.xHotspot,
+ NewCursor->IconInfo.yHotspot,
+ CurInfo->x,
+ CurInfo->y,
+ NULL,
+ SPS_CHANGE);
+ DPRINT("SetCursor: DrvSetPointerShape() returned %x\n",
+ GDIDEV(SurfObj)->Pointer.Status);
+ }
+ else
+ {
+ GDIDEV(SurfObj)->Pointer.Status = SPS_DECLINE;
+ }
+
+ if(GDIDEV(SurfObj)->Pointer.Status == SPS_DECLINE)
+ {
+ GDIDEV(SurfObj)->Pointer.Status = EngSetPointerShape(
+ SurfObj, soMask, soColor, XlateObj,
+ NewCursor->IconInfo.xHotspot,
+ NewCursor->IconInfo.yHotspot,
+ CurInfo->x,
+ CurInfo->y,
+ NULL,
+ SPS_CHANGE);
+ GDIDEV(SurfObj)->Pointer.MovePointer = EngMovePointer;
+ }
+ else
+ {
+ GDIDEV(SurfObj)->Pointer.MovePointer = GDIDEVFUNCS(SurfObj).MovePointer;
+ }
+
+ BITMAPOBJ_UnlockBitmap(dcbmp);
+ if(hMask)
+ {
+ EngUnlockSurface(soMask);
+ EngDeleteSurface((HSURF)hMask);
+ }
+ if(hColor)
+ {
+ EngDeleteSurface((HSURF)hColor);
+ }
+ if(XlateObj)
+ {
+ EngDeleteXlate(XlateObj);
+ }
+
+ if(GDIDEV(SurfObj)->Pointer.Status == SPS_ERROR)
+ DPRINT1("SetCursor: DrvSetPointerShape() returned SPS_ERROR\n");
+
+ return Ret;
+}
+
+BOOL FASTCALL
+IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject)
+{
+ return TRUE;
+}
+
+PCURICON_OBJECT FASTCALL
+IntFindExistingCurIconObject(PWINSTATION_OBJECT WinStaObject, HMODULE hModule,
+ HRSRC hRsrc, LONG cx, LONG cy)
+{
+ PUSER_HANDLE_TABLE HandleTable;
+ PLIST_ENTRY CurrentEntry;
+ PUSER_HANDLE_BLOCK Current;
+ PCURICON_OBJECT Object;
+ ULONG i;
+
+ HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->HandleTable;
+ ObmpLockHandleTable(HandleTable);
+
+ CurrentEntry = HandleTable->ListHead.Flink;
+ while(CurrentEntry != &HandleTable->ListHead)
+ {
+ Current = CONTAINING_RECORD(CurrentEntry, USER_HANDLE_BLOCK, ListEntry);
+ for(i = 0; i < HANDLE_BLOCK_ENTRIES; i++)
+ {
+ Object = (PCURICON_OBJECT)Current->Handles[i].ObjectBody;
+ if(Object && (ObmReferenceObjectByPointer(Object, otCursorIcon) == STATUS_SUCCESS))
+ {
+ if((Object->hModule == hModule) && (Object->hRsrc == hRsrc))
+ {
+ if(cx && ((cx != Object->Size.cx) || (cy != Object->Size.cy)))
+ {
+ ObmDereferenceObject(Object);
+ continue;
+ }
+ ObmpUnlockHandleTable(HandleTable);
+ return Object;
+ }
+ ObmDereferenceObject(Object);
+ }
+ }
+ CurrentEntry = CurrentEntry->Flink;
+ }
+
+ ObmpUnlockHandleTable(HandleTable);
+ return NULL;
+}
+
+PCURICON_OBJECT FASTCALL
+IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject)
+{
+ PCURICON_OBJECT Object;
+ HANDLE Handle;
+ PW32PROCESS Win32Process;
+
+ Object = ObmCreateObject(WinStaObject->HandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT));
+
+ if(!Object)
+ {
+ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
+
+ Win32Process = PsGetWin32Process();
+
+ IntLockProcessCursorIcons(Win32Process);
+ InsertTailList(&Win32Process->CursorIconListHead, &Object->ListEntry);
+ IntUnLockProcessCursorIcons(Win32Process);
+
+ Object->Self = Handle;
+ Object->Process = PsGetWin32Process();
+
+ return Object;
+}
+
+BOOL FASTCALL
+IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL RemoveFromProcess)
+{
+ PSYSTEM_CURSORINFO CurInfo;
+ PCURICON_OBJECT Object;
+ HBITMAP bmpMask, bmpColor;
+ NTSTATUS Status;
+ BOOL Ret;
+
+ Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, Handle, otCursorIcon, (PVOID*)&Object);
+ if(!NT_SUCCESS(Status))
+ {
+ return FALSE;
+ }
+
+ if (Object->Process != PsGetWin32Process())
+ {
+ ObmDereferenceObject(Object);
+ return FALSE;
+ }
+
+ CurInfo = IntGetSysCursorInfo(WinStaObject);
+
+ if (CurInfo->CurrentCursorObject == Object)
+ {
+ /* Hide the cursor if we're destroying the current cursor */
+ IntSetCursor(WinStaObject, NULL, TRUE);
+ }
+
+ bmpMask = Object->IconInfo.hbmMask;
+ bmpColor = Object->IconInfo.hbmColor;
+
+ if (Object->Process && RemoveFromProcess)
+ {
+ IntLockProcessCursorIcons(Object->Process);
+ RemoveEntryList(&Object->ListEntry);
+ IntUnLockProcessCursorIcons(Object->Process);
+ }
+
+ Ret = NT_SUCCESS(ObmCloseHandle(WinStaObject->HandleTable, Handle));
+
+ /* delete bitmaps */
+ if(bmpMask)
+ {
+ GDIOBJ_SetOwnership(bmpMask, PsGetCurrentProcess());
+ NtGdiDeleteObject(bmpMask);
+ }
+ if(bmpColor)
+ {
+ GDIOBJ_SetOwnership(bmpColor, PsGetCurrentProcess());
+ NtGdiDeleteObject(bmpColor);
+ }
+
+ ObmDereferenceObject(Object);
+
+ return Ret;
+}
+
+VOID FASTCALL
+IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process)
+{
+ PWINSTATION_OBJECT WinStaObject;
+ PCURICON_OBJECT Current;
+ PLIST_ENTRY CurrentEntry, NextEntry;
+
+ WinStaObject = IntGetWinStaObj();
+ if(WinStaObject != NULL)
+ {
+ CurrentEntry = Win32Process->CursorIconListHead.Flink;
+ while(CurrentEntry != &Win32Process->CursorIconListHead)
+ {
+ NextEntry = CurrentEntry->Flink;
+ Current = CONTAINING_RECORD(CurrentEntry, CURICON_OBJECT, ListEntry);
+ RemoveEntryList(&Current->ListEntry);
+ IntDestroyCurIconObject(WinStaObject, Current->Self, FALSE);
+ CurrentEntry = NextEntry;
+ }
+ ObDereferenceObject(WinStaObject);
+ }
+}
+
+/*
+ * @implemented
+ */
+HANDLE
+STDCALL
+NtUserCreateCursorIconHandle(PICONINFO IconInfo, BOOL Indirect)
+{
+ PCURICON_OBJECT CurIconObject;
+ PWINSTATION_OBJECT WinStaObject;
+ PBITMAPOBJ bmp;
+ NTSTATUS Status;
+ HANDLE Ret;
+
+ WinStaObject = IntGetWinStaObj();
+ if(WinStaObject == NULL)
+ {
+ return (HANDLE)0;
+ }
+
+ CurIconObject = IntCreateCurIconHandle(WinStaObject);
+ if(CurIconObject)
+ {
+ Ret = CurIconObject->Self;
+
+ if(IconInfo)
+ {
+ Status = MmCopyFromCaller(&CurIconObject->IconInfo, IconInfo, sizeof(ICONINFO));
+ if(NT_SUCCESS(Status))
+ {
+ if(Indirect)
+ {
+ CurIconObject->IconInfo.hbmMask = BITMAPOBJ_CopyBitmap(CurIconObject->IconInfo.hbmMask);
+ CurIconObject->IconInfo.hbmColor = BITMAPOBJ_CopyBitmap(CurIconObject->IconInfo.hbmColor);
+ }
+ if(CurIconObject->IconInfo.hbmColor &&
+ (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor)))
+ {
+ CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
+ CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy;
+ BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmColor);
+ GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmColor, NULL);
+ }
+ else
+ {
+ if(CurIconObject->IconInfo.hbmMask &&
+ (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask)))
+ {
+ CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
+ CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
+ BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmMask);
+ GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmMask, NULL);
+ }
+ }
+ }
+ else
+ {
+ SetLastNtError(Status);
+ /* FIXME - Don't exit here */
+ }
+ }
+
+ ObDereferenceObject(WinStaObject);
+ return Ret;
+ }
+
+ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+ ObDereferenceObject(WinStaObject);
+ return (HANDLE)0;
+}
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+NtUserGetCursorIconInfo(
+ HANDLE Handle,
+ PICONINFO IconInfo)
+{
+ ICONINFO ii;
+ PCURICON_OBJECT CurIconObject;
+ PWINSTATION_OBJECT WinStaObject;
+ NTSTATUS Status;
+ BOOL Ret = FALSE;
+
+ WinStaObject = IntGetWinStaObj();
+ if(WinStaObject == NULL)
+ {
+ return FALSE;
+ }
+
+ CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
+ if(CurIconObject)
+ {
+ if(IconInfo)
+ {
+ RtlCopyMemory(&ii, &CurIconObject->IconInfo, sizeof(ICONINFO));
+
+ /* Copy bitmaps */
+ ii.hbmMask = BITMAPOBJ_CopyBitmap(ii.hbmMask);
+ ii.hbmColor = BITMAPOBJ_CopyBitmap(ii.hbmColor);
+
+ /* Copy fields */
+ Status = MmCopyToCaller(IconInfo, &ii, sizeof(ICONINFO));
+ if(NT_SUCCESS(Status))
+ Ret = TRUE;
+ else
+ SetLastNtError(Status);
+ }
+ else
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ }
+
+ IntReleaseCurIconObject(CurIconObject);
+ ObDereferenceObject(WinStaObject);
+ return Ret;
+ }
+
+ SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+ ObDereferenceObject(WinStaObject);
+ return FALSE;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+NtUserGetCursorIconSize(
+ HANDLE Handle,
+ BOOL *fIcon,
+ SIZE *Size)
+{
+ PCURICON_OBJECT CurIconObject;
+ PBITMAPOBJ bmp;
+ PWINSTATION_OBJECT WinStaObject;
+ NTSTATUS Status;
+ BOOL Ret = FALSE;
+ SIZE SafeSize;
+
+ WinStaObject = IntGetWinStaObj();
+ if(WinStaObject == NULL)
+ {
+ return FALSE;
+ }
+
+ CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
+ if(CurIconObject)
+ {
+ /* Copy fields */
+ Status = MmCopyToCaller(fIcon, &CurIconObject->IconInfo.fIcon, sizeof(BOOL));
+ if(!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ goto done;
+ }
+
+ bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor);
+ if(!bmp)
+ goto done;
+
+ SafeSize.cx = bmp->SurfObj.sizlBitmap.cx;
+ SafeSize.cy = bmp->SurfObj.sizlBitmap.cy;
+ Status = MmCopyToCaller(Size, &SafeSize, sizeof(SIZE));
+ if(NT_SUCCESS(Status))
+ Ret = TRUE;
+ else
+ SetLastNtError(Status);
+
+ BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmColor);
+
+ done:
+ IntReleaseCurIconObject(CurIconObject);
+ ObDereferenceObject(WinStaObject);
+ return Ret;
+ }
+
+ SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+ ObDereferenceObject(WinStaObject);
+ return FALSE;
+}
+
+
+/*
+ * @unimplemented
+ */
+DWORD
+STDCALL
+NtUserGetCursorFrameInfo(
+ DWORD Unknown0,
+ DWORD Unknown1,
+ DWORD Unknown2,
+ DWORD Unknown3)
+{
+ UNIMPLEMENTED
+
+ return 0;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+NtUserGetCursorInfo(
+ PCURSORINFO pci)
+{
+ CURSORINFO SafeCi;
+ PSYSTEM_CURSORINFO CurInfo;
+ PWINSTATION_OBJECT WinStaObject;
+ NTSTATUS Status;
+ PCURICON_OBJECT CursorObject;
+
+ Status = MmCopyFromCaller(&SafeCi.cbSize, pci, sizeof(DWORD));
+ if(!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ return FALSE;
+ }
+
+ if(SafeCi.cbSize != sizeof(CURSORINFO))
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ WinStaObject = IntGetWinStaObj();
+ if(WinStaObject == NULL)
+ {
+ return FALSE;
+ }
+
+ CurInfo = IntGetSysCursorInfo(WinStaObject);
+ CursorObject = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
+
+ SafeCi.flags = ((CurInfo->ShowingCursor && CursorObject) ? CURSOR_SHOWING : 0);
+ SafeCi.hCursor = (CursorObject ? (HCURSOR)CursorObject->Self : (HCURSOR)0);
+ SafeCi.ptScreenPos.x = CurInfo->x;
+ SafeCi.ptScreenPos.y = CurInfo->y;
+
+ Status = MmCopyToCaller(pci, &SafeCi, sizeof(CURSORINFO));
+ if(!NT_SUCCESS(Status))
+ {
+ ObDereferenceObject(WinStaObject);
+ SetLastNtError(Status);
+ return FALSE;
+ }
+
+ ObDereferenceObject(WinStaObject);
+ return TRUE;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+NtUserClipCursor(
+ RECT *UnsafeRect)
+{
+ /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
+
+ PWINSTATION_OBJECT WinStaObject;
+ PSYSTEM_CURSORINFO CurInfo;
+ RECT Rect;
+ PWINDOW_OBJECT DesktopWindow = NULL;
+
+ WinStaObject = IntGetWinStaObj();
+ if (WinStaObject == NULL)
+ {
+ return FALSE;
+ }
+
+ if (NULL != UnsafeRect && ! NT_SUCCESS(MmCopyFromCaller(&Rect, UnsafeRect, sizeof(RECT))))
+ {
+ ObDereferenceObject(WinStaObject);
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ CurInfo = IntGetSysCursorInfo(WinStaObject);
+ if(WinStaObject->ActiveDesktop)
+ DesktopWindow = IntGetWindowObject(WinStaObject->ActiveDesktop->DesktopWindow);
+
+ if((Rect.right > Rect.left) && (Rect.bottom > Rect.top)
+ && DesktopWindow && UnsafeRect != NULL)
+ {
+ MOUSEINPUT mi;
+
+ CurInfo->CursorClipInfo.IsClipped = TRUE;
+ CurInfo->CursorClipInfo.Left = max(Rect.left, DesktopWindow->WindowRect.left);
+ CurInfo->CursorClipInfo.Top = max(Rect.top, DesktopWindow->WindowRect.top);
+ CurInfo->CursorClipInfo.Right = min(Rect.right - 1, DesktopWindow->WindowRect.right - 1);
+ CurInfo->CursorClipInfo.Bottom = min(Rect.bottom - 1, DesktopWindow->WindowRect.bottom - 1);
+ IntReleaseWindowObject(DesktopWindow);
+
+ mi.dx = CurInfo->x;
+ mi.dy = CurInfo->y;
+ mi.mouseData = 0;
+ mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
+ mi.time = 0;
+ mi.dwExtraInfo = 0;
+ IntMouseInput(&mi);
+
+ return TRUE;
+ }
+
+ CurInfo->CursorClipInfo.IsClipped = FALSE;
+ ObDereferenceObject(WinStaObject);
+
+ return TRUE;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+NtUserDestroyCursorIcon(
+ HANDLE Handle,
+ DWORD Unknown)
+{
+ PWINSTATION_OBJECT WinStaObject;
+
+ WinStaObject = IntGetWinStaObj();
+ if(WinStaObject == NULL)
+ {
+ return FALSE;
+ }
+
+ if(IntDestroyCurIconObject(WinStaObject, Handle, TRUE))
+ {
+ ObDereferenceObject(WinStaObject);
+ return TRUE;
+ }
+
+ SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+ ObDereferenceObject(WinStaObject);
+ return FALSE;
+}
+
+
+/*
+ * @implemented
+ */
+HICON
+STDCALL
+NtUserFindExistingCursorIcon(
+ HMODULE hModule,
+ HRSRC hRsrc,
+ LONG cx,
+ LONG cy)
+{
+ PCURICON_OBJECT CurIconObject;
+ PWINSTATION_OBJECT WinStaObject;
+ HANDLE Ret = (HANDLE)0;
+
+ WinStaObject = IntGetWinStaObj();
+ if(WinStaObject == NULL)
+ {
+ return Ret;
+ }
+
+ CurIconObject = IntFindExistingCurIconObject(WinStaObject, hModule, hRsrc, cx, cy);
+ if(CurIconObject)
+ {
+ Ret = CurIconObject->Self;
+
+ IntReleaseCurIconObject(CurIconObject);
+ ObDereferenceObject(WinStaObject);
+ return Ret;
+ }
+
+ SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+ ObDereferenceObject(WinStaObject);
+ return (HANDLE)0;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+NtUserGetClipCursor(
+ RECT *lpRect)
+{
+ /* FIXME - check if process has WINSTA_READATTRIBUTES */
+ PSYSTEM_CURSORINFO CurInfo;
+ PWINSTATION_OBJECT WinStaObject;
+ RECT Rect;
+ NTSTATUS Status;
+
+ if(!lpRect)
+ return FALSE;
+
+ WinStaObject = IntGetWinStaObj();
+ if (WinStaObject == NULL)
+ {
+ DPRINT("Validation of window station handle (0x%X) failed\n",
+ PROCESS_WINDOW_STATION());
+ return FALSE;
+ }
+
+ CurInfo = IntGetSysCursorInfo(WinStaObject);
+ if(CurInfo->CursorClipInfo.IsClipped)
+ {
+ Rect.left = CurInfo->CursorClipInfo.Left;
+ Rect.top = CurInfo->CursorClipInfo.Top;
+ Rect.right = CurInfo->CursorClipInfo.Right;
+ Rect.bottom = CurInfo->CursorClipInfo.Bottom;
+ }
+ else
+ {
+ Rect.left = 0;
+ Rect.top = 0;
+ Rect.right = NtUserGetSystemMetrics(SM_CXSCREEN);
+ Rect.bottom = NtUserGetSystemMetrics(SM_CYSCREEN);
+ }
+
+ Status = MmCopyToCaller((PRECT)lpRect, &Rect, sizeof(RECT));
+ if(!NT_SUCCESS(Status))
+ {
+ ObDereferenceObject(WinStaObject);
+ SetLastNtError(Status);
+ return FALSE;
+ }
+
+ ObDereferenceObject(WinStaObject);
+
+ return TRUE;
+}
+
+
+/*
+ * @implemented
+ */
+HCURSOR
+STDCALL
+NtUserSetCursor(
+ HCURSOR hCursor)
+{
+ PCURICON_OBJECT CurIconObject;
+ HICON OldCursor = (HCURSOR)0;
+ PWINSTATION_OBJECT WinStaObject;
+
+ WinStaObject = IntGetWinStaObj();
+ if(WinStaObject == NULL)
+ {
+ return (HCURSOR)0;
+ }
+
+ CurIconObject = IntGetCurIconObject(WinStaObject, hCursor);
+ if(CurIconObject)
+ {
+ OldCursor = IntSetCursor(WinStaObject, CurIconObject, FALSE);
+ IntReleaseCurIconObject(CurIconObject);
+ }
+ else
+ SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+
+ ObDereferenceObject(WinStaObject);
+ return OldCursor;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+NtUserSetCursorIconContents(
+ HANDLE Handle,
+ PICONINFO IconInfo)
+{
+ PCURICON_OBJECT CurIconObject;
+ PBITMAPOBJ bmp;
+ PWINSTATION_OBJECT WinStaObject;
+ NTSTATUS Status;
+ BOOL Ret = FALSE;
+
+ WinStaObject = IntGetWinStaObj();
+ if(WinStaObject == NULL)
+ {
+ return FALSE;
+ }
+
+ CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
+ if(CurIconObject)
+ {
+ /* Copy fields */
+ Status = MmCopyFromCaller(&CurIconObject->IconInfo, IconInfo, sizeof(ICONINFO));
+ if(!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ goto done;
+ }
+
+ bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor);
+ if(bmp)
+ {
+ CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
+ CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy;
+ BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmColor);
+ GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmColor, NULL);
+ }
+ else
+ {
+ bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask);
+ if(!bmp)
+ goto done;
+
+ CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
+ CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
+
+ BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmMask);
+ GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmMask, NULL);
+ }
+
+ Ret = TRUE;
+
+ done:
+ IntReleaseCurIconObject(CurIconObject);
+ ObDereferenceObject(WinStaObject);
+ return Ret;
+ }
+
+ SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+ ObDereferenceObject(WinStaObject);
+ return FALSE;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+NtUserSetCursorIconData(
+ HANDLE Handle,
+ PBOOL fIcon,
+ POINT *Hotspot,
+ HMODULE hModule,
+ HRSRC hRsrc,
+ HRSRC hGroupRsrc)
+{
+ PCURICON_OBJECT CurIconObject;
+ PWINSTATION_OBJECT WinStaObject;
+ NTSTATUS Status;
+ POINT SafeHotspot;
+ BOOL Ret = FALSE;
+
+ WinStaObject = IntGetWinStaObj();
+ if(WinStaObject == NULL)
+ {
+ return FALSE;
+ }
+
+ CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
+ if(CurIconObject)
+ {
+ CurIconObject->hModule = hModule;
+ CurIconObject->hRsrc = hRsrc;
+ CurIconObject->hGroupRsrc = hGroupRsrc;
+
+ /* Copy fields */
+ if(fIcon)
+ {
+ Status = MmCopyFromCaller(&CurIconObject->IconInfo.fIcon, fIcon, sizeof(BOOL));
+ if(!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ goto done;
+ }
+ }
+ else
+ {
+ if(!Hotspot)
+ Ret = TRUE;
+ }
+
+ if(Hotspot)
+ {
+ Status = MmCopyFromCaller(&SafeHotspot, Hotspot, sizeof(POINT));
+ if(NT_SUCCESS(Status))
+ {
+ CurIconObject->IconInfo.xHotspot = SafeHotspot.x;
+ CurIconObject->IconInfo.yHotspot = SafeHotspot.y;
+
+ Ret = TRUE;
+ }
+ else
+ SetLastNtError(Status);
+ }
+
+ if(!fIcon && !Hotspot)
+ {
+ Ret = TRUE;
[truncated at 1000 lines; 213 more skipped]
reactos/subsys/win32k/ntuser
diff -u -r1.27 -r1.28
--- desktop.c 10 Dec 2004 16:52:04 -0000 1.27
+++ desktop.c 12 Dec 2004 01:40:37 -0000 1.28
@@ -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: desktop.c,v 1.27 2004/12/10 16:52:04 navaraf Exp $
+ * $Id: desktop.c,v 1.28 2004/12/12 01:40:37 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -287,6 +287,7 @@
PDC dc;
BITMAPOBJ *BitmapObj;
dc = DC_LockDc(ScreenDeviceContext);
+ /* FIXME - Handle dc == NULL!!!! */
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
if(BitmapObj)
{
reactos/subsys/win32k/ntuser
diff -u -r1.38 -r1.39
--- input.c 28 Sep 2004 15:02:30 -0000 1.38
+++ input.c 12 Dec 2004 01:40:37 -0000 1.39
@@ -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: input.c,v 1.38 2004/09/28 15:02:30 weiden Exp $
+/* $Id: input.c,v 1.39 2004/12/12 01:40:37 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -543,7 +543,6 @@
BITMAPOBJ *BitmapObj;
SURFOBJ *SurfObj;
PDC dc;
- RECTL PointerRect;
PWINDOW_OBJECT DesktopWindow;
NTSTATUS Status;
@@ -649,16 +648,12 @@
{
SurfObj = &BitmapObj->SurfObj;
- if (GDIDEV(SurfObj)->MovePointer)
+ if (GDIDEV(SurfObj)->Pointer.MovePointer)
{
- GDIDEV(SurfObj)->MovePointer(SurfObj, MousePos.x, MousePos.y, &PointerRect);
+ GDIDEV(SurfObj)->Pointer.MovePointer(SurfObj, MousePos.x, MousePos.y, NULL);
}
BITMAPOBJ_UnlockBitmap(hBitmap);
-
- ExAcquireFastMutex(&CurInfo->CursorMutex);
- SetPointerRect(CurInfo, &PointerRect);
- ExReleaseFastMutex(&CurInfo->CursorMutex);
}
}
}
reactos/subsys/win32k/ntuser
diff -u -r1.90 -r1.91
--- misc.c 10 Dec 2004 16:52:04 -0000 1.90
+++ misc.c 12 Dec 2004 01:40:37 -0000 1.91
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.90 2004/12/10 16:52:04 navaraf Exp $
+/* $Id: misc.c,v 1.91 2004/12/12 01:40:37 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -130,9 +130,9 @@
case NOPARAM_ROUTINE_CSRSS_INITIALIZED:
Result = (DWORD)CsrInit();
break;
-
+
case NOPARAM_ROUTINE_GDI_QUERY_TABLE:
- /* not used yet */
+ Result = (DWORD)GDI_MapHandleTable(NtCurrentProcess());
break;
default:
@@ -222,7 +222,9 @@
if (!NT_SUCCESS(Status))
return (DWORD)FALSE;
- Result = (DWORD)IntSwapMouseButton(WinStaObject, (BOOL)Param);
+ /* FIXME
+ Result = (DWORD)IntSwapMouseButton(WinStaObject, (BOOL)Param); */
+ Result = 0;
ObDereferenceObject(WinStaObject);
return Result;
@@ -512,6 +514,100 @@
case TWOPARAM_ROUTINE_REGISTERLOGONPROC:
return (DWORD)IntRegisterLogonProcess(Param1, (BOOL)Param2);
+
+ case TWOPARAM_ROUTINE_SETSYSCOLORS:
+ {
+ DWORD Ret = 0;
+ PVOID Buffer;
+ struct
+ {
+ INT *Elements;
+ COLORREF *Colors;
+ } ChangeSysColors;
+
+ /* FIXME - we should make use of SEH here... */
+
+ Status = MmCopyFromCaller(&ChangeSysColors, (PVOID)Param1, sizeof(ChangeSysColors));
+ if(!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ return 0;
+ }
+
+ Buffer = ExAllocatePool(PagedPool, (Param2 * sizeof(INT)) + (Param2 * sizeof(COLORREF)));
+ if(Buffer != NULL)
+ {
+ INT *Elements = (INT*)Buffer;
+ COLORREF *Colors = (COLORREF*)Buffer + Param2;
+
+ Status = MmCopyFromCaller(Elements, ChangeSysColors.Elements, Param2 * sizeof(INT));
+ if(NT_SUCCESS(Status))
+ {
+ Status = MmCopyFromCaller(Colors, ChangeSysColors.Colors, Param2 * sizeof(COLORREF));
+ if(NT_SUCCESS(Status))
+ {
+ Ret = (DWORD)IntSetSysColors((UINT)Param2, Elements, Colors);
+ }
+ else
+ SetLastNtError(Status);
+ }
+ else
+ SetLastNtError(Status);
+
+ ExFreePool(Buffer);
+ }
+ return Ret;
+ }
+
+ case TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES:
+ case TWOPARAM_ROUTINE_GETSYSCOLORPENS:
+ case TWOPARAM_ROUTINE_GETSYSCOLORS:
+ {
+ DWORD Ret;
+ union
+ {
+ PVOID Pointer;
+ HBRUSH *Brushes;
+ HPEN *Pens;
+ COLORREF *Colors;
+ } Buffer;
+
+ /* FIXME - we should make use of SEH here... */
+
+ Buffer.Pointer = ExAllocatePool(PagedPool, Param2 * sizeof(HANDLE));
+ if(Buffer.Pointer != NULL)
+ {
+ switch(Routine)
+ {
+ case TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES:
+ Ret = (DWORD)IntGetSysColorBrushes(Buffer.Brushes, (UINT)Param2);
+ break;
+ case TWOPARAM_ROUTINE_GETSYSCOLORPENS:
+ Ret = (DWORD)IntGetSysColorPens(Buffer.Pens, (UINT)Param2);
+ break;
+ case TWOPARAM_ROUTINE_GETSYSCOLORS:
+ Ret = (DWORD)IntGetSysColors(Buffer.Colors, (UINT)Param2);
+ break;
+ default:
+ Ret = 0;
+ break;
+ }
+
+ if(Ret > 0)
+ {
+ Status = MmCopyToCaller((PVOID)Param1, Buffer.Pointer, Param2 * sizeof(HANDLE));
+ if(!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ Ret = 0;
+ }
+ }
+
+ ExFreePool(Buffer.Pointer);
+ }
+
+ return Ret;
+ }
}
DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",
reactos/subsys/win32k/ntuser
diff -u -r1.48 -r1.49
--- stubs.c 6 Dec 2004 02:23:05 -0000 1.48
+++ stubs.c 12 Dec 2004 01:40:37 -0000 1.49
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.48 2004/12/06 02:23:05 navaraf Exp $
+/* $Id: stubs.c,v 1.49 2004/12/12 01:40:37 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -8,8 +8,7 @@
* REVISION HISTORY:
* 04-06-2001 CSH Created
*/
-#include <ddk/ntddk.h>
-#include <windows.h>
+#include <w32k.h>
#define NDEBUG
#include <debug.h>
reactos/subsys/win32k/ntuser
diff -u -r1.67 -r1.68
--- windc.c 3 Aug 2004 19:55:57 -0000 1.67
+++ windc.c 12 Dec 2004 01:40:37 -0000 1.68
@@ -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: windc.c,v 1.67 2004/08/03 19:55:57 blight Exp $
+/* $Id: windc.c,v 1.68 2004/12/12 01:40:37 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -586,25 +586,26 @@
return(Dce->hDC);
}
-BOOL FASTCALL
-DCE_InternalDelete(PDCE Dce)
+BOOL INTERNAL_CALL
+DCE_Cleanup(PVOID ObjectBody)
{
PDCE PrevInList;
+ PDCE pDce = (PDCE)ObjectBody;
DCE_LockList();
- if (Dce == FirstDce)
+ if (pDce == FirstDce)
{
- FirstDce = Dce->next;
- PrevInList = Dce;
+ FirstDce = pDce->next;
+ PrevInList = pDce;
}
else
{
for (PrevInList = FirstDce; NULL != PrevInList; PrevInList = PrevInList->next)
{
- if (Dce == PrevInList->next)
+ if (pDce == PrevInList->next)
{
- PrevInList->next = Dce->next;
+ PrevInList->next = pDce->next;
break;
}
}
@@ -665,7 +666,7 @@
* DceFreeDCE
*/
PDCE FASTCALL
-DceFreeDCE(PDCE dce)
+DceFreeDCE(PDCE dce, BOOLEAN Force)
{
DCE *ret;
HANDLE hDce;
@@ -681,6 +682,13 @@
SetDCHook(dce->hDC, NULL, 0L);
#endif
+ if(Force && !GDIOBJ_OwnedByCurrentProcess(dce->hDC))
+ {
+ /* FIXME - changing ownership to current process only works for global objects! */
+ GDIOBJ_SetOwnership(dce->hDC, PsGetCurrentProcess());
+ DC_SetOwnership(dce->hDC, PsGetCurrentProcess());
+ }
+
NtGdiDeleteDC(dce->hDC);
if (dce->hClipRgn && ! (dce->DCXFlags & DCX_KEEPCLIPRGN))
{
@@ -688,6 +696,11 @@
}
hDce = dce->Self;
+ if(Force && !GDIOBJ_OwnedByCurrentProcess(hDce))
+ {
+ /* FIXME - changing ownership to current process only works for global objects! */
+ GDIOBJ_SetOwnership(hDce, PsGetCurrentProcess());
+ }
DCEOBJ_FreeDCE(hDce);
return ret;
@@ -715,7 +728,7 @@
{
if (Window->Class->style & CS_OWNDC) /* owned DCE*/
{
- pDCE = DceFreeDCE(pDCE);
+ pDCE = DceFreeDCE(pDCE, FALSE);
Window->Dce = NULL;
continue;
}
@@ -756,7 +769,7 @@
DCE_LockList();
while (FirstDce != NULL)
{
- DceFreeDCE(FirstDce);
+ DceFreeDCE(FirstDce, TRUE);
}
DCE_UnlockList();
}
@@ -793,9 +806,16 @@
continue;
}
}
+ if (!GDIOBJ_OwnedByCurrentProcess(pDCE->hDC))
+ {
+ /* skip DCs we don't even own */
+ goto skip;
+ }
+
dc = DC_LockDc(pDCE->hDC);
if (dc == NULL)
{
+skip:
if (Window->Self != pDCE->hwndCurrent)
{
IntReleaseWindowObject(CurrentWindow);
reactos/subsys/win32k/ntuser
diff -u -r1.252 -r1.253
--- window.c 11 Dec 2004 21:19:41 -0000 1.252
+++ window.c 12 Dec 2004 01:40:37 -0000 1.253
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: window.c,v 1.252 2004/12/11 21:19:41 weiden Exp $
+/* $Id: window.c,v 1.253 2004/12/12 01:40:37 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -2506,7 +2506,10 @@
}
#endif
- ClassDereferenceObject(ClassObject);
+ if (ClassObject != NULL)
+ {
+ ClassDereferenceObject(ClassObject);
+ }
Cleanup:
if(ClassName.Length > 0 && ClassName.Buffer)
reactos/subsys/win32k/ntuser
diff -u -r1.125 -r1.126
--- winpos.c 11 Dec 2004 19:39:18 -0000 1.125
+++ winpos.c 12 Dec 2004 01:40:38 -0000 1.126
@@ -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: winpos.c,v 1.125 2004/12/11 19:39:18 weiden Exp $
+/* $Id: winpos.c,v 1.126 2004/12/12 01:40:38 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -1046,7 +1046,6 @@
* there's nothing to copy. Also, it's no use copying bits onto
* themselves.
*/
- VisRgn = NULL;
if ((VisRgn = (PROSRGNDATA)RGNDATA_LockRgn(CopyRgn)) &&
UnsafeIntGetRgnBox(VisRgn, &CopyRect) == NULLREGION)
{
reactos/subsys/win32k/ntuser
diff -u -r1.67 -r1.68
--- winsta.c 21 Nov 2004 13:02:02 -0000 1.67
+++ winsta.c 12 Dec 2004 01:40:38 -0000 1.68
@@ -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: winsta.c,v 1.67 2004/11/21 13:02:02 weiden Exp $
+ * $Id: winsta.c,v 1.68 2004/12/12 01:40:38 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -197,8 +197,6 @@
}
DC_SetOwnership(ScreenDeviceContext, NULL);
- EnableMouse(ScreenDeviceContext);
-
NtUserAcquireOrReleaseInputOwnership(FALSE);
return TRUE;
@@ -208,7 +206,6 @@
IntEndDesktopGraphics(VOID)
{
NtUserAcquireOrReleaseInputOwnership(TRUE);
- EnableMouse(FALSE);
if (NULL != ScreenDeviceContext)
{
DC_SetOwnership(ScreenDeviceContext, PsGetCurrentProcess());
@@ -401,8 +398,6 @@
/* FIXME: Obtain the following information from the registry */
CurInfo->SwapButtons = FALSE;
- CurInfo->SafetySwitch = FALSE;
- CurInfo->SafetyRemoveCount = 0;
CurInfo->DblClickSpeed = 500;
CurInfo->DblClickWidth = 4;
CurInfo->DblClickHeight = 4;
reactos/subsys/win32k/objects
diff -N stockobj.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ stockobj.c 12 Dec 2004 01:40:39 -0000 1.2
@@ -0,0 +1,319 @@
+/*
+ * ReactOS W32 Subsystem
+ * Copyright (C) 1998 - 2004 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.
+ */
+/*
+ * STOCKOBJ.C - GDI Stock Objects
+ *
+ * $Id: stockobj.c,v 1.2 2004/12/12 01:40:39 weiden Exp $
+ *
+ */
+#include <w32k.h>
+
+#define NDEBUG
+#include <debug.h>
+
+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 HPEN SysColorPens[NUM_SYSCOLORS];
+static HBRUSH SysColorBrushes[NUM_SYSCOLORS];
+
+/* GDI stock objects */
+
+static LOGBRUSH WhiteBrush =
+{ BS_SOLID, RGB(255,255,255), 0 };
+
+static LOGBRUSH LtGrayBrush =
+/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
+{ BS_SOLID, RGB(192,192,192), 0 };
+
+static LOGBRUSH GrayBrush =
+/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
+{ BS_SOLID, RGB(128,128,128), 0 };
+
+static LOGBRUSH DkGrayBrush =
+/* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
+/* NB_HATCH_STYLES is an index into HatchBrushes */
+{ BS_HATCHED, RGB(0,0,0), NB_HATCH_STYLES };
+
+static LOGBRUSH BlackBrush =
+{ BS_SOLID, RGB(0,0,0), 0 };
+
+static LOGBRUSH NullBrush =
+{ BS_NULL, 0, 0 };
+
+static LOGPEN WhitePen =
+{ PS_SOLID, { 0, 0 }, RGB(255,255,255) };
+
+static LOGPEN BlackPen =
+{ PS_SOLID, { 0, 0 }, RGB(0,0,0) };
+
+static LOGPEN NullPen =
+{ PS_NULL, { 0, 0 }, 0 };
+
+static LOGFONTW OEMFixedFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
+ 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
+
+static LOGFONTW AnsiFixedFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
+
+/*static LOGFONTW AnsiVarFont =
+ *{ 10, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ * 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif" }; */
+
+static LOGFONTW SystemFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
+
+static LOGFONTW DeviceDefaultFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
+
+static LOGFONTW SystemFixedFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
+
+/* FIXME: Is this correct? */
+static LOGFONTW DefaultGuiFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
+
+#define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1)
+
+static HGDIOBJ StockObjects[NB_STOCK_OBJECTS];
+
+/*!
+ * Creates a bunch of stock objects: brushes, pens, fonts.
+*/
+VOID FASTCALL
+CreateStockObjects(void)
+{
+ UINT Object;
+
+ DPRINT("Beginning creation of stock objects\n");
+
+ /* Create GDI Stock Objects from the logical structures we've defined */
+
+ StockObjects[WHITE_BRUSH] = IntGdiCreateBrushIndirect(&WhiteBrush);
+ StockObjects[LTGRAY_BRUSH] = IntGdiCreateBrushIndirect(&LtGrayBrush);
+ StockObjects[GRAY_BRUSH] = IntGdiCreateBrushIndirect(&GrayBrush);
+ StockObjects[DKGRAY_BRUSH] = IntGdiCreateBrushIndirect(&DkGrayBrush);
+ StockObjects[BLACK_BRUSH] = IntGdiCreateBrushIndirect(&BlackBrush);
+ StockObjects[NULL_BRUSH] = IntGdiCreateBrushIndirect(&NullBrush);
+
+ StockObjects[WHITE_PEN] = IntGdiCreatePenIndirect(&WhitePen);
+ StockObjects[BLACK_PEN] = IntGdiCreatePenIndirect(&BlackPen);
+ StockObjects[NULL_PEN] = IntGdiCreatePenIndirect(&NullPen);
+
+ (void) TextIntCreateFontIndirect(&OEMFixedFont, (HFONT*)&StockObjects[OEM_FIXED_FONT]);
+ (void) TextIntCreateFontIndirect(&AnsiFixedFont, (HFONT*)&StockObjects[ANSI_FIXED_FONT]);
+ (void) TextIntCreateFontIndirect(&SystemFont, (HFONT*)&StockObjects[SYSTEM_FONT]);
+ (void) TextIntCreateFontIndirect(&DeviceDefaultFont, (HFONT*)&StockObjects[DEVICE_DEFAULT_FONT]);
+ (void) TextIntCreateFontIndirect(&SystemFixedFont, (HFONT*)&StockObjects[SYSTEM_FIXED_FONT]);
+ (void) TextIntCreateFontIndirect(&DefaultGuiFont, (HFONT*)&StockObjects[DEFAULT_GUI_FONT]);
+
+ StockObjects[DEFAULT_PALETTE] = (HGDIOBJ*)PALETTE_Init();
+
+ for (Object = 0; Object < NB_STOCK_OBJECTS; Object++)
+ {
+ if (NULL != StockObjects[Object])
+ {
+ GDIOBJ_ConvertToStockObj(&StockObjects[Object]);
+ }
+ }
+
+ DPRINT("Completed creation of stock objects\n");
+}
+
+/*!
+ * Return stock object.
+ * \param Object - stock object id.
+ * \return Handle to the object.
+*/
+HGDIOBJ STDCALL
+NtGdiGetStockObject(INT Object)
+{
+ DPRINT("NtGdiGetStockObject index %d\n", Object);
+
+ return ((Object < 0) || (NB_STOCK_OBJECTS <= Object)) ? NULL : StockObjects[Object];
+}
+
+BOOL FASTCALL
+IntSetSysColors(UINT nColors, INT *Elements, COLORREF *Colors)
+{
+ UINT i;
+
+ ASSERT(Elements);
+ ASSERT(Colors);
+
+ for(i = 0; i < nColors; i++)
+ {
+ if((*Elements) >= 0 && (*Elements) < NUM_SYSCOLORS)
+ {
+ SysColors[*Elements] = *Colors;
+ /* FIXME - update the syscolor pens and brushes */
+ }
+ Elements++;
+ Colors++;
+ }
+
+ return nColors > 0;
+}
+
+BOOL FASTCALL
+IntGetSysColorBrushes(HBRUSH *Brushes, UINT nBrushes)
+{
+ UINT i;
+
+ ASSERT(Brushes);
+
+ if(nBrushes > NUM_SYSCOLORS)
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ for(i = 0; i < nBrushes; i++)
+ {
+ *(Brushes++) = SysColorBrushes[i];
+ }
+
+ return nBrushes > 0;
+}
+
+BOOL FASTCALL
+IntGetSysColorPens(HPEN *Pens, UINT nPens)
+{
+ UINT i;
+
+ ASSERT(Pens);
+
+ if(nPens > NUM_SYSCOLORS)
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ for(i = 0; i < nPens; i++)
+ {
+ *(Pens++) = SysColorPens[i];
+ }
+
+ return nPens > 0;
+}
+
+BOOL FASTCALL
+IntGetSysColors(COLORREF *Colors, UINT nColors)
+{
+ UINT i;
+ COLORREF *col;
+
+ ASSERT(Colors);
+
+ if(nColors > NUM_SYSCOLORS)
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ col = &SysColors[0];
+ for(i = 0; i < nColors; i++)
+ {
+ *(Colors++) = *(col++);
+ }
+
+ return nColors > 0;
+}
+
+VOID FASTCALL
+CreateSysColorObjects(VOID)
+{
+ UINT i;
+ LOGBRUSH Brush;
+ LOGPEN Pen;
+
+ /* Create the syscolor brushes */
+ Brush.lbStyle = BS_SOLID;
+ Brush.lbHatch = 0;
+ for(i = 0; i < NUM_SYSCOLORS; i++)
+ {
+ if(SysColorBrushes[i] == NULL)
+ {
+ Brush.lbColor = SysColors[i];
+ SysColorBrushes[i] = IntGdiCreateBrushIndirect(&Brush);
+ if(SysColorBrushes[i] != NULL)
+ {
+ GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorBrushes[i]);
+ }
+ }
+ }
+
+ /* Create the syscolor pens */
+ Pen.lopnStyle = PS_SOLID;
+ Pen.lopnWidth.x = 0;
+ Pen.lopnWidth.y = 0;
+ for(i = 0; i < NUM_SYSCOLORS; i++)
+ {
+ if(SysColorPens[i] == NULL)
+ {
+ Pen.lopnColor = SysColors[i];
+ SysColorPens[i] = IntGdiCreatePenIndirect(&Pen);
+ if(SysColorPens[i] != NULL)
+ {
+ GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorPens[i]);
+ }
+ }
+ }
+}
+
+/* EOF */
reactos/subsys/win32k/objects
diff -u -r1.81 -r1.82
--- bitmaps.c 21 Nov 2004 10:55:29 -0000 1.81
+++ bitmaps.c 12 Dec 2004 01:40:38 -0000 1.82
@@ -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: bitmaps.c,v 1.81 2004/11/21 10:55:29 navaraf Exp $ */
+/* $Id: bitmaps.c,v 1.82 2004/12/12 01:40:38 weiden Exp $ */
#include <w32k.h>
#define IN_RECT(r,x,y) \
@@ -126,6 +126,14 @@
{
DC_UnlockDc(hDCSrc);
}
+ if(BitmapDest != NULL)
+ {
+ BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
+ }
+ if(BitmapSrc != NULL && BitmapSrc != BitmapDest)
+ {
+ BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
+ }
DC_UnlockDc(hDCDest);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
@@ -173,6 +181,18 @@
DC_UnlockDc(hDCSrc);
}
DC_UnlockDc(hDCDest);
+ if(BitmapDest != NULL)
+ {
+ BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
+ }
+ if(BitmapSrc != NULL && BitmapSrc != BitmapDest)
+ {
+ BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
+ }
+ if(BrushObj != NULL)
+ {
+ BRUSHOBJ_UnlockBrush(DCDest->w.hBrush);
+ }
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return FALSE;
}
@@ -185,12 +205,16 @@
if (UsesSource && XlateObj != NULL)
EngDeleteXlate(XlateObj);
- BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
- if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
+
+ if(BitmapDest != NULL)
+ {
+ BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
+ }
+ if (UsesSource && BitmapSrc != BitmapDest)
{
BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
}
- if (UsesPattern)
+ if (BrushObj != NULL)
{
BRUSHOBJ_UnlockBrush(DCDest->w.hBrush);
}
@@ -296,8 +320,10 @@
XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalDestMode, PalSrcMode, DestPalette, SourcePalette);
BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
+ /* FIXME - BitmapDest can be NULL!!!! Don't assert here! */
ASSERT(BitmapDest);
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
+ /* FIXME - BitmapSrc can be NULL!!!! Don't assert here! */
ASSERT(BitmapSrc);
rcDest.left = xDst;
@@ -374,6 +400,7 @@
Size.cx, Size.cy, BitsPerPel, hBitmap);
bmp = BITMAPOBJ_LockBitmap( hBitmap );
+ /* FIXME - bmp can be NULL!!!!!! */
bmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
BITMAPOBJ_UnlockBitmap( hBitmap );
@@ -391,11 +418,10 @@
return hBitmap;
}
-BOOL FASTCALL
-Bitmap_InternalDelete( PBITMAPOBJ pBmp )
+BOOL INTERNAL_CALL
+BITMAP_Cleanup(PVOID ObjectBody)
{
- ASSERT( pBmp );
-
+ PBITMAPOBJ pBmp = (PBITMAPOBJ)ObjectBody;
if (pBmp->SurfObj.pvBits != NULL &&
(pBmp->flFlags & BITMAPOBJ_IS_APIBITMAP))
{
@@ -572,8 +598,8 @@
}
EngDeleteXlate(XlateObj);
}
+ BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
}
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
}
DC_UnlockDc(hDC);
reactos/subsys/win32k/objects
diff -u -r1.41 -r1.42
--- brush.c 5 Dec 2004 00:20:41 -0000 1.41
+++ brush.c 12 Dec 2004 01:40:38 -0000 1.42
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: brush.c,v 1.41 2004/12/05 00:20:41 navaraf Exp $
+ * $Id: brush.c,v 1.42 2004/12/12 01:40:38 weiden Exp $
*/
#include <w32k.h>
@@ -31,11 +31,10 @@
{0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81} /* HS_DIAGCROSS */
};
-BOOL FASTCALL
-Brush_InternalDelete( PGDIBRUSHOBJ pBrush )
+BOOL INTERNAL_CALL
+BRUSH_Cleanup(PVOID ObjectBody)
{
- ASSERT(pBrush);
-
+ PGDIBRUSHOBJ pBrush = (PGDIBRUSHOBJ)ObjectBody;
if(pBrush->flAttrs & (GDIBRUSH_IS_HATCH | GDIBRUSH_IS_BITMAP))
{
ASSERT(pBrush->hbmPattern);
@@ -132,40 +131,44 @@
}
BrushObject = BRUSHOBJ_LockBrush(hBrush);
-
- switch (LogBrush->lbStyle)
+ if(BrushObject != NULL)
{
- case BS_NULL:
- BrushObject->flAttrs |= GDIBRUSH_IS_NULL;
- break;
-
- case BS_SOLID:
- BrushObject->flAttrs |= GDIBRUSH_IS_SOLID;
- BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF;
- /* FIXME: Fill in the rest of fields!!! */
- break;
-
- case BS_HATCHED:
- BrushObject->flAttrs |= GDIBRUSH_IS_HATCH;
- BrushObject->hbmPattern = hPattern;
- BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF;
- break;
-
- case BS_PATTERN:
- BrushObject->flAttrs |= GDIBRUSH_IS_BITMAP;
- BrushObject->hbmPattern = hPattern;
- /* FIXME: Fill in the rest of fields!!! */
- break;
-
- default:
- DPRINT1("Brush Style: %d\n", LogBrush->lbStyle);
- UNIMPLEMENTED;
+ switch (LogBrush->lbStyle)
+ {
+ case BS_NULL:
+ BrushObject->flAttrs |= GDIBRUSH_IS_NULL;
+ break;
+
+ case BS_SOLID:
+ BrushObject->flAttrs |= GDIBRUSH_IS_SOLID;
+ BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF;
+ /* FIXME: Fill in the rest of fields!!! */
+ break;
+
+ case BS_HATCHED:
+ BrushObject->flAttrs |= GDIBRUSH_IS_HATCH;
+ BrushObject->hbmPattern = hPattern;
+ BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF;
+ break;
+
+ case BS_PATTERN:
+ BrushObject->flAttrs |= GDIBRUSH_IS_BITMAP;
+ BrushObject->hbmPattern = hPattern;
+ /* FIXME: Fill in the rest of fields!!! */
+ break;
+
+ default:
+ DPRINT1("Brush Style: %d\n", LogBrush->lbStyle);
+ UNIMPLEMENTED;
+ break;
+ }
+
+ BRUSHOBJ_UnlockBrush(hBrush);
}
if (hPattern != 0)
GDIOBJ_SetOwnership(hPattern, NULL);
- BRUSHOBJ_UnlockBrush(hBrush);
return hBrush;
}
@@ -185,6 +188,8 @@
POINTL BrushOrigin;
BOOL ret = TRUE;
+ ASSERT(BrushObj);
+
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
if (BitmapObj == NULL)
{
@@ -192,7 +197,6 @@
return FALSE;
}
- ASSERT(BrushObj);
if (!(BrushObj->flAttrs & GDIBRUSH_IS_NULL))
{
if (Width > 0)
@@ -264,15 +268,18 @@
for (r = pRects, i = 0; i < cRects; i++)
{
BrushObj = BRUSHOBJ_LockBrush(r->hBrush);
- IntPatBlt(
- dc,
- r->r.left,
- r->r.top,
- r->r.right,
- r->r.bottom,
- dwRop,
- BrushObj);
- BRUSHOBJ_UnlockBrush(r->hBrush);
+ if(BrushObj != NULL)
+ {
+ IntPatBlt(
+ dc,
+ r->r.left,
+ r->r.top,
+ r->r.right,
+ r->r.bottom,
+ dwRop,
+ BrushObj);
+ BRUSHOBJ_UnlockBrush(r->hBrush);
+ }
r++;
}
reactos/subsys/win32k/objects
diff -u -r1.43 -r1.44
--- cliprgn.c 7 Dec 2004 19:53:44 -0000 1.43
+++ cliprgn.c 12 Dec 2004 01:40:38 -0000 1.44
@@ -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: cliprgn.c,v 1.43 2004/12/07 19:53:44 royce Exp $ */
+/* $Id: cliprgn.c,v 1.44 2004/12/12 01:40:38 weiden Exp $ */
#include <w32k.h>
int FASTCALL
@@ -33,35 +33,38 @@
NtGdiCombineRgn(Dc->w.hGCClipRgn, Dc->w.hClipRgn, Dc->w.hVisRgn, RGN_AND);
NtGdiOffsetRgn(Dc->w.hGCClipRgn, Dc->w.DCOrgX, Dc->w.DCOrgY);
- CombinedRegion = RGNDATA_LockRgn(Dc->w.hGCClipRgn);
- ASSERT(CombinedRegion != NULL);
+ if((CombinedRegion = RGNDATA_LockRgn(Dc->w.hGCClipRgn)))
+ {
+ if (Dc->CombinedClip != NULL)
+ IntEngDeleteClipRegion(Dc->CombinedClip);
- if (Dc->CombinedClip != NULL)
- IntEngDeleteClipRegion(Dc->CombinedClip);
+ Dc->CombinedClip = IntEngCreateClipRegion(
+ CombinedRegion->rdh.nCount,
+ (PRECTL)CombinedRegion->Buffer,
+ (PRECTL)&CombinedRegion->rdh.rcBound);
- Dc->CombinedClip = IntEngCreateClipRegion(
- CombinedRegion->rdh.nCount,
- (PRECTL)CombinedRegion->Buffer,
- (PRECTL)&CombinedRegion->rdh.rcBound);
+ RGNDATA_UnlockRgn(Dc->w.hGCClipRgn);
+ }
- RGNDATA_UnlockRgn(Dc->w.hGCClipRgn);
if ( NULL == Dc->CombinedClip )
{
DPRINT1("IntEngCreateClipRegion() failed\n");
return ERROR;
}
+
return NtGdiOffsetRgn(Dc->w.hGCClipRgn, -Dc->w.DCOrgX, -Dc->w.DCOrgY);
}
HRGN WINAPI SaveVisRgn(HDC hdc)
{
HRGN copy;
- PROSRGNDATA obj, copyObj;
+ PROSRGNDATA obj;/*, copyObj;*/
PDC dc = DC_LockDc(hdc);
if (!dc) return 0;
obj = RGNDATA_LockRgn(dc->w.hVisRgn);
+ /* FIXME - Handle obj == NULL!!! */
if(!(copy = NtGdiCreateRectRgn(0, 0, 0, 0)))
{
@@ -70,10 +73,10 @@
return 0;
}
NtGdiCombineRgn(copy, dc->w.hVisRgn, 0, RGN_COPY);
- copyObj = RGNDATA_LockRgn(copy);
+ /* copyObj = RGNDATA_LockRgn(copy); */
/* copyObj->header.hNext = obj->header.hNext;
header.hNext = copy; */
-
+ DC_UnlockDc(hdc);
return copy;
}
@@ -104,7 +107,7 @@
retval = NtGdiCombineRgn(dc->w.hVisRgn, hrgn, 0, RGN_COPY);
if ( retval != ERROR )
- retval = CLIPPING_UpdateGCRegion(dc);
+ CLIPPING_UpdateGCRegion(dc);
DC_UnlockDc( hdc );
return retval;
reactos/subsys/win32k/objects
diff -u -r1.50 -r1.51
--- color.c 14 Jul 2004 20:48:58 -0000 1.50
+++ color.c 12 Dec 2004 01:40:38 -0000 1.51
@@ -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: color.c,v 1.50 2004/07/14 20:48:58 navaraf Exp $ */
+/* $Id: color.c,v 1.51 2004/12/12 01:40:38 weiden Exp $ */
#include <w32k.h>
// FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping
@@ -123,6 +123,7 @@
0, 0, 0);
PalGDI = (PPALGDI) PALETTE_LockPalette(NewPalette);
+ /* FIXME - Handle PalGDI == NULL!!!! */
PALETTE_ValidateFlags(PalGDI->IndexedColors, PalGDI->NumColors);
PalGDI->logicalToSystem = NULL;
@@ -333,6 +334,7 @@
systemPalette = NtGdiGetStockObject((INT)DEFAULT_PALETTE);
palGDI = PALETTE_LockPalette(dc->w.hPalette);
palPtr = (PALOBJ*) palGDI;
+ /* FIXME - Handle palGDI == NULL!!!! */
// Step 1: Create mapping of system palette\DC palette
#ifndef NO_MAPPING
@@ -345,6 +347,7 @@
sysGDI = PALETTE_LockPalette(systemPalette);
sysPtr = (PALOBJ*) sysGDI;
+ /* FIXME - Handle sysGDI == NULL!!!!! */
// Step 2:
// The RealizePalette function modifies the palette for the device associated with the specified device context. If the
reactos/subsys/win32k/objects
diff -u -r1.148 -r1.149
--- dc.c 7 Dec 2004 19:53:44 -0000 1.148
+++ dc.c 12 Dec 2004 01:40:38 -0000 1.149
@@ -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: dc.c,v 1.148 2004/12/07 19:53:44 royce Exp $
+/* $Id: dc.c,v 1.149 2004/12/12 01:40:38 weiden Exp $
*
* DC.C - Device context functions
*
@@ -465,6 +465,7 @@
BOOL GotDriver;
BOOL DoDefault;
ULONG DisplayNumber;
+ RECTL SurfaceRect;
for (DisplayNumber = 0; ; DisplayNumber++)
{
@@ -654,6 +655,11 @@
SurfObj = EngLockSurface((HSURF)PrimarySurface.Handle);
SurfObj->dhpdev = PrimarySurface.PDev;
SurfSize = SurfObj->sizlBitmap;
+ SurfSize = SurfObj->sizlBitmap;
+ SurfaceRect.left = SurfaceRect.top = 0;
+ SurfaceRect.right = SurfObj->sizlBitmap.cx;
+ SurfaceRect.bottom = SurfObj->sizlBitmap.cy;
+ EngEraseSurface(SurfObj, &SurfaceRect, 0);
EngUnlockSurface(SurfObj);
IntShowDesktop(IntGetActiveDesktop(), SurfSize.cx, SurfSize.cy);
break;
@@ -728,6 +734,7 @@
}
NewDC = DC_LockDc( hNewDC );
+ /* FIXME - NewDC can be NULL!!! Don't assert here! */
ASSERT( NewDC );
NewDC->DMW = PrimarySurface.DMW;
@@ -846,8 +853,7 @@
{
return FALSE;
}
- DPRINT( "Deleting DC\n" );
- CHECKPOINT;
+
/* First delete all saved DCs */
while (DCToDelete->saveLevel)
{
@@ -862,7 +868,7 @@
}
DC_SetNextDC (DCToDelete, DC_GetNextDC (savedDC));
DCToDelete->saveLevel--;
- DC_UnlockDc( savedHDC );
+ DC_UnlockDc( savedHDC );
NtGdiDeleteDC (savedHDC);
}
@@ -1064,6 +1070,7 @@
return 0;
}
newdc = DC_LockDc( hnewdc );
+ /* FIXME - newdc can be NULL!!!! Don't assert here!!! */
ASSERT( newdc );
newdc->w.flags = dc->w.flags | DC_SAVED;
@@ -1247,7 +1254,7 @@
GDISelectPalette16( hDC, dcs->w.hPalette, FALSE );
#endif
} else {
- DC_UnlockDc(hDC);
+ DC_UnlockDc(hDC);
}
DC_UnlockDc ( hDCSave );
} else {
@@ -1472,7 +1479,7 @@
INT FASTCALL
IntGdiGetObject(HANDLE Handle, INT Count, LPVOID Buffer)
{
- PGDIOBJHDR GdiObject;
+ PVOID GdiObject;
INT Result = 0;
DWORD ObjectType;
@@ -1517,7 +1524,7 @@
break;
}
- GDIOBJ_UnlockObj(Handle, GDI_OBJECT_TYPE_DONTCARE);
+ GDIOBJ_UnlockObj(Handle);
return Result;
}
@@ -1558,7 +1565,7 @@
NtGdiGetObjectType(HANDLE handle)
{
GDIOBJHDR * ptr;
- INT result = 0;
+ INT result;
DWORD objectType;
ptr = GDIOBJ_LockObj(handle, GDI_OBJECT_TYPE_DONTCARE);
@@ -1610,11 +1617,13 @@
case GDI_OBJECT_TYPE_MEMDC:
result = OBJ_MEMDC;
break;
+
default:
DPRINT1("Magic 0x%08x not implemented\n", objectType);
+ result = 0;
break;
}
- GDIOBJ_UnlockObj(handle, GDI_OBJECT_TYPE_DONTCARE);
+ GDIOBJ_UnlockObj(handle);
return result;
}
@@ -1723,7 +1732,7 @@
dc = DC_LockDc (hDC);
if (dc == NULL)
{
- DC_UnlockDc(dc);
+ DC_UnlockDc(hdcs);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return 0;
}
@@ -1788,7 +1797,7 @@
}
XlateObj = IntGdiCreateBrushXlate(dc, pen, &Failed);
- PENOBJ_UnlockPen((HPEN) hGDIObj);
+ PENOBJ_UnlockPen(hGDIObj);
if (Failed)
{
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
@@ -1811,7 +1820,7 @@
}
XlateObj = IntGdiCreateBrushXlate(dc, brush, &Failed);
- BRUSHOBJ_UnlockBrush((HPEN) hGDIObj);
+ BRUSHOBJ_UnlockBrush(hGDIObj);
if (Failed)
{
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
@@ -1826,9 +1835,11 @@
break;
case GDI_OBJECT_TYPE_FONT:
- objOrg = (HGDIOBJ)dc->w.hFont;
- dc->w.hFont = (HFONT) hGDIObj;
- TextIntRealizeFont(dc->w.hFont);
+ if(NT_SUCCESS(TextIntRealizeFont((HFONT)hGDIObj)))
+ {
+ objOrg = (HGDIOBJ)dc->w.hFont;
+ dc->w.hFont = (HFONT) hGDIObj;
+ }
break;
case GDI_OBJECT_TYPE_BITMAP:
@@ -1882,9 +1893,9 @@
DC_UnlockDc ( hDC );
hVisRgn = NtGdiCreateRectRgn ( 0, 0, pb->SurfObj.sizlBitmap.cx, pb->SurfObj.sizlBitmap.cy );
+ BITMAPOBJ_UnlockBitmap( hGDIObj );
NtGdiSelectVisRgn ( hDC, hVisRgn );
NtGdiDeleteObject ( hVisRgn );
- BITMAPOBJ_UnlockBitmap(hGDIObj);
return objOrg;
@@ -1963,7 +1974,7 @@
RtlCopyMemory(Buf, Driver->Buffer, Driver->MaximumLength);
}
- hDC = (HDC) GDIOBJ_AllocObj(sizeof(DC), GDI_OBJECT_TYPE_DC, (GDICLEANUPPROC) DC_InternalDeleteDC);
+ hDC = (HDC) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DC);
if (hDC == NULL)
{
if(Buf)
@@ -1974,6 +1985,7 @@
}
NewDC = DC_LockDc(hDC);
+ /* FIXME - Handle NewDC == NULL! */
if (Driver != NULL)
{
@@ -2038,17 +2050,17 @@
VOID FASTCALL
DC_FreeDC(HDC DCToFree)
{
- if (!GDIOBJ_FreeObj(DCToFree, GDI_OBJECT_TYPE_DC, GDIOBJFLAG_DEFAULT))
+ if (!GDIOBJ_FreeObj(DCToFree, GDI_OBJECT_TYPE_DC))
{
DPRINT("DC_FreeDC failed\n");
}
}
-BOOL FASTCALL
-DC_InternalDeleteDC( PDC DCToDelete )
+BOOL INTERNAL_CALL
+DC_Cleanup(PVOID ObjectBody)
{
-
- RtlFreeUnicodeString(&DCToDelete->DriverName);
+ PDC pDC = (PDC)ObjectBody;
+ RtlFreeUnicodeString(&pDC->DriverName);
return TRUE;
}
reactos/subsys/win32k/objects
diff -u -r1.56 -r1.57
--- dib.c 3 Jul 2004 13:55:36 -0000 1.56
+++ dib.c 12 Dec 2004 01:40:38 -0000 1.57
@@ -1,5 +1,5 @@
/*
- * $Id: dib.c,v 1.56 2004/07/03 13:55:36 navaraf Exp $
+ * $Id: dib.c,v 1.57 2004/12/12 01:40:38 weiden Exp $
*
* ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
@@ -385,11 +385,13 @@
DestSurfObj = EngLockSurface((HSURF)DestBitmap);
SourcePalette = PALETTE_LockPalette(hSourcePalette);
+ /* FIXME - SourcePalette can be NULL!!! Don't assert here! */
ASSERT(SourcePalette);
SourcePaletteType = SourcePalette->Mode;
PALETTE_UnlockPalette(hSourcePalette);
DestPalette = PALETTE_LockPalette(hDestPalette);
+ /* FIXME - DestPalette can be NULL!!!! Don't assert here!!! */
ASSERT(DestPalette);
DestPaletteType = DestPalette->Mode;
reactos/subsys/win32k/objects
diff -u -r1.52 -r1.53
--- fillshap.c 14 Jul 2004 20:48:58 -0000 1.52
+++ fillshap.c 12 Dec 2004 01:40:38 -0000 1.53
@@ -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: fillshap.c,v 1.52 2004/07/14 20:48:58 navaraf Exp $ */
+/* $Id: fillshap.c,v 1.53 2004/12/12 01:40:38 weiden Exp $ */
#include <w32k.h>
/*
@@ -59,6 +59,7 @@
}
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!!! don't assert but handle this case gracefully! */
ASSERT(BitmapObj);
/* Convert to screen coordinates */
@@ -87,6 +88,7 @@
/* Now fill the polygon with the current brush. */
FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
+ /* FIXME - FillBrushObj can be NULL!!!!!!!! Don't Assert! */
ASSERT(FillBrushObj);
if (!(FillBrushObj->flAttrs & GDIBRUSH_IS_NULL))
{
@@ -97,6 +99,7 @@
/* get BRUSHOBJ from current pen. */
PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
+ /* FIXME - handle PenBrushObj == NULL !!!!! */
IntGdiInitBrushInstance(&PenBrushInst, PenBrushObj, dc->XlatePen);
// Draw the Polygon Edges with the current pen ( if not a NULL pen )
@@ -128,10 +131,10 @@
dc->w.ROPmode); /* MIX */
}
}
+ PENOBJ_UnlockPen( dc->w.hPen );
}
BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- PENOBJ_UnlockPen( dc->w.hPen );
return ret;
}
@@ -250,13 +253,14 @@
PenBrush = PENOBJ_LockPen(dc->w.hPen);
if (NULL == PenBrush)
{
- PENOBJ_UnlockPen(dc->w.hPen);
+ BRUSHOBJ_UnlockBrush(dc->w.hBrush);
DC_UnlockDc(hDC);
SetLastWin32Error(ERROR_INTERNAL_ERROR);
return FALSE;
}
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!!! Don't assert but handle this case gracefully! */
ASSERT(BitmapObj);
IntGdiInitBrushInstance(&FillBrushInst, FillBrush, dc->XlateBrush);
@@ -937,6 +941,7 @@
RECTL DestRect;
ASSERT ( dc ); // caller's responsibility to set this up
+ /* FIXME - BitmapObj can be NULL!!! Don't assert but handle this case gracefully! */
ASSERT ( BitmapObj );
if ( PATH_IsPathOpen(dc->w.path) )
@@ -956,6 +961,7 @@
DestRect.bottom = BottomRect;
FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
+ /* FIXME - Handle FillBrushObj == NULL !!!! */
IntGdiInitBrushInstance(&FillBrushInst, FillBrushObj, dc->XlateBrush);
if ( FillBrushObj )
@@ -1105,9 +1111,11 @@
RectBounds.bottom = bottom;
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!!! Handle this case gracefully instead of ASSERT! */
ASSERT(BitmapObj);
FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
+ /* FIXME - Don't assert if FillBrushObj == NULL, handle this case !!!! */
ASSERT(FillBrushObj);
if (FillBrushObj->flAttrs & GDIBRUSH_IS_NULL)
{
@@ -1116,6 +1124,7 @@
}
PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
+ /* FIXME - PenBrushObject can be NULL!!! Don't assert!!!! */
ASSERT(PenBrushObj);
if (PenBrushObj->flAttrs & GDIBRUSH_IS_NULL)
{
@@ -1304,7 +1313,8 @@
}
BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- PENOBJ_UnlockPen(dc->w.hPen);
+ if(PenBrushObj != NULL)
+ PENOBJ_UnlockPen(dc->w.hPen);
BRUSHOBJ_UnlockBrush(dc->w.hBrush);
return ret;
@@ -1410,9 +1420,11 @@
Extent.bottom += DitherOrg.y;
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!! Don't assert but handle this case gracefully! */
ASSERT(BitmapObj);
PalDestGDI = PALETTE_LockPalette(dc->w.hPalette);
+ /* FIXME - PalDestGDI can be NULL!!! Don't assert but handle this case gracefully! */
ASSERT(PalDestGDI);
Mode = PalDestGDI->Mode;
PALETTE_UnlockPalette(dc->w.hPalette);
reactos/subsys/win32k/objects
diff -u -r1.73 -r1.74
--- gdiobj.c 2 Oct 2004 16:48:12 -0000 1.73
+++ gdiobj.c 12 Dec 2004 01:40:38 -0000 1.74
@@ -1,6 +1,6 @@
/*
* ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
+ * Copyright (C) 1998 - 2004 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
@@ -19,348 +19,290 @@
/*
* GDIOBJ.C - GDI object manipulation routines
*
- * $Id: gdiobj.c,v 1.73 2004/10/02 16:48:12 navaraf Exp $
- *
+ * $Id: gdiobj.c,v 1.74 2004/12/12 01:40:38 weiden Exp $
*/
#include <w32k.h>
-/* count all gdi objects */
-#define GDI_COUNT_OBJECTS 1
+#define NDEBUG
+#include <debug.h>
-/*! Size of the GDI handle table
- * http://www.windevnet.com/documents/s=7290/wdj9902b/9902b.htm
- * gdi handle table can hold 0x4000 handles
-*/
-#define GDI_HANDLE_COUNT 0x4000
+#ifdef __USE_W32API
+/* F*(&#$ header mess!!!! */
+HANDLE
+STDCALL PsGetProcessId(
+ PEPROCESS Process
+ );
+#endif /* __USE_W32API */
-#define GDI_GLOBAL_PROCESS ((HANDLE) 0xffffffff)
-#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))
-
-#define GDI_TYPE_TO_MAGIC(t) ((WORD) ((t) >> 16))
-#define GDI_MAGIC_TO_TYPE(m) ((DWORD)(m) << 16)
-
-/* FIXME Ownership of GDI objects by processes not properly implemented yet */
-#if 0
-#define GDI_VALID_OBJECT(h, obj, t, f) \
- (NULL != (obj) \
- && (GDI_MAGIC_TO_TYPE((obj)->Magic) == (t) || GDI_OBJECT_TYPE_DONTCARE == (t)) \
- && (GDI_HANDLE_GET_TYPE((h)) == GDI_MAGIC_TO_TYPE((obj)->Magic)) \
- && (((obj)->hProcessId == PsGetCurrentProcessId()) \
- || (GDI_GLOBAL_PROCESS == (obj)->hProcessId) \
- || ((f) & GDIOBJFLAG_IGNOREPID)))
-#else
-#define GDI_VALID_OBJECT(h, obj, t, f) \
- (NULL != (obj) \
- && (GDI_MAGIC_TO_TYPE((obj)->Magic) == (t) || GDI_OBJECT_TYPE_DONTCARE == (t)) \
- && (GDI_HANDLE_GET_TYPE((h)) == GDI_MAGIC_TO_TYPE((obj)->Magic)))
-#endif
+
+
+#define GDI_ENTRY_TO_INDEX(ht, e) \
+ (((ULONG_PTR)(e) - (ULONG_PTR)&((ht)->Entries[0])) / sizeof(GDI_TABLE_ENTRY))
+#define GDI_HANDLE_GET_ENTRY(HandleTable, h) \
+ (&(HandleTable)->Entries[GDI_HANDLE_GET_INDEX((h))])
+
+#define GDIBdyToHdr(body) \
+ ((PGDIOBJHDR)(body) - 1)
+#define GDIHdrToBdy(hdr) \
+ (PGDIOBJ)((PGDIOBJHDR)(hdr) + 1)
+
+/* apparently the first 10 entries are never used in windows as they are empty */
+#define RESERVE_ENTRIES_COUNT 10
typedef struct _GDI_HANDLE_TABLE
{
- WORD wTableSize;
- WORD AllocationHint;
- #if GDI_COUNT_OBJECTS
- ULONG HandlesCount;
- #endif
+ LONG HandlesCount;
+ LONG nEntries;
PPAGED_LOOKASIDE_LIST LookasideLists;
- PGDIOBJHDR Handles[1];
+
+ PGDI_TABLE_ENTRY EntriesEnd;
+
+ GDI_TABLE_ENTRY Entries[1];
} GDI_HANDLE_TABLE, *PGDI_HANDLE_TABLE;
typedef struct
{
ULONG Type;
ULONG Size;
-} GDI_OBJ_SIZE;
+ GDICLEANUPPROC CleanupProc;
+} GDI_OBJ_INFO, *PGDI_OBJ_INFO;
+
+/*
+ * Dummy GDI Cleanup Callback
+ */
+BOOL INTERNAL_CALL
+GDI_CleanupDummy(PVOID ObjectBody)
+{
+ return TRUE;
+}
+/* Testing shows that regions are the most used GDIObj type,
+ so put that one first for performance */
const
-GDI_OBJ_SIZE ObjSizes[] =
+GDI_OBJ_INFO ObjInfo[] =
{
- /* Testing shows that regions are the most used GDIObj type,
- so put that one first for performance */
- {GDI_OBJECT_TYPE_REGION, sizeof(ROSRGNDATA)},
- {GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAPOBJ)},
- {GDI_OBJECT_TYPE_DC, sizeof(DC)},
- {GDI_OBJECT_TYPE_PALETTE, sizeof(PALGDI)},
- {GDI_OBJECT_TYPE_BRUSH, sizeof(GDIBRUSHOBJ)},
- {GDI_OBJECT_TYPE_PEN, sizeof(GDIBRUSHOBJ)},
- {GDI_OBJECT_TYPE_FONT, sizeof(TEXTOBJ)},
- {GDI_OBJECT_TYPE_DCE, sizeof(DCE)},
-/*
- {GDI_OBJECT_TYPE_DIRECTDRAW, sizeof(DD_DIRECTDRAW)},
- {GDI_OBJECT_TYPE_DD_SURFACE, sizeof(DD_SURFACE)},
-*/
- {GDI_OBJECT_TYPE_EXTPEN, 0},
- {GDI_OBJECT_TYPE_METADC, 0},
- {GDI_OBJECT_TYPE_METAFILE, 0},
- {GDI_OBJECT_TYPE_ENHMETAFILE, 0},
- {GDI_OBJECT_TYPE_ENHMETADC, 0},
- {GDI_OBJECT_TYPE_MEMDC, 0},
- {GDI_OBJECT_TYPE_EMF, 0}
+ /* Type */ /* Size */ /* CleanupProc */
+ {GDI_OBJECT_TYPE_REGION, sizeof(ROSRGNDATA), RGNDATA_Cleanup},
+ {GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAPOBJ), BITMAP_Cleanup},
+ {GDI_OBJECT_TYPE_DC, sizeof(DC), DC_Cleanup},
+ {GDI_OBJECT_TYPE_PALETTE, sizeof(PALGDI), PALETTE_Cleanup},
+ {GDI_OBJECT_TYPE_BRUSH, sizeof(GDIBRUSHOBJ), BRUSH_Cleanup},
+ {GDI_OBJECT_TYPE_PEN, sizeof(GDIBRUSHOBJ), GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_FONT, sizeof(TEXTOBJ), GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_DCE, sizeof(DCE), DCE_Cleanup},
+/*{GDI_OBJECT_TYPE_DIRECTDRAW, sizeof(DD_DIRECTDRAW), DD_Cleanup},
+ {GDI_OBJECT_TYPE_DD_SURFACE, sizeof(DD_SURFACE), DDSURF_Cleanup},*/
+ {GDI_OBJECT_TYPE_EXTPEN, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_METADC, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_METAFILE, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_ENHMETAFILE, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_ENHMETADC, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_MEMDC, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_EMF, 0, GDI_CleanupDummy}
};
-#define OBJTYPE_COUNT (sizeof(ObjSizes) / sizeof(ObjSizes[0]))
-
-/* GDI stock objects */
-
-static LOGBRUSH WhiteBrush =
-{ BS_SOLID, RGB(255,255,255), 0 };
-
-static LOGBRUSH LtGrayBrush =
-/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
-{ BS_SOLID, RGB(192,192,192), 0 };
-
-static LOGBRUSH GrayBrush =
-/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
-{ BS_SOLID, RGB(128,128,128), 0 };
-
-static LOGBRUSH DkGrayBrush =
-/* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
-/* NB_HATCH_STYLES is an index into HatchBrushes */
-{ BS_HATCHED, RGB(0,0,0), NB_HATCH_STYLES };
-
-static LOGBRUSH BlackBrush =
-{ BS_SOLID, RGB(0,0,0), 0 };
-
-static LOGBRUSH NullBrush =
-{ BS_NULL, 0, 0 };
-
-static LOGPEN WhitePen =
-{ PS_SOLID, { 0, 0 }, RGB(255,255,255) };
-
-static LOGPEN BlackPen =
-{ PS_SOLID, { 0, 0 }, RGB(0,0,0) };
-
-static LOGPEN NullPen =
-{ PS_NULL, { 0, 0 }, 0 };
-
-static LOGFONTW OEMFixedFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
- 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
+#define OBJTYPE_COUNT (sizeof(ObjInfo) / sizeof(ObjInfo[0]))
-static LOGFONTW AnsiFixedFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
+static PGDI_HANDLE_TABLE HandleTable = NULL;
+static LARGE_INTEGER ShortDelay;
-/*static LOGFONTW AnsiVarFont =
- *{ 10, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- * 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif" }; */
-
-static LOGFONTW SystemFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
-
-static LOGFONTW DeviceDefaultFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
-
-static LOGFONTW SystemFixedFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
-
-/* FIXME: Is this correct? */
-static LOGFONTW DefaultGuiFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
-
-#define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1)
-
-static HGDIOBJ StockObjects[NB_STOCK_OBJECTS];
-static PGDI_HANDLE_TABLE HandleTable = 0;
-static FAST_MUTEX HandleTableMutex;
-static FAST_MUTEX RefCountHandling;
-static LARGE_INTEGER ShortDelay;
+#define DelayExecution() \
+ DPRINT("%s:%i: Delay\n", __FILE__, __LINE__); \
+ KeDelayExecutionThread(KernelMode, FALSE, &ShortDelay)
/*!
* Allocate GDI object table.
* \param Size - number of entries in the object table.
- * Notes:: Must be called at IRQL < DISPATCH_LEVEL.
*/
-static PGDI_HANDLE_TABLE FASTCALL
-GDIOBJ_iAllocHandleTable (WORD Size)
+static PGDI_HANDLE_TABLE INTERNAL_CALL
+GDIOBJ_iAllocHandleTable(ULONG Entries)
{
- PGDI_HANDLE_TABLE handleTable;
- ULONG MemSize;
+ PGDI_HANDLE_TABLE handleTable;
UINT ObjType;
-
- MemSize = sizeof(GDI_HANDLE_TABLE) + sizeof(PGDIOBJ) * Size;
+ ULONG MemSize = sizeof(GDI_HANDLE_TABLE) + (sizeof(GDI_TABLE_ENTRY) * (Entries - 1));
- ExAcquireFastMutex(&HandleTableMutex);
- handleTable = ExAllocatePoolWithTag(PagedPool, MemSize, TAG_GDIHNDTBLE);
+ handleTable = ExAllocatePoolWithTag(NonPagedPool, MemSize, TAG_GDIHNDTBLE);
ASSERT( handleTable );
- memset (handleTable, 0, MemSize);
-#if GDI_COUNT_OBJECTS
+ RtlZeroMemory(handleTable, MemSize);
+
handleTable->HandlesCount = 0;
-#endif
- handleTable->wTableSize = Size;
- handleTable->AllocationHint = 1;
- handleTable->LookasideLists = ExAllocatePoolWithTag(PagedPool,
+ handleTable->nEntries = Entries;
+
+ handleTable->EntriesEnd = &handleTable->Entries[Entries];
+
+ handleTable->LookasideLists = ExAllocatePoolWithTag(NonPagedPool,
OBJTYPE_COUNT * sizeof(PAGED_LOOKASIDE_LIST),
TAG_GDIHNDTBLE);
- if (NULL == handleTable->LookasideLists)
- {
- ExFreePool(handleTable);
- ExReleaseFastMutex(&HandleTableMutex);
- return NULL;
- }
- for (ObjType = 0; ObjType < OBJTYPE_COUNT; ObjType++)
- {
- ExInitializePagedLookasideList(handleTable->LookasideLists + ObjType, NULL, NULL, 0,
- ObjSizes[ObjType].Size + sizeof(GDIOBJHDR), TAG_GDIOBJ, 0);
- }
- ExReleaseFastMutex(&HandleTableMutex);
+ if(handleTable->LookasideLists == NULL)
+ {
+ ExFreePool(handleTable);
+ return NULL;
+ }
+
+ for(ObjType = 0; ObjType < OBJTYPE_COUNT; ObjType++)
+ {
+ ExInitializePagedLookasideList(handleTable->LookasideLists + ObjType, NULL, NULL, 0,
+ ObjInfo[ObjType].Size + sizeof(GDIOBJHDR), TAG_GDIOBJ, 0);
+ }
+
+ ShortDelay.QuadPart = -5000LL; /* FIXME - 0.5 ms? */
return handleTable;
}
-/*!
- * Returns the entry into the handle table by index.
-*/
-static PGDIOBJHDR FASTCALL
-GDIOBJ_iGetObjectForIndex(WORD TableIndex)
+static inline PPAGED_LOOKASIDE_LIST
+FindLookasideList(DWORD ObjectType)
{
- if (0 == TableIndex || HandleTable->wTableSize < TableIndex)
+ int Index;
+
+ for (Index = 0; Index < OBJTYPE_COUNT; Index++)
+ {
+ if (ObjInfo[Index].Type == ObjectType)
{
- DPRINT1("Invalid TableIndex %u\n", (unsigned) TableIndex);
- return NULL;
+ return HandleTable->LookasideLists + Index;
}
+ }
+
+ DPRINT1("Can't find lookaside list for object type 0x%08x\n", ObjectType);
- return HandleTable->Handles[TableIndex];
+ return NULL;
}
-/*!
- * Finds next free entry in the GDI handle table.
- * \return index into the table is successful, zero otherwise.
-*/
-static WORD FASTCALL
-GDIOBJ_iGetNextOpenHandleIndex (void)
+static inline BOOL
+RunCleanupCallback(PGDIOBJ pObj, DWORD ObjectType)
{
- WORD tableIndex;
-
- for (tableIndex = HandleTable->AllocationHint;
- tableIndex < HandleTable->wTableSize;
- tableIndex++)
- {
- if (HandleTable->Handles[tableIndex] == NULL)
- {
- HandleTable->AllocationHint = tableIndex + 1;
- return tableIndex;
- }
- }
+ int Index;
- for (tableIndex = 1;
- tableIndex < HandleTable->AllocationHint;
- tableIndex++)
- {
- if (HandleTable->Handles[tableIndex] == NULL)
- {
- HandleTable->AllocationHint = tableIndex + 1;
- return tableIndex;
- }
- }
+ for (Index = 0; Index < OBJTYPE_COUNT; Index++)
+ {
+ if (ObjInfo[Index].Type == ObjectType)
+ {
+ return ((GDICLEANUPPROC)ObjInfo[Index].CleanupProc)(pObj);
+ }
+ }
- return 0;
+ DPRINT1("Can't find cleanup callback for object type 0x%08x\n", ObjectType);
+ return TRUE;
}
-static PPAGED_LOOKASIDE_LIST FASTCALL
-FindLookasideList(DWORD ObjectType)
+static inline ULONG
+GetObjectSize(DWORD ObjectType)
{
int Index;
for (Index = 0; Index < OBJTYPE_COUNT; Index++)
+ {
+ if (ObjInfo[Index].Type == ObjectType)
{
- if (ObjSizes[Index].Type == ObjectType)
- {
- return HandleTable->LookasideLists + Index;
- }
+ return ObjInfo[Index].Size;
}
+ }
- DPRINT1("Can't find lookaside list for object type 0x%08x\n", ObjectType);
-
- return NULL;
+ DPRINT1("Can't find size for object type 0x%08x\n", ObjectType);
+ return 0;
}
/*!
* Allocate memory for GDI object and return handle to it.
*
- * \param Size - size of the GDI object. This shouldn't to include the size of GDIOBJHDR.
- * The actual amount of allocated memory is sizeof(GDIOBJHDR)+Size
* \param ObjectType - type of object \ref GDI object types
- * \param CleanupProcPtr - Routine to be called on destruction of object
*
* \return Handle of the allocated object.
*
* \note Use GDIOBJ_Lock() to obtain pointer to the new object.
+ * \todo return the object pointer and lock it by default.
*/
-HGDIOBJ FASTCALL
-GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProc)
+HGDIOBJ INTERNAL_CALL
+GDIOBJ_AllocObj(ULONG ObjectType)
{
PW32PROCESS W32Process;
PGDIOBJHDR newObject;
- WORD Index;
PPAGED_LOOKASIDE_LIST LookasideList;
+ LONG CurrentProcessId, LockedProcessId;
- ExAcquireFastMutex(&HandleTableMutex);
- Index = GDIOBJ_iGetNextOpenHandleIndex ();
- if (0 == Index)
- {
- ExReleaseFastMutex(&HandleTableMutex);
- DPRINT1("Out of GDI handles\n");
- return NULL;
- }
+ ASSERT(ObjectType != GDI_OBJECT_TYPE_DONTCARE);
LookasideList = FindLookasideList(ObjectType);
- if (NULL == LookasideList)
+ if(LookasideList != NULL)
+ {
+ newObject = ExAllocateFromPagedLookasideList(LookasideList);
+ if(newObject != NULL)
{
- ExReleaseFastMutex(&HandleTableMutex);
- return NULL;
+ PGDI_TABLE_ENTRY Entry;
+ PGDIOBJ ObjectBody;
+ LONG TypeInfo;
+
+ /* shift the process id to the left so we can use the first bit to lock
+ the object.
+ FIXME - don't shift once ROS' PIDs match with nt! */
+ CurrentProcessId = (LONG)PsGetCurrentProcessId() << 1;
+ LockedProcessId = CurrentProcessId | 0x1;
+ W32Process = PsGetWin32Process();
+
+ newObject->LockingThread = NULL;
+ newObject->Locks = 0;
+
+#ifdef GDI_DEBUG
+ newObject->lockfile = NULL;
+ newObject->lockline = 0;
+#endif
+
+ ObjectBody = GDIHdrToBdy(newObject);
+
+ RtlZeroMemory(ObjectBody, GetObjectSize(ObjectType));
+
+ TypeInfo = (ObjectType & 0xFFFF0000) | (ObjectType >> 16);
+
+ /* Search for a free handle entry */
+ for(Entry = &HandleTable->Entries[RESERVE_ENTRIES_COUNT];
+ Entry < HandleTable->EntriesEnd;
+ Entry++)
+ {
+ LONG PrevProcId = InterlockedCompareExchange(&Entry->ProcessId, LockedProcessId, 0);
+ if(PrevProcId == 0)
+ {
+ if(InterlockedCompareExchangePointer(&Entry->KernelData, ObjectBody, NULL) == NULL)
+ {
+ HGDIOBJ Handle;
+ UINT Index = GDI_ENTRY_TO_INDEX(HandleTable, Entry);
+
+ Handle = (HGDIOBJ)((Index & 0xFFFF) | (ObjectType & 0xFFFF0000));
+
+ /* we found a free entry, no need to exchange this field atomically
+ since we're holding the lock */
+ Entry->Type = TypeInfo;
+
+ InterlockedExchange(&Entry->ProcessId, CurrentProcessId);
+
+ if(W32Process != NULL)
+ {
+ InterlockedIncrement(&W32Process->GDIObjects);
+ }
+
+ DPRINT("GDIOBJ_AllocObj: 0x%x ob: 0x%x\n", Handle, ObjectBody);
+ return Handle;
+ }
+ else
+ {
+ InterlockedExchange(&Entry->ProcessId, PrevProcId);
+ }
+ }
+ }
+
+ ExFreeToPagedLookasideList(LookasideList, newObject);
+ DPRINT1("Failed to insert gdi object into the handle table, no handles left!\n");
}
- newObject = ExAllocateFromPagedLookasideList(LookasideList);
- if (NULL == newObject)
+ else
{
- ExReleaseFastMutex(&HandleTableMutex);
- DPRINT1("Unable to allocate GDI object from lookaside list\n");
- return NULL;
- }
- RtlZeroMemory (newObject, Size + sizeof(GDIOBJHDR));
-
- newObject->wTableIndex = Index;
-
- newObject->dwCount = 0;
- newObject->hProcessId = PsGetCurrentProcessId ();
- newObject->CleanupProc = CleanupProc;
- newObject->Magic = GDI_TYPE_TO_MAGIC(ObjectType);
- newObject->lockfile = NULL;
- newObject->lockline = 0;
-#ifdef GDIOBJ_USE_FASTMUTEX
- ExInitializeFastMutex(&newObject->Lock);
- newObject->RecursiveLockCount = 0;
-#else
- newObject->LockTid = 0;
- newObject->LockCount = 0;
-#endif
- HandleTable->Handles[Index] = newObject;
-#if GDI_COUNT_OBJECTS
- HandleTable->HandlesCount++;
-#endif
- ExReleaseFastMutex(&HandleTableMutex);
-
- W32Process = PsGetCurrentProcess()->Win32Process;
- if(W32Process)
+ DPRINT1("Not enough memory to allocate gdi object!\n");
+ }
+ }
+ else
{
- W32Process->GDIObjects++;
+ DPRINT1("Failed to find lookaside list for object type 0x%x\n", ObjectType);
}
-
- return GDI_HANDLE_CREATE(Index, ObjectType);
+ return NULL;
}
/*!
@@ -368,77 +310,137 @@
* appropriate cleanup routine.
*
* \param hObj - handle of the object to be deleted.
- * \param ObjectType - one of the \ref GDI object types
- * or GDI_OBJECT_TYPE_DONTCARE.
- * \param Flag - if set to GDIOBJFLAG_IGNOREPID then the routine doesn't check if the process that
- * tries to delete the object is the same one that created it.
*
* \return Returns TRUE if succesful.
- *
- * \note You should only use GDIOBJFLAG_IGNOREPID if you are cleaning up after the process that terminated.
- * \note This function deferres object deletion if it is still in use.
+ * \return Returns FALSE if the cleanup routine returned FALSE or the object doesn't belong
+ * to the calling process.
*/
-BOOL STDCALL
-GDIOBJ_FreeObj(HGDIOBJ hObj, DWORD ObjectType, DWORD Flag)
+BOOL INTERNAL_CALL
+#ifdef GDI_DEBUG
+GDIOBJ_FreeObjDbg(const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
+#else /* !GDI_DEBUG */
+GDIOBJ_FreeObj(HGDIOBJ hObj, DWORD ObjectType)
+#endif /* GDI_DEBUG */
{
- PW32PROCESS W32Process;
- PGDIOBJHDR objectHeader;
- PGDIOBJ Obj;
+ PGDI_TABLE_ENTRY Entry;
PPAGED_LOOKASIDE_LIST LookasideList;
- BOOL bRet = TRUE;
+ LONG ProcessId, LockedProcessId, PrevProcId, ExpectedType;
+#ifdef GDI_DEBUG
+ ULONG Attempts = 0;
+#endif
- objectHeader = GDIOBJ_iGetObjectForIndex(GDI_HANDLE_GET_INDEX(hObj));
- DPRINT("GDIOBJ_FreeObj: hObj: 0x%08x, object: %x\n", hObj, objectHeader);
+ DPRINT("GDIOBJ_FreeObj: hObj: 0x%08x\n", hObj);
+
+ if(GDI_HANDLE_IS_STOCKOBJ(hObj))
+ {
+ DPRINT1("GDIOBJ_FreeObj() failed, can't delete stock object handle: 0x%x !!!\n", hObj);
+#ifdef GDI_DEBUG
+ DPRINT1("-> called from %s:%i\n", file, line);
+#endif
+ return FALSE;
+ }
+
+ /* shift the process id to the left so we can use the first bit to lock the object.
+ FIXME - don't shift once ROS' PIDs match with nt! */
+ ProcessId = (LONG)PsGetCurrentProcessId() << 1;
+ LockedProcessId = ProcessId | 0x1;
+
+ ExpectedType = ((ObjectType != GDI_OBJECT_TYPE_DONTCARE) ? ObjectType : 0);
+
+ Entry = GDI_HANDLE_GET_ENTRY(HandleTable, hObj);
+
+LockHandle:
+ /* lock the object, we must not delete global objects, so don't exchange the locking
+ process ID to zero when attempting to lock a global object... */
+ PrevProcId = InterlockedCompareExchange(&Entry->ProcessId, LockedProcessId, ProcessId);
+ if(PrevProcId == ProcessId)
+ {
+ if(Entry->Type != 0 && Entry->KernelData != NULL && (ExpectedType == 0 || ((Entry->Type << 16) == ExpectedType)))
+ {
+ PGDIOBJHDR GdiHdr;
+
+ GdiHdr = GDIBdyToHdr(Entry->KernelData);
+
+ if(GdiHdr->LockingThread == NULL)
+ {
+ BOOL Ret;
+ ULONG Type = Entry->Type << 16;
+
+ /* Clear the type field so when unlocking the handle it gets finally deleted */
+ Entry->Type = 0;
+ Entry->KernelData = NULL;
+
+ /* unlock the handle slot */
+ InterlockedExchange(&Entry->ProcessId, 0);
+
+ /* call the cleanup routine. */
+ Ret = RunCleanupCallback(GDIHdrToBdy(GdiHdr), Type);
+
+ /* Now it's time to free the memory */
+ LookasideList = FindLookasideList(Type);
+ if(LookasideList != NULL)
+ {
+ ExFreeToPagedLookasideList(LookasideList, GdiHdr);
+ }
- if (! GDI_VALID_OBJECT(hObj, objectHeader, ObjectType, Flag)
- || GDI_GLOBAL_PROCESS == objectHeader->hProcessId)
+ return Ret;
+ }
+ else
+ {
+ /* the object is currently locked. just clear the type field so when the
+ object gets unlocked it will be finally deleted from the table. */
+ Entry->Type = 0;
+
+ /* unlock the handle slot */
+ InterlockedExchange(&Entry->ProcessId, 0);
+ /* report a successful deletion as the object is actually removed from the table */
+ return TRUE;
+ }
+ }
+ else
{
- DPRINT1("Can't delete hObj:0x%08x, type:0x%08x, flag:%d\n", hObj, ObjectType, Flag);
- return FALSE;
+ if(Entry->Type != 0)
+ {
+ DPRINT1("Attempted to delete object 0x%x, type mismatch (0x%x : 0x%x)\n", hObj, ObjectType, ExpectedType);
+ }
+ else
+ {
+ DPRINT1("Attempted to delete object 0x%x which was already deleted!\n", hObj);
+ }
+ InterlockedExchange(&Entry->ProcessId, PrevProcId);
}
-
- DPRINT("FreeObj: locks: %x\n", objectHeader->dwCount );
- if (!(Flag & GDIOBJFLAG_IGNORELOCK))
+ }
+ else if(PrevProcId == LockedProcessId)
+ {
+#ifdef GDI_DEBUG
+ if(++Attempts > 20)
{
- /* check that the reference count is zero. if not then set flag
- * and delete object when releaseobj is called */
- ExAcquireFastMutex(&RefCountHandling);
- if ((objectHeader->dwCount & ~0x80000000) > 0 )
- {
- DPRINT("GDIOBJ_FreeObj: delayed object deletion: count %d\n", objectHeader->dwCount);
- objectHeader->dwCount |= 0x80000000;
- ExReleaseFastMutex(&RefCountHandling);
- return TRUE;
- }
- ExReleaseFastMutex(&RefCountHandling);
+ DPRINT1("[%d]Waiting on 0x%x\n", Attempts, hObj);
}
-
- /* allow object to delete internal data */
- if (NULL != objectHeader->CleanupProc)
+#endif
+ /* the object is currently locked, wait some time and try again.
+ FIXME - we shouldn't loop forever! Give up after some time! */
+ DelayExecution();
+ /* try again */
+ goto LockHandle;
+ }
+ else
+ {
+ if((PrevProcId >> 1) == 0)
{
- Obj = (PGDIOBJ)((PCHAR)objectHeader + sizeof(GDIOBJHDR));
- bRet = (*(objectHeader->CleanupProc))(Obj);
+ DPRINT1("Attempted to free global gdi handle 0x%x, caller needs to get ownership first!!!", hObj);
}
- LookasideList = FindLookasideList(GDI_MAGIC_TO_TYPE(objectHeader->Magic));
- if (NULL != LookasideList)
+ else
{
- ExFreeToPagedLookasideList(LookasideList, objectHeader);
+ DPRINT1("Attempted to free foreign handle: 0x%x Owner: 0x%x from Caller: 0x%x\n", hObj, PrevProcId >> 1, ProcessId >> 1);
}
- ExAcquireFastMutexUnsafe (&HandleTableMutex);
- HandleTable->Handles[GDI_HANDLE_GET_INDEX(hObj)] = NULL;
-#if GDI_COUNT_OBJECTS
- HandleTable->HandlesCount--;
+#ifdef GDI_DEBUG
+ DPRINT1("-> called from %s:%i\n", file, line);
#endif
- ExReleaseFastMutexUnsafe (&HandleTableMutex);
-
- W32Process = PsGetCurrentProcess()->Win32Process;
- if(W32Process)
- {
- W32Process->GDIObjects--;
}
- return bRet;
+ return FALSE;
}
/*!
@@ -451,7 +453,7 @@
*
* \note this function uses an O(n^2) algoritm because we shouldn't need to call it with more than 3 or 4 objects.
*/
-BOOL FASTCALL
+BOOL INTERNAL_CALL
GDIOBJ_LockMultipleObj(PGDIMULTILOCK pList, INT nObj)
{
INT i, j;
@@ -493,7 +495,7 @@
*
* \note this function uses O(n^2) algoritm because we shouldn't need to call it with more than 3 or 4 objects.
*/
-BOOL FASTCALL
+BOOL INTERNAL_CALL
GDIOBJ_UnlockMultipleObj(PGDIMULTILOCK pList, INT nObj)
{
INT i, j;
@@ -512,7 +514,7 @@
pList[j].pObj = NULL;
}
}
- GDIOBJ_UnlockObj(pList[i].hObj, pList[i].ObjectType);
+ GDIOBJ_UnlockObj(pList[i].hObj);
pList[i].pObj = NULL;
}
}
@@ -521,101 +523,15 @@
}
/*!
- * Get the type of the object.
- * \param ObjectHandle - handle of the object.
- * \return One of the \ref GDI object types
-*/
-DWORD FASTCALL
-GDIOBJ_GetObjectType(HGDIOBJ ObjectHandle)
-{
- PGDIOBJHDR ObjHdr;
-
- ObjHdr = GDIOBJ_iGetObjectForIndex(GDI_HANDLE_GET_INDEX(ObjectHandle));
- if (NULL == ObjHdr
- || ! GDI_VALID_OBJECT(ObjectHandle, ObjHdr, GDI_MAGIC_TO_TYPE(ObjHdr->Magic), 0))
- {
- DPRINT1("Invalid ObjectHandle 0x%08x\n", ObjectHandle);
- return 0;
- }
- DPRINT("GDIOBJ_GetObjectType for handle 0x%08x returns 0x%08x\n", ObjectHandle,
- GDI_MAGIC_TO_TYPE(ObjHdr->Magic));
-
- return GDI_MAGIC_TO_TYPE(ObjHdr->Magic);
-}
-
-/*!
* Initialization of the GDI object engine.
*/
-VOID FASTCALL
+VOID INTERNAL_CALL
InitGdiObjectHandleTable (VOID)
{
DPRINT("InitGdiObjectHandleTable\n");
- ExInitializeFastMutex (&HandleTableMutex);
- ExInitializeFastMutex (&RefCountHandling);
-
- ShortDelay.QuadPart = -100;
HandleTable = GDIOBJ_iAllocHandleTable (GDI_HANDLE_COUNT);
- DPRINT("HandleTable: %x\n", HandleTable );
-
- InitEngHandleTable();
-}
-
-/*!
- * Creates a bunch of stock objects: brushes, pens, fonts.
-*/
-VOID FASTCALL
-CreateStockObjects(void)
-{
- unsigned Object;
-
- DPRINT("Beginning creation of stock objects\n");
-
- /* Create GDI Stock Objects from the logical structures we've defined */
-
- StockObjects[WHITE_BRUSH] = IntGdiCreateBrushIndirect(&WhiteBrush);
- StockObjects[LTGRAY_BRUSH] = IntGdiCreateBrushIndirect(&LtGrayBrush);
- StockObjects[GRAY_BRUSH] = IntGdiCreateBrushIndirect(&GrayBrush);
- StockObjects[DKGRAY_BRUSH] = IntGdiCreateBrushIndirect(&DkGrayBrush);
- StockObjects[BLACK_BRUSH] = IntGdiCreateBrushIndirect(&BlackBrush);
- StockObjects[NULL_BRUSH] = IntGdiCreateBrushIndirect(&NullBrush);
-
- StockObjects[WHITE_PEN] = IntGdiCreatePenIndirect(&WhitePen);
- StockObjects[BLACK_PEN] = IntGdiCreatePenIndirect(&BlackPen);
- StockObjects[NULL_PEN] = IntGdiCreatePenIndirect(&NullPen);
-
- (void) TextIntCreateFontIndirect(&OEMFixedFont, (HFONT*)&StockObjects[OEM_FIXED_FONT]);
- (void) TextIntCreateFontIndirect(&AnsiFixedFont, (HFONT*)&StockObjects[ANSI_FIXED_FONT]);
- (void) TextIntCreateFontIndirect(&SystemFont, (HFONT*)&StockObjects[SYSTEM_FONT]);
- (void) TextIntCreateFontIndirect(&DeviceDefaultFont, (HFONT*)&StockObjects[DEVICE_DEFAULT_FONT]);
- (void) TextIntCreateFontIndirect(&SystemFixedFont, (HFONT*)&StockObjects[SYSTEM_FIXED_FONT]);
- (void) TextIntCreateFontIndirect(&DefaultGuiFont, (HFONT*)&StockObjects[DEFAULT_GUI_FONT]);
-
- StockObjects[DEFAULT_PALETTE] = (HGDIOBJ*)PALETTE_Init();
-
- for (Object = 0; Object < NB_STOCK_OBJECTS; Object++)
- {
- if (NULL != StockObjects[Object])
- {
- GDIOBJ_SetOwnership(StockObjects[Object], NULL);
-/* GDI_HANDLE_SET_STOCKOBJ(StockObjects[Object]);*/
- }
- }
-
- DPRINT("Completed creation of stock objects\n");
-}
-
-/*!
- * Return stock object.
- * \param Object - stock object id.
- * \return Handle to the object.
-*/
-HGDIOBJ STDCALL
-NtGdiGetStockObject(INT Object)
-{
- DPRINT("NtGdiGetStockObject index %d\n", Object);
-
- return ((Object < 0) || (NB_STOCK_OBJECTS <= Object)) ? NULL : StockObjects[Object];
+ DPRINT("HandleTable: %x\n", HandleTable);
}
/*!
@@ -629,19 +545,21 @@
DPRINT("NtGdiDeleteObject handle 0x%08x\n", hObject);
return NULL != hObject
- ? GDIOBJ_FreeObj(hObject, GDI_OBJECT_TYPE_DONTCARE, GDIOBJFLAG_DEFAULT) : FALSE;
+ ? GDIOBJ_FreeObj(hObject, GDI_OBJECT_TYPE_DONTCARE) : FALSE;
}
/*!
* Internal function. Called when the process is destroyed to free the remaining GDI handles.
* \param Process - PID of the process that will be destroyed.
*/
-BOOL FASTCALL
-CleanupForProcess (struct _EPROCESS *Process, INT Pid)
+BOOL INTERNAL_CALL
+GDI_CleanupForProcess (struct _EPROCESS *Process)
{
- DWORD i;
- PGDIOBJHDR objectHeader;
+ PGDI_TABLE_ENTRY Entry;
PEPROCESS CurrentProcess;
+ PW32PROCESS W32Process;
+ LONG ProcId;
+ ULONG Index = RESERVE_ENTRIES_COUNT;
DPRINT("Starting CleanupForProcess prochandle %x Pid %d\n", Process, Pid);
CurrentProcess = PsGetCurrentProcess();
@@ -649,366 +567,764 @@
{
KeAttachProcess(Process);
}
+ W32Process = Process->Win32Process;
+ ASSERT(W32Process);
- for(i = 1; i < HandleTable->wTableSize; i++)
- {
- objectHeader = GDIOBJ_iGetObjectForIndex(i);
- if (NULL != objectHeader &&
- (INT) objectHeader->hProcessId == Pid)
- {
- DPRINT("CleanupForProcess: %d, process: %d, locks: %d, magic: 0x%x", i, objectHeader->hProcessId, objectHeader->dwCount, objectHeader->Magic);
- GDIOBJ_FreeObj(GDI_HANDLE_CREATE(i, GDI_MAGIC_TO_TYPE(objectHeader->Magic)),
- GDI_MAGIC_TO_TYPE(objectHeader->Magic),
- GDIOBJFLAG_IGNOREPID | GDIOBJFLAG_IGNORELOCK);
- }
- }
-
- if (CurrentProcess != Process)
+ if(W32Process->GDIObjects > 0)
+ {
+ /* FIXME - Instead of building the handle here and delete it using GDIOBJ_FreeObj
+ we should delete it directly here! */
+ ProcId = ((LONG)Process->UniqueProcessId << 1);
+
+ for(Entry = &HandleTable->Entries[RESERVE_ENTRIES_COUNT];
+ Entry < HandleTable->EntriesEnd;
+ Entry++, Index++)
{
- KeDetachProcess();
- }
-
- DPRINT("Completed cleanup for process %d\n", Pid);
-
- return TRUE;
-}
+ /* ignore the lock bit */
+ if((Entry->ProcessId & ~0x1) == ProcId && Entry->Type != 0)
+ {
+ HGDIOBJ ObjectHandle;
-#define GDIOBJ_TRACKLOCKS
+ /* Create the object handle for the entry, the upper 16 bit of the
+ Type field includes the type of the object including the stock
+ object flag - but since stock objects don't have a process id we can
+ simply ignore this fact here. */
+ ObjectHandle = (HGDIOBJ)(Index | (Entry->Type & 0xFFFF0000));
-#ifdef GDIOBJ_LockObj
-#undef GDIOBJ_LockObj
-PGDIOBJ FASTCALL
-GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
-{
- PGDIOBJHDR ObjHdr = GDIOBJ_iGetObjectForIndex(GDI_HANDLE_GET_INDEX(hObj));
-#ifndef GDIOBJ_USE_FASTMUTEX
- DWORD CurrentTid = (DWORD)PsGetCurrentThreadId();
-#endif
-
- DPRINT("(%s:%i) GDIOBJ_LockObjDbg(0x%08x,0x%08x)\n", file, line, hObj, ObjectType);
- if (! GDI_VALID_OBJECT(hObj, ObjHdr, ObjectType, GDIOBJFLAG_DEFAULT))
- {
- int reason = 0;
- if (NULL == ObjHdr)
- {
- reason = 1;
- }
- else if (GDI_MAGIC_TO_TYPE(ObjHdr->Magic) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE)
- {
- reason = 2;
- }
- else if (ObjHdr->hProcessId != GDI_GLOBAL_PROCESS
- && ObjHdr->hProcessId != PsGetCurrentProcessId())
- {
- reason = 3;
- }
- else if (GDI_HANDLE_GET_TYPE(hObj) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE)
- {
- reason = 4;
- }
- DPRINT1("GDIOBJ_LockObj failed for 0x%08x, reqtype 0x%08x reason %d\n",
- hObj, ObjectType, reason );
- DPRINT1("\tcalled from: %s:%i\n", file, line );
- return NULL;
- }
-
-#ifdef GDIOBJ_USE_FASTMUTEX
[truncated at 1000 lines; 946 more skipped]
reactos/subsys/win32k/objects
diff -u -r1.37 -r1.38
--- line.c 14 Jul 2004 20:48:58 -0000 1.37
+++ line.c 12 Dec 2004 01:40:38 -0000 1.38
@@ -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: line.c,v 1.37 2004/07/14 20:48:58 navaraf Exp $ */
+/* $Id: line.c,v 1.38 2004/12/12 01:40:38 weiden Exp $ */
#include <w32k.h>
// Some code from the WINE project source (www.winehq.com)
@@ -98,6 +98,7 @@
/* get BRUSHOBJ from current pen. */
PenBrushObj = PENOBJ_LockPen( dc->w.hPen );
+ /* FIXME - PenBrushObj can be NULL!!!! Don't assert here! */
ASSERT(PenBrushObj);
if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
@@ -202,6 +203,7 @@
/* Get BRUSHOBJ from current pen. */
PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
+ /* FIXME - PenBrushObj can be NULL! Don't assert here! */
ASSERT(PenBrushObj);
if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
@@ -210,6 +212,7 @@
if (Points != NULL)
{
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!!! Don't assert but handle this case gracefully! */
ASSERT(BitmapObj);
RtlCopyMemory(Points, pt, Count * sizeof(POINT));
reactos/subsys/win32k/objects
diff -u -r1.20 -r1.21
--- palette.c 22 Jun 2004 20:08:17 -0000 1.20
+++ palette.c 12 Dec 2004 01:40:38 -0000 1.21
@@ -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: palette.c,v 1.20 2004/06/22 20:08:17 gvg Exp $ */
+/* $Id: palette.c,v 1.21 2004/12/12 01:40:38 weiden Exp $ */
#include <w32k.h>
#ifndef NO_MAPPING
@@ -36,12 +36,13 @@
return COLOR_sysPal;
}
-static BOOL FASTCALL
-PALETTE_InternalDelete(PPALGDI Palette)
+BOOL INTERNAL_CALL
+PALETTE_Cleanup(PVOID ObjectBody)
{
- if (NULL != Palette->IndexedColors)
+ PPALGDI pPal = (PPALGDI)ObjectBody;
+ if (NULL != pPal->IndexedColors)
{
- ExFreePool(Palette->IndexedColors);
+ ExFreePool(pPal->IndexedColors);
}
return TRUE;
@@ -58,13 +59,14 @@
HPALETTE NewPalette;
PPALGDI PalGDI;
- NewPalette = (HPALETTE) GDIOBJ_AllocObj(sizeof(PALGDI), GDI_OBJECT_TYPE_PALETTE, (GDICLEANUPPROC) PALETTE_InternalDelete);
+ NewPalette = (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
if (NULL == NewPalette)
{
return NULL;
}
PalGDI = PALETTE_LockPalette(NewPalette);
+ /* FIXME - PalGDI can be NULL!!! Don't assert here! */
ASSERT( PalGDI );
PalGDI->Self = NewPalette;
@@ -106,13 +108,14 @@
PPALGDI PalGDI;
unsigned i;
- NewPalette = (HPALETTE) GDIOBJ_AllocObj(sizeof(PALGDI), GDI_OBJECT_TYPE_PALETTE, (GDICLEANUPPROC) PALETTE_InternalDelete);
+ NewPalette = (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
if (NULL == NewPalette)
{
return NULL;
}
PalGDI = PALETTE_LockPalette(NewPalette);
+ /* FIXME - PalGDI can be NULL!!! Don't assert here! */
ASSERT( PalGDI );
PalGDI->Self = NewPalette;
@@ -227,6 +230,7 @@
HPALETTE hSysPal = NtGdiGetStockObject(DEFAULT_PALETTE);
PPALGDI pSysPal = PALETTE_LockPalette(hSysPal);
PPALGDI palGDI = (PPALGDI) palPtr;
+ /* FIXME - handle pSysPal == NULL!!!!!!! */
COLOR_sysPal = pSysPal->IndexedColors;
PALETTE_UnlockPalette(hSysPal); // FIXME: Is this a right way to obtain pointer to the system palette?
reactos/subsys/win32k/objects
diff -u -r1.16 -r1.17
--- pen.c 14 Jul 2004 20:48:58 -0000 1.16
+++ pen.c 12 Dec 2004 01:40:38 -0000 1.17
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: pen.c,v 1.16 2004/07/14 20:48:58 navaraf Exp $
+ * $Id: pen.c,v 1.17 2004/12/12 01:40:38 weiden Exp $
*/
#include <w32k.h>
@@ -42,6 +42,7 @@
}
PenObject = PENOBJ_LockPen(hPen);
+ /* FIXME - Handle PenObject == NULL!!! */
PenObject->ptPenWidth = LogPen->lopnWidth;
PenObject->ulPenStyle = LogPen->lopnStyle;
PenObject->BrushAttr.lbColor = LogPen->lopnColor;
reactos/subsys/win32k/objects
diff -u -r1.23 -r1.24
--- print.c 17 Jul 2004 17:37:41 -0000 1.23
+++ print.c 12 Dec 2004 01:40:38 -0000 1.24
@@ -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: print.c,v 1.23 2004/07/17 17:37:41 blight Exp $ */
+/* $Id: print.c,v 1.24 2004/12/12 01:40:38 weiden Exp $ */
#include <w32k.h>
INT
@@ -85,6 +85,8 @@
BITMAPOBJ *BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
INT Result;
+ /* FIXME - Handle BitmapObj == NULL !!!!!! */
+
if ( NULL == dc->DriverFunctions.Escape )
{
Result = IntEngExtEscape(
reactos/subsys/win32k/objects
diff -u -r1.63 -r1.64
--- region.c 11 Dec 2004 22:39:38 -0000 1.63
+++ region.c 12 Dec 2004 01:40:38 -0000 1.64
@@ -113,12 +113,26 @@
* the y-x-banding that's so nice to have...
*/
-/* $Id: region.c,v 1.63 2004/12/11 22:39:38 weiden Exp $ */
+/* $Id: region.c,v 1.64 2004/12/12 01:40:38 weiden Exp $ */
#include <w32k.h>
#include <win32k/float.h>
// Internal Functions
+#if 1
+#define COPY_RECTS(dest, src, nRects) \
+ do { \
+ PRECT xDest = (dest); \
+ PRECT xSrc = (src); \
+ UINT xRects = (nRects); \
+ while(xRects-- > 0) { \
+ *(xDest++) = *(xSrc++); \
+ } \
+ } while(0)
+#else
+#define COPY_RECTS(dest, src, nRects) RtlCopyMemory(dest, src, (nRects) * sizeof(RECT))
+#endif
+
#define EMPTY_REGION(pReg) { \
(pReg)->rdh.nCount = 0; \
(pReg)->rdh.rcBound.left = (pReg)->rdh.rcBound.top = 0; \
@@ -382,8 +396,6 @@
#define LARGE_COORDINATE 0x7fffffff /* FIXME */
#define SMALL_COORDINATE 0x80000000
-
-
/*
* Check to see if there is enough memory in the present region.
*/
@@ -394,7 +406,10 @@
if (temp == 0)
return 0;
- RtlCopyMemory( temp, *firstrect, reg->rdh.nRgnSize );
+
+ /* copy the rectangles */
+ COPY_RECTS(temp, *firstrect, reg->rdh.nCount);
+
reg->rdh.nRgnSize *= 2;
if (*firstrect != ®->rdh.rcBound)
ExFreePool( *firstrect );
@@ -473,7 +488,7 @@
dst->rdh.rcBound.right = src->rdh.rcBound.right;
dst->rdh.rcBound.bottom = src->rdh.rcBound.bottom;
dst->rdh.iType = src->rdh.iType;
- RtlCopyMemory(dst->Buffer, src->Buffer, (int)(src->rdh.nCount * sizeof(RECT)));
+ COPY_RECTS(dst->Buffer, src->Buffer, src->rdh.nCount);
}
return TRUE;
}
@@ -546,7 +561,9 @@
ULONG i;
if(rgnDst != rgnSrc)
- RtlCopyMemory(rgnDst, rgnSrc, sizeof(ROSRGNDATA));
+ {
+ *rgnDst = *rgnSrc;
+ }
if(off->x || off->y)
{
@@ -563,7 +580,9 @@
rgnDst->rdh.rcBound.bottom += off->y;
}
else
- RtlCopyMemory(xrect, rgnSrc->Buffer, rgnDst->rdh.nCount * sizeof(RECT));
+ {
+ COPY_RECTS(xrect, rgnSrc->Buffer, rgnDst->rdh.nCount);
+ }
rgnDst->Buffer = xrect;
} else
@@ -1137,7 +1156,7 @@
newReg->Buffer = prev_rects;
else{
newReg->rdh.nRgnSize = newReg->rdh.nCount*sizeof(RECT);
- RtlCopyMemory( newReg->Buffer, prev_rects, newReg->rdh.nRgnSize );
+ COPY_RECTS(newReg->Buffer, prev_rects, newReg->rdh.nCount);
if (prev_rects != &newReg->rdh.rcBound)
ExFreePool( prev_rects );
}
@@ -1883,8 +1902,7 @@
PROSRGNDATA pReg;
BOOL bRet;
- if ((hReg = (HRGN) GDIOBJ_AllocObj(sizeof(ROSRGNDATA), GDI_OBJECT_TYPE_REGION,
- (GDICLEANUPPROC) RGNDATA_InternalDelete)))
+ if ((hReg = (HRGN) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_REGION)))
{
if (NULL != (pReg = RGNDATA_LockRgn(hReg)))
{
@@ -1921,9 +1939,10 @@
return NULL;
}
-BOOL FASTCALL RGNDATA_InternalDelete( PROSRGNDATA pRgn )
+BOOL INTERNAL_CALL
+RGNDATA_Cleanup(PVOID ObjectBody)
{
- ASSERT(pRgn);
+ PROSRGNDATA pRgn = (PROSRGNDATA)ObjectBody;
if(pRgn->Buffer && pRgn->Buffer != &pRgn->rdh.rcBound)
ExFreePool(pRgn->Buffer);
return TRUE;
@@ -2237,8 +2256,8 @@
NtGdiPatBlt(hDC, r->left, r->top, r->right - r->left, r->bottom - r->top, PATCOPY);
}
- NtGdiSelectObject(hDC, oldhBrush);
RGNDATA_UnlockRgn( hRgn );
+ NtGdiSelectObject(hDC, oldhBrush);
return TRUE;
}
@@ -2438,6 +2457,7 @@
BrushOrigin.x = dc->w.brushOrgX;
BrushOrigin.y = dc->w.brushOrgY;
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - Handle BitmapObj == NULL !!!! */
bRet = IntEngPaint(BitmapObj,
ClipRegion,
@@ -2446,7 +2466,7 @@
0xFFFF);//FIXME:don't know what to put here
BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- RGNDATA_UnlockRgn( tmpVisRgn );
+ RGNDATA_UnlockRgn( hRgn );
// Fill the region
DC_UnlockDc( hDC );
@@ -2571,7 +2591,7 @@
RECT SafeRect;
PROSRGNDATA Rgn;
- if(!(Rgn = (PROSRGNDATA)RGNDATA_UnlockRgn(hDest)))
+ if(!(Rgn = (PROSRGNDATA)RGNDATA_LockRgn(hDest)))
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return NULL;
@@ -2870,7 +2890,7 @@
}
if(reg->Buffer != NULL)
{
- RtlCopyMemory(temp, reg->Buffer, reg->rdh.nCount * sizeof(RECT));
+ COPY_RECTS(temp, reg->Buffer, reg->rdh.nCount);
if(reg->Buffer != ®->rdh.rcBound)
ExFreePool(reg->Buffer);
}
reactos/subsys/win32k/objects
diff -u -r1.112 -r1.113
--- text.c 7 Oct 2004 05:26:54 -0000 1.112
+++ text.c 12 Dec 2004 01:40:38 -0000 1.113
@@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: text.c,v 1.112 2004/10/07 05:26:54 sedwards Exp $ */
+/* $Id: text.c,v 1.113 2004/12/12 01:40:38 weiden Exp $ */
#include <w32k.h>
#include <ft2build.h>
@@ -33,7 +33,7 @@
typedef struct _FONT_ENTRY {
LIST_ENTRY ListEntry;
- HFONT hFont;
+ FONTGDI *Font;
UNICODE_STRING FaceName;
BYTE NotEnum;
} FONT_ENTRY, *PFONT_ENTRY;
@@ -247,9 +247,7 @@
INT FASTCALL
IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
{
- HFONT NewFont;
- FONTOBJ *FontObj;
- PFONTGDI FontGDI;
+ FONTGDI *FontGDI;
NTSTATUS Status;
HANDLE FileHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
@@ -261,20 +259,6 @@
ANSI_STRING AnsiFaceName;
PFONT_ENTRY Entry;
- /* Create handle for the font */
-
- NewFont = (HFONT)CreateGDIHandle(
- sizeof(FONTGDI),
- sizeof(FONTOBJ),
- (PVOID*)&FontGDI,
- (PVOID*)&FontObj);
-
- if (NewFont == 0)
- {
- DPRINT("Could not allocate a new GDI font object\n");
- return 0;
- }
-
/* Open the font file */
InitializeObjectAttributes(&ObjectAttributes, FileName, 0, NULL, NULL);
@@ -289,7 +273,6 @@
if (!NT_SUCCESS(Status))
{
DPRINT("Could not font file: %wZ\n", FileName);
- NtGdiDeleteObject(NewFont);
return 0;
}
@@ -305,7 +288,6 @@
if (!NT_SUCCESS(Status))
{
DPRINT("Could not get file size\n");
- NtGdiDeleteObject(NewFont);
ZwClose(FileHandle);
return 0;
}
@@ -315,12 +297,11 @@
Buffer = ExAllocatePoolWithTag(
PagedPool,
FileStdInfo.EndOfFile.u.LowPart,
- TAG_GDITEXT);
+ TAG_FNTFILE);
if (Buffer == NULL)
{
DPRINT("Could not allocate memory for font");
- NtGdiDeleteObject(NewFont);
ZwClose(FileHandle);
return 0;
}
@@ -342,7 +323,6 @@
{
DPRINT("Could not read the font file into memory");
ExFreePool(Buffer);
- NtGdiDeleteObject(NewFont);
ZwClose(FileHandle);
return 0;
}
@@ -365,7 +345,6 @@
else
DPRINT("Error reading font file (error code: %u)\n", Error);
ExFreePool(Buffer);
- NtGdiDeleteObject(NewFont);
return 0;
}
@@ -378,6 +357,16 @@
return 0;
}
+ FontGDI = EngAllocMem(0, sizeof(FONTGDI), TAG_FONTOBJ);
+ if(FontGDI == NULL)
+ {
+ FT_Done_Face(Face);
+ ExFreePool(Buffer);
+ ExFreePool(Entry);
+ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+ return 0;
+ }
+
/* FontGDI->Filename = FileName; perform strcpy */
FontGDI->face = Face;
@@ -392,7 +381,7 @@
/* Add this font resource to the font table */
- Entry->hFont = NewFont;
+ Entry->Font = FontGDI;
Entry->NotEnum = (Characteristics & FR_NOT_ENUM);
RtlInitAnsiString(&AnsiFaceName, (LPSTR)Face->family_name);
RtlAnsiStringToUnicodeString(&Entry->FaceName, &AnsiFaceName, TRUE);
@@ -451,39 +440,6 @@
}
return FT_RENDER_MODE_MONO;
}
-static NTSTATUS STDCALL
-GetFontObjectsFromTextObj(PTEXTOBJ TextObj, HFONT *FontHandle, FONTOBJ **FontObj, PFONTGDI *FontGDI)
-{
- FONTOBJ *FntObj;
- NTSTATUS Status = STATUS_SUCCESS;
-
- ASSERT(NULL != TextObj && NULL != TextObj->GDIFontHandle);
- if (NULL != TextObj && NULL != TextObj->GDIFontHandle)
- {
- if (NULL != FontHandle)
- {
- *FontHandle = TextObj->GDIFontHandle;
- }
- FntObj = (FONTOBJ*)AccessUserObject((ULONG) TextObj->GDIFontHandle);
- if (NULL != FontObj)
- {
- *FontObj = FntObj;
- if (NULL == *FontObj)
- {
- ASSERT(FALSE);
- Status = STATUS_INVALID_HANDLE;
- }
- }
- if (NT_SUCCESS(Status) && NULL != FontGDI)
- {
- *FontGDI = AccessInternalObjectFromUserObject(FntObj);
- }
-
- return Status;
- }
-
- return STATUS_INVALID_HANDLE;
-}
int
STDCALL
@@ -1007,18 +963,16 @@
PFONT_ENTRY CurrentEntry;
ANSI_STRING EntryFaceNameA;
UNICODE_STRING EntryFaceNameW;
- PFONTGDI FontGDI;
+ FONTGDI *FontGDI;
Entry = Head->Flink;
while (Entry != Head)
{
CurrentEntry = (PFONT_ENTRY) CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
- if (NULL == (FontGDI = AccessInternalObject((ULONG) CurrentEntry->hFont)))
- {
- Entry = Entry->Flink;
- continue;
- }
+ FontGDI = CurrentEntry->Font;
+ ASSERT(FontGDI);
+
RtlInitAnsiString(&EntryFaceNameA, FontGDI->face->family_name);
RtlAnsiStringToUnicodeString(&EntryFaceNameW, &EntryFaceNameA, TRUE);
if ((LF_FACESIZE - 1) * sizeof(WCHAR) < EntryFaceNameW.Length)
@@ -1275,18 +1229,16 @@
PFONT_ENTRY CurrentEntry;
ANSI_STRING EntryFaceNameA;
UNICODE_STRING EntryFaceNameW;
- PFONTGDI FontGDI;
+ FONTGDI *FontGDI;
Entry = Head->Flink;
while (Entry != Head)
{
CurrentEntry = (PFONT_ENTRY) CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
- if (NULL == (FontGDI = AccessInternalObject((ULONG) CurrentEntry->hFont)))
- {
- Entry = Entry->Flink;
- continue;
- }
+ FontGDI = CurrentEntry->Font;
+ ASSERT(FontGDI);
+
RtlInitAnsiString(&EntryFaceNameA, FontGDI->face->family_name);
RtlAnsiStringToUnicodeString(&EntryFaceNameW, &EntryFaceNameA, TRUE);
if ((LF_FACESIZE - 1) * sizeof(WCHAR) < EntryFaceNameW.Length)
@@ -1605,6 +1557,7 @@
if (hBrushBg)
{
BrushBg = BRUSHOBJ_LockBrush(hBrushBg);
+ /* FIXME - Handle BrushBg == NULL !!!!! */
IntGdiInitBrushInstance(&BrushBgInst, BrushBg, NULL);
}
else
@@ -1652,12 +1605,14 @@
}
TextObj = TEXTOBJ_LockText(dc->w.hFont);
-
- if (!NT_SUCCESS(GetFontObjectsFromTextObj(TextObj, NULL, &FontObj, &FontGDI)))
+ if(TextObj == NULL)
{
- goto fail;
+ goto fail;
}
+ FontObj = TextObj->Font;
+ FontGDI = ObjToGDI(FontObj, FONT);
+
face = FontGDI->face;
if (face->charmap == NULL)
{
@@ -1913,7 +1868,8 @@
EngDeleteXlate(XlateObj);
EngDeleteXlate(XlateObj2);
BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- TEXTOBJ_UnlockText(dc->w.hFont);
+ if(TextObj != NULL)
+ TEXTOBJ_UnlockText(dc->w.hFont);
if (hBrushBg != NULL)
{
BRUSHOBJ_UnlockBrush(hBrushBg);
@@ -1925,12 +1881,13 @@
{
ExFreePool(Dx);
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc( hDC );
return TRUE;
fail:
- TEXTOBJ_UnlockText(dc->w.hFont);
+ if(TextObj != NULL)
+ TEXTOBJ_UnlockText(dc->w.hFont);
BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
if (hBrushBg != NULL)
{
@@ -2043,13 +2000,7 @@
return FALSE;
}
- if (!NT_SUCCESS(GetFontObjectsFromTextObj(TextObj, NULL, NULL, &FontGDI)))
- {
- ExFreePool(SafeBuffer);
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- TEXTOBJ_UnlockText(hFont);
- return FALSE;
- }
+ FontGDI = ObjToGDI(TextObj->Font, FONT);
face = FontGDI->face;
if (face->charmap == NULL)
@@ -2197,10 +2148,7 @@
FT_CharMap charmap, found = NULL;
BOOL use_kerning;
- if (!NT_SUCCESS(GetFontObjectsFromTextObj(TextObj, NULL, NULL, &FontGDI)))
- {
- return FALSE;
- }
+ FontGDI = ObjToGDI(TextObj->Font, FONT);
face = FontGDI->face;
if (NULL != Fit)
@@ -2381,6 +2329,7 @@
return FALSE;
}
TextObj = TEXTOBJ_LockText(dc->w.hFont);
+ /* FIXME - TextObj can be NULL!!!! Handle this case!!! */
DC_UnlockDc(hDC);
Result = TextIntGetTextExtentPoint(hDC, TextObj, String, Count, MaxExtent,
NULL == UnsafeFit ? NULL : &Fit, Dx, &Size);
@@ -2503,6 +2452,7 @@
return FALSE;
}
TextObj = TEXTOBJ_LockText(dc->w.hFont);
+ /* FIXME - TextObj can be NULL!!! Handle this case!!! */
DC_UnlockDc(hDC);
Result = TextIntGetTextExtentPoint (
hDC, TextObj, String, Count, 0, NULL, NULL, &Size);
@@ -2583,9 +2533,8 @@
TextObj = TEXTOBJ_LockText(dc->w.hFont);
if (NULL != TextObj)
{
- Status = GetFontObjectsFromTextObj(TextObj, NULL, NULL, &FontGDI);
- if (NT_SUCCESS(Status))
- {
+ FontGDI = ObjToGDI(TextObj->Font, FONT);
+
Face = FontGDI->face;
IntLockFreeType;
Error = FT_Set_Pixel_Sizes(Face,
@@ -2625,7 +2574,6 @@
}
Status = MmCopyToCaller(tm, &SafeTm, sizeof(TEXTMETRICW));
}
- }
TEXTOBJ_UnlockText(dc->w.hFont);
}
else
@@ -2748,7 +2696,6 @@
PTEXTOBJ TextObj;
PFONTGDI FontGdi;
DWORD Result = GDI_ERROR;
- NTSTATUS Status;
Dc = DC_LockDc(hDC);
if (Dc == NULL)
@@ -2766,27 +2713,25 @@
return GDI_ERROR;
}
- Status = GetFontObjectsFromTextObj(TextObj, NULL, NULL, &FontGdi);
- if (NT_SUCCESS(Status))
- {
- IntLockFreeType;
-
- if (FT_IS_SFNT(FontGdi->face))
- {
- if (Table)
- Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
- (Table << 8 & 0xFF0000);
+ FontGdi = ObjToGDI(TextObj->Font, FONT);
+
+ IntLockFreeType;
- if (Buffer == NULL)
- Size = 0;
+ if (FT_IS_SFNT(FontGdi->face))
+ {
+ if (Table)
+ Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
+ (Table << 8 & 0xFF0000);
- if (!FT_Load_Sfnt_Table(FontGdi->face, Table, Offset, Buffer, &Size))
- Result = Size;
- }
+ if (Buffer == NULL)
+ Size = 0;
- IntUnLockFreeType;
+ if (!FT_Load_Sfnt_Table(FontGdi->face, Table, Offset, Buffer, &Size))
+ Result = Size;
}
+ IntUnLockFreeType;
+
TEXTOBJ_UnlockText(hFont);
return Result;
@@ -2847,35 +2792,34 @@
return Score;
}
-static VOID FASTCALL
-FindBestFontFromList(HFONT *Font, UINT *MatchScore, LOGFONTW *LogFont,
+static inline VOID
+FindBestFontFromList(FONTOBJ **FontObj, UINT *MatchScore, LOGFONTW *LogFont,
PUNICODE_STRING FaceName, PLIST_ENTRY Head)
{
PLIST_ENTRY Entry;
PFONT_ENTRY CurrentEntry;
- PFONTGDI FontGDI;
+ FONTGDI *FontGDI;
UINT Score;
Entry = Head->Flink;
while (Entry != Head)
{
CurrentEntry = (PFONT_ENTRY) CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
- if (NULL == (FontGDI = AccessInternalObject((ULONG) CurrentEntry->hFont)))
- {
- Entry = Entry->Flink;
- continue;
- }
+
+ FontGDI = CurrentEntry->Font;
+ ASSERT(FontGDI);
+
Score = GetFontScore(LogFont, FaceName, FontGDI);
if (*MatchScore == 0 || *MatchScore < Score)
{
- *Font = CurrentEntry->hFont;
+ *FontObj = GDIToObj(FontGDI, FONT);
*MatchScore = Score;
}
Entry = Entry->Flink;
}
}
-static BOOLEAN FASTCALL
+static inline BOOLEAN
SubstituteFontFamilyKey(PUNICODE_STRING FaceName,
LPCWSTR Key)
{
@@ -2911,7 +2855,7 @@
return NT_SUCCESS(Status);
}
-static void FASTCALL
+static inline void
SubstituteFontFamily(PUNICODE_STRING FaceName, UINT Level)
{
if (10 < Level) /* Enough is enough */
@@ -2948,34 +2892,38 @@
}
SubstituteFontFamily(&FaceName, 0);
MatchScore = 0;
- TextObj->GDIFontHandle = NULL;
+ TextObj->Font = NULL;
/* First search private fonts */
Win32Process = PsGetWin32Process();
IntLockProcessPrivateFonts(Win32Process);
- FindBestFontFromList(&TextObj->GDIFontHandle, &MatchScore,
+ FindBestFontFromList(&TextObj->Font, &MatchScore,
&TextObj->logfont, &FaceName,
&Win32Process->PrivateFontListHead);
IntUnLockProcessPrivateFonts(Win32Process);
/* Search system fonts */
IntLockGlobalFonts;
- FindBestFontFromList(&TextObj->GDIFontHandle, &MatchScore,
+ FindBestFontFromList(&TextObj->Font, &MatchScore,
&TextObj->logfont, &FaceName,
&FontListHead);
IntUnLockGlobalFonts;
- if (NULL == TextObj->GDIFontHandle)
+ if (NULL == TextObj->Font)
{
DPRINT1("Requested font %S not found, no fonts loaded at all\n",
TextObj->logfont.lfFaceName);
Status = STATUS_NOT_FOUND;
}
+ else
+ {
+ Status = STATUS_SUCCESS;
+ }
RtlFreeUnicodeString(&FaceName);
TEXTOBJ_UnlockText(FontHandle);
- ASSERT((NT_SUCCESS(Status) ^ (NULL == TextObj->GDIFontHandle)) != 0);
+ ASSERT((NT_SUCCESS(Status) ^ (NULL == TextObj->Font)) != 0);
return Status;
}
reactos/subsys/win32k/objects
diff -N cursoricon.c
--- cursoricon.c 21 Nov 2004 21:23:24 -0000 1.66
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,1201 +0,0 @@
-/*
- * 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.
- */
-/* $Id: cursoricon.c,v 1.66 2004/11/21 21:23:24 weiden Exp $ */
-#include <w32k.h>
-
-PCURICON_OBJECT FASTCALL
-IntGetCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle)
-{
- PCURICON_OBJECT Object;
- NTSTATUS Status;
-
- Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable,
- Handle, otCursorIcon, (PVOID*)&Object);
- if (!NT_SUCCESS(Status))
- {
- return NULL;
- }
- return Object;
-}
-
-#define COLORCURSORS_ALLOWED FALSE
-HCURSOR FASTCALL
-IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
- BOOL ForceChange)
-{
- BITMAPOBJ *BitmapObj;
- SURFOBJ *SurfObj;
- PDEVINFO DevInfo;
- PBITMAPOBJ MaskBmpObj = NULL;
- PSYSTEM_CURSORINFO CurInfo;
- PCURICON_OBJECT OldCursor;
- HCURSOR Ret = (HCURSOR)0;
- HBITMAP hColor = (HBITMAP)0;
- HBITMAP hMask = 0;
- SURFOBJ *soMask = NULL, *soColor = NULL;
- XLATEOBJ *XlateObj = NULL;
- RECTL PointerRect;
- HDC Screen;
-
- CurInfo = IntGetSysCursorInfo(WinStaObject);
- OldCursor = CurInfo->CurrentCursorObject;
- if (OldCursor)
- {
- Ret = (HCURSOR)OldCursor->Self;
- }
-
- if (!ForceChange && OldCursor == NewCursor)
- {
- return Ret;
- }
-
- {
- if(!(Screen = IntGetScreenDC()))
- {
- return (HCURSOR)0;
- }
- /* FIXME use the desktop's HDC instead of using ScreenDeviceContext */
- PDC dc = DC_LockDc(Screen);
-
- if (!dc)
- {
- return Ret;
- }
-
- BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
- SurfObj = &BitmapObj->SurfObj;
- DevInfo = dc->DevInfo;
- DC_UnlockDc(Screen);
- }
-
- if (!NewCursor && (CurInfo->CurrentCursorObject || ForceChange))
- {
- if (NULL != CurInfo->CurrentCursorObject && CurInfo->ShowingCursor)
- {
- /* Remove the cursor if it was displayed */
- if (GDIDEV(SurfObj)->MovePointer)
- GDIDEV(SurfObj)->MovePointer(SurfObj, -1, -1, &PointerRect);
- SetPointerRect(CurInfo, &PointerRect);
- }
-
- GDIDEV(SurfObj)->PointerStatus = SPS_ACCEPT_NOEXCLUDE;
-
- CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
- CurInfo->ShowingCursor = 0;
- BITMAPOBJ_UnlockBitmap(SurfObj->hsurf);
- return Ret;
- }
-
- if (!NewCursor)
- {
- BITMAPOBJ_UnlockBitmap(SurfObj->hsurf);
- return Ret;
- }
-
- /* TODO: Fixme. Logic is screwed above */
-
- ASSERT(NewCursor);
- MaskBmpObj = BITMAPOBJ_LockBitmap(NewCursor->IconInfo.hbmMask);
- if (MaskBmpObj)
- {
- const int maskBpp = BitsPerFormat(MaskBmpObj->SurfObj.iBitmapFormat);
- BITMAPOBJ_UnlockBitmap(NewCursor->IconInfo.hbmMask);
- if (maskBpp != 1)
- {
- DPRINT1("SetCursor: The Mask bitmap must have 1BPP!\n");
- BITMAPOBJ_UnlockBitmap(SurfObj->hsurf);
- return Ret;
- }
-
- if ((DevInfo->flGraphicsCaps2 & GCAPS2_ALPHACURSOR) &&
- SurfObj->iBitmapFormat >= BMF_16BPP &&
- SurfObj->iBitmapFormat <= BMF_32BPP &&
- NewCursor->Shadow && COLORCURSORS_ALLOWED)
- {
- /* FIXME - Create a color pointer, only 32bit bitmap, set alpha bits!
- Do not pass a mask bitmap to DrvSetPointerShape()!
- Create a XLATEOBJ that describes the colors of the bitmap. */
- DPRINT1("SetCursor: (Colored) alpha cursors are not supported!\n");
- }
- else
- {
- if(NewCursor->IconInfo.hbmColor
- && COLORCURSORS_ALLOWED)
- {
- /* FIXME - Create a color pointer, create only one 32bit bitmap!
- Do not pass a mask bitmap to DrvSetPointerShape()!
- Create a XLATEOBJ that describes the colors of the bitmap.
- (16bit bitmaps are propably allowed) */
- DPRINT1("SetCursor: Cursors with colors are not supported!\n");
- }
- else
- {
- MaskBmpObj = BITMAPOBJ_LockBitmap(NewCursor->IconInfo.hbmMask);
- if(MaskBmpObj)
- {
- RECTL DestRect = {0, 0, MaskBmpObj->SurfObj.sizlBitmap.cx, MaskBmpObj->SurfObj.sizlBitmap.cy};
- POINTL SourcePoint = {0, 0};
-
- /*
- * NOTE: For now we create the cursor in top-down bitmap,
- * because VMware driver rejects it otherwise. This should
- * be fixed later.
- */
- hMask = EngCreateBitmap(
- MaskBmpObj->SurfObj.sizlBitmap, abs(MaskBmpObj->SurfObj.lDelta),
- MaskBmpObj->SurfObj.iBitmapFormat, BMF_TOPDOWN,
- NULL);
- ASSERT(hMask);
- soMask = EngLockSurface((HSURF)hMask);
- EngCopyBits(soMask, &MaskBmpObj->SurfObj, NULL, NULL,
- &DestRect, &SourcePoint);
- BITMAPOBJ_UnlockBitmap(NewCursor->IconInfo.hbmMask);
- }
- }
- }
- CurInfo->ShowingCursor = CURSOR_SHOWING;
- CurInfo->CurrentCursorObject = NewCursor;
- }
- else
- {
- CurInfo->ShowingCursor = 0;
- CurInfo->CurrentCursorObject = NULL;
- }
-
- if (GDIDEVFUNCS(SurfObj).SetPointerShape)
- {
- GDIDEV(SurfObj)->PointerStatus =
- GDIDEVFUNCS(SurfObj).SetPointerShape(
- SurfObj, soMask, soColor, XlateObj,
- NewCursor->IconInfo.xHotspot,
- NewCursor->IconInfo.yHotspot,
- CurInfo->x,
- CurInfo->y,
- &PointerRect,
- SPS_CHANGE);
- DPRINT("SetCursor: DrvSetPointerShape() returned %x\n",
- GDIDEV(SurfObj)->PointerStatus);
- }
- else
- {
- GDIDEV(SurfObj)->PointerStatus = SPS_DECLINE;
- }
-
- if(GDIDEV(SurfObj)->PointerStatus == SPS_DECLINE)
- {
- GDIDEV(SurfObj)->PointerStatus = EngSetPointerShape(
- SurfObj, soMask, soColor, XlateObj,
- NewCursor->IconInfo.xHotspot,
- NewCursor->IconInfo.yHotspot,
- CurInfo->x,
- CurInfo->y,
- &PointerRect,
- SPS_CHANGE);
- GDIDEV(SurfObj)->MovePointer = EngMovePointer;
- }
- else
- {
- GDIDEV(SurfObj)->MovePointer = GDIDEVFUNCS(SurfObj).MovePointer;
- }
-
- SetPointerRect(CurInfo, &PointerRect);
-
- BITMAPOBJ_UnlockBitmap(SurfObj->hsurf);
- if(hMask)
- {
- EngUnlockSurface(soMask);
- EngDeleteSurface((HSURF)hMask);
- }
- if(hColor)
- {
- EngDeleteSurface((HSURF)hColor);
- }
- if(XlateObj)
- {
- EngDeleteXlate(XlateObj);
- }
-
- if(GDIDEV(SurfObj)->PointerStatus == SPS_ERROR)
- DPRINT1("SetCursor: DrvSetPointerShape() returned SPS_ERROR\n");
-
- return Ret;
-}
-
-BOOL FASTCALL
-IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject)
-{
- return TRUE;
-}
-
-PCURICON_OBJECT FASTCALL
-IntFindExistingCurIconObject(PWINSTATION_OBJECT WinStaObject, HMODULE hModule,
- HRSRC hRsrc, LONG cx, LONG cy)
-{
- PUSER_HANDLE_TABLE HandleTable;
- PLIST_ENTRY CurrentEntry;
- PUSER_HANDLE_BLOCK Current;
- PCURICON_OBJECT Object;
- ULONG i;
-
- HandleTable = (PUSER_HANDLE_TABLE)WinStaObject->HandleTable;
- ObmpLockHandleTable(HandleTable);
-
- CurrentEntry = HandleTable->ListHead.Flink;
- while(CurrentEntry != &HandleTable->ListHead)
- {
- Current = CONTAINING_RECORD(CurrentEntry, USER_HANDLE_BLOCK, ListEntry);
- for(i = 0; i < HANDLE_BLOCK_ENTRIES; i++)
- {
- Object = (PCURICON_OBJECT)Current->Handles[i].ObjectBody;
- if(Object && (ObmReferenceObjectByPointer(Object, otCursorIcon) == STATUS_SUCCESS))
- {
- if((Object->hModule == hModule) && (Object->hRsrc == hRsrc))
- {
- if(cx && ((cx != Object->Size.cx) || (cy != Object->Size.cy)))
- {
- ObmDereferenceObject(Object);
- continue;
- }
- ObmpUnlockHandleTable(HandleTable);
- return Object;
- }
- ObmDereferenceObject(Object);
- }
- }
- CurrentEntry = CurrentEntry->Flink;
- }
-
- ObmpUnlockHandleTable(HandleTable);
- return NULL;
-}
-
-PCURICON_OBJECT FASTCALL
-IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject)
-{
- PCURICON_OBJECT Object;
- HANDLE Handle;
- PW32PROCESS Win32Process;
-
- Object = ObmCreateObject(WinStaObject->HandleTable, &Handle, otCursorIcon, sizeof(CURICON_OBJECT));
-
- if(!Object)
- {
- SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
-
- Win32Process = PsGetWin32Process();
-
- IntLockProcessCursorIcons(Win32Process);
- InsertTailList(&Win32Process->CursorIconListHead, &Object->ListEntry);
- IntUnLockProcessCursorIcons(Win32Process);
-
- Object->Self = Handle;
- Object->Process = PsGetWin32Process();
-
- return Object;
-}
-
-BOOL FASTCALL
-IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, HANDLE Handle, BOOL RemoveFromProcess)
-{
- PSYSTEM_CURSORINFO CurInfo;
- PCURICON_OBJECT Object;
- HBITMAP bmpMask, bmpColor;
- NTSTATUS Status;
- BOOL Ret;
-
- Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, Handle, otCursorIcon, (PVOID*)&Object);
- if(!NT_SUCCESS(Status))
- {
- return FALSE;
- }
-
- if (Object->Process != PsGetWin32Process())
- {
- ObmDereferenceObject(Object);
- return FALSE;
- }
-
- CurInfo = IntGetSysCursorInfo(WinStaObject);
-
- if (CurInfo->CurrentCursorObject == Object)
- {
- /* Hide the cursor if we're destroying the current cursor */
- IntSetCursor(WinStaObject, NULL, TRUE);
- }
-
- bmpMask = Object->IconInfo.hbmMask;
- bmpColor = Object->IconInfo.hbmColor;
-
- if (Object->Process && RemoveFromProcess)
- {
- IntLockProcessCursorIcons(Object->Process);
- RemoveEntryList(&Object->ListEntry);
- IntUnLockProcessCursorIcons(Object->Process);
- }
-
- Ret = NT_SUCCESS(ObmCloseHandle(WinStaObject->HandleTable, Handle));
-
- /* delete bitmaps */
- if(bmpMask)
- NtGdiDeleteObject(bmpMask);
- if(bmpColor)
- NtGdiDeleteObject(bmpColor);
-
- ObmDereferenceObject(Object);
-
- return Ret;
-}
-
-VOID FASTCALL
-IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process)
-{
- PWINSTATION_OBJECT WinStaObject;
- PCURICON_OBJECT Current;
- PLIST_ENTRY CurrentEntry, NextEntry;
-
- WinStaObject = IntGetWinStaObj();
- if(WinStaObject != NULL)
- {
- CurrentEntry = Win32Process->CursorIconListHead.Flink;
- while(CurrentEntry != &Win32Process->CursorIconListHead)
- {
- NextEntry = CurrentEntry->Flink;
- Current = CONTAINING_RECORD(CurrentEntry, CURICON_OBJECT, ListEntry);
- RemoveEntryList(&Current->ListEntry);
- IntDestroyCurIconObject(WinStaObject, Current->Self, FALSE);
- CurrentEntry = NextEntry;
- }
- ObDereferenceObject(WinStaObject);
- }
-}
-
-/*
- * @implemented
- */
-HANDLE
-STDCALL
-NtUserCreateCursorIconHandle(PICONINFO IconInfo, BOOL Indirect)
-{
- PCURICON_OBJECT CurIconObject;
- PWINSTATION_OBJECT WinStaObject;
- PBITMAPOBJ bmp;
- NTSTATUS Status;
- HANDLE Ret;
-
- WinStaObject = IntGetWinStaObj();
- if(WinStaObject == NULL)
- {
- return (HANDLE)0;
- }
-
- CurIconObject = IntCreateCurIconHandle(WinStaObject);
- if(CurIconObject)
- {
- Ret = CurIconObject->Self;
-
- if(IconInfo)
- {
- Status = MmCopyFromCaller(&CurIconObject->IconInfo, IconInfo, sizeof(ICONINFO));
- if(NT_SUCCESS(Status))
- {
- if(Indirect)
- {
- CurIconObject->IconInfo.hbmMask = BITMAPOBJ_CopyBitmap(CurIconObject->IconInfo.hbmMask);
- CurIconObject->IconInfo.hbmColor = BITMAPOBJ_CopyBitmap(CurIconObject->IconInfo.hbmColor);
- }
- if(CurIconObject->IconInfo.hbmColor &&
- (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor)))
- {
- CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
- CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy;
- BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmColor);
- }
- else
- {
- if(CurIconObject->IconInfo.hbmMask &&
- (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask)))
- {
- CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
- CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
- BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmMask);
- }
- }
- }
- else
- {
- SetLastNtError(Status);
- /* FIXME - Don't exit here */
- }
- }
-
- ObDereferenceObject(WinStaObject);
- return Ret;
- }
-
- SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
- ObDereferenceObject(WinStaObject);
- return (HANDLE)0;
-}
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserGetCursorIconInfo(
- HANDLE Handle,
- PICONINFO IconInfo)
-{
- ICONINFO ii;
- PCURICON_OBJECT CurIconObject;
- PWINSTATION_OBJECT WinStaObject;
- NTSTATUS Status;
- BOOL Ret = FALSE;
-
- WinStaObject = IntGetWinStaObj();
- if(WinStaObject == NULL)
- {
- return FALSE;
- }
-
- CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
- if(CurIconObject)
- {
- if(IconInfo)
- {
- RtlCopyMemory(&ii, &CurIconObject->IconInfo, sizeof(ICONINFO));
-
- /* Copy bitmaps */
- ii.hbmMask = BITMAPOBJ_CopyBitmap(ii.hbmMask);
- ii.hbmColor = BITMAPOBJ_CopyBitmap(ii.hbmColor);
-
- /* Copy fields */
- Status = MmCopyToCaller(IconInfo, &ii, sizeof(ICONINFO));
- if(NT_SUCCESS(Status))
- Ret = TRUE;
- else
- SetLastNtError(Status);
- }
- else
- {
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
- }
-
- IntReleaseCurIconObject(CurIconObject);
- ObDereferenceObject(WinStaObject);
- return Ret;
- }
-
- SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
- ObDereferenceObject(WinStaObject);
- return FALSE;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserGetCursorIconSize(
- HANDLE Handle,
- BOOL *fIcon,
- SIZE *Size)
-{
- PCURICON_OBJECT CurIconObject;
- PBITMAPOBJ bmp;
- PWINSTATION_OBJECT WinStaObject;
- NTSTATUS Status;
- BOOL Ret = FALSE;
- SIZE SafeSize;
-
- WinStaObject = IntGetWinStaObj();
- if(WinStaObject == NULL)
- {
- return FALSE;
- }
-
- CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
- if(CurIconObject)
- {
- /* Copy fields */
- Status = MmCopyToCaller(fIcon, &CurIconObject->IconInfo.fIcon, sizeof(BOOL));
- if(!NT_SUCCESS(Status))
- {
- SetLastNtError(Status);
- goto done;
- }
-
- bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor);
- if(!bmp)
- goto done;
-
- SafeSize.cx = bmp->SurfObj.sizlBitmap.cx;
- SafeSize.cy = bmp->SurfObj.sizlBitmap.cy;
- Status = MmCopyToCaller(Size, &SafeSize, sizeof(SIZE));
- if(NT_SUCCESS(Status))
- Ret = TRUE;
- else
- SetLastNtError(Status);
-
- BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmColor);
-
- done:
- IntReleaseCurIconObject(CurIconObject);
- ObDereferenceObject(WinStaObject);
- return Ret;
- }
-
- SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
- ObDereferenceObject(WinStaObject);
- return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-DWORD
-STDCALL
-NtUserGetCursorFrameInfo(
- DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2,
- DWORD Unknown3)
-{
- UNIMPLEMENTED
-
- return 0;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserGetCursorInfo(
- PCURSORINFO pci)
-{
- CURSORINFO SafeCi;
- PSYSTEM_CURSORINFO CurInfo;
- PWINSTATION_OBJECT WinStaObject;
- NTSTATUS Status;
- PCURICON_OBJECT CursorObject;
-
- Status = MmCopyFromCaller(&SafeCi.cbSize, pci, sizeof(DWORD));
- if(!NT_SUCCESS(Status))
- {
- SetLastNtError(Status);
- return FALSE;
- }
-
- if(SafeCi.cbSize != sizeof(CURSORINFO))
- {
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- WinStaObject = IntGetWinStaObj();
- if(WinStaObject == NULL)
- {
- return FALSE;
- }
-
- CurInfo = IntGetSysCursorInfo(WinStaObject);
- CursorObject = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
-
- SafeCi.flags = ((CurInfo->ShowingCursor && CursorObject) ? CURSOR_SHOWING : 0);
- SafeCi.hCursor = (CursorObject ? (HCURSOR)CursorObject->Self : (HCURSOR)0);
- SafeCi.ptScreenPos.x = CurInfo->x;
- SafeCi.ptScreenPos.y = CurInfo->y;
-
- Status = MmCopyToCaller(pci, &SafeCi, sizeof(CURSORINFO));
- if(!NT_SUCCESS(Status))
- {
- ObDereferenceObject(WinStaObject);
- SetLastNtError(Status);
- return FALSE;
- }
-
- ObDereferenceObject(WinStaObject);
- return TRUE;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserClipCursor(
- RECT *UnsafeRect)
-{
- /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
-
- PWINSTATION_OBJECT WinStaObject;
- PSYSTEM_CURSORINFO CurInfo;
- RECT Rect;
- PWINDOW_OBJECT DesktopWindow = NULL;
-
- WinStaObject = IntGetWinStaObj();
- if (WinStaObject == NULL)
- {
- return FALSE;
- }
-
- if (NULL != UnsafeRect && ! NT_SUCCESS(MmCopyFromCaller(&Rect, UnsafeRect, sizeof(RECT))))
- {
- ObDereferenceObject(WinStaObject);
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- CurInfo = IntGetSysCursorInfo(WinStaObject);
- if(WinStaObject->ActiveDesktop)
- DesktopWindow = IntGetWindowObject(WinStaObject->ActiveDesktop->DesktopWindow);
-
- if((Rect.right > Rect.left) && (Rect.bottom > Rect.top)
- && DesktopWindow && UnsafeRect != NULL)
- {
- MOUSEINPUT mi;
-
- CurInfo->CursorClipInfo.IsClipped = TRUE;
- CurInfo->CursorClipInfo.Left = max(Rect.left, DesktopWindow->WindowRect.left);
- CurInfo->CursorClipInfo.Top = max(Rect.top, DesktopWindow->WindowRect.top);
- CurInfo->CursorClipInfo.Right = min(Rect.right - 1, DesktopWindow->WindowRect.right - 1);
- CurInfo->CursorClipInfo.Bottom = min(Rect.bottom - 1, DesktopWindow->WindowRect.bottom - 1);
- IntReleaseWindowObject(DesktopWindow);
-
- mi.dx = CurInfo->x;
- mi.dy = CurInfo->y;
- mi.mouseData = 0;
- mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
- mi.time = 0;
- mi.dwExtraInfo = 0;
- IntMouseInput(&mi);
-
- return TRUE;
- }
-
- CurInfo->CursorClipInfo.IsClipped = FALSE;
- ObDereferenceObject(WinStaObject);
-
- return TRUE;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserDestroyCursorIcon(
- HANDLE Handle,
- DWORD Unknown)
-{
- PWINSTATION_OBJECT WinStaObject;
-
- WinStaObject = IntGetWinStaObj();
- if(WinStaObject == NULL)
- {
- return FALSE;
- }
-
- if(IntDestroyCurIconObject(WinStaObject, Handle, TRUE))
- {
- ObDereferenceObject(WinStaObject);
- return TRUE;
- }
-
- SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
- ObDereferenceObject(WinStaObject);
- return FALSE;
-}
-
-
-/*
- * @implemented
- */
-HICON
-STDCALL
-NtUserFindExistingCursorIcon(
- HMODULE hModule,
- HRSRC hRsrc,
- LONG cx,
- LONG cy)
-{
- PCURICON_OBJECT CurIconObject;
- PWINSTATION_OBJECT WinStaObject;
- HANDLE Ret = (HANDLE)0;
-
- WinStaObject = IntGetWinStaObj();
- if(WinStaObject == NULL)
- {
- return Ret;
- }
-
- CurIconObject = IntFindExistingCurIconObject(WinStaObject, hModule, hRsrc, cx, cy);
- if(CurIconObject)
- {
- Ret = CurIconObject->Self;
-
- IntReleaseCurIconObject(CurIconObject);
- ObDereferenceObject(WinStaObject);
- return Ret;
- }
-
- SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
- ObDereferenceObject(WinStaObject);
- return (HANDLE)0;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserGetClipCursor(
- RECT *lpRect)
-{
- /* FIXME - check if process has WINSTA_READATTRIBUTES */
- PSYSTEM_CURSORINFO CurInfo;
- PWINSTATION_OBJECT WinStaObject;
- RECT Rect;
- NTSTATUS Status;
-
- if(!lpRect)
- return FALSE;
-
- WinStaObject = IntGetWinStaObj();
- if (WinStaObject == NULL)
- {
- DPRINT("Validation of window station handle (0x%X) failed\n",
- PROCESS_WINDOW_STATION());
- return FALSE;
- }
-
- CurInfo = IntGetSysCursorInfo(WinStaObject);
- if(CurInfo->CursorClipInfo.IsClipped)
- {
- Rect.left = CurInfo->CursorClipInfo.Left;
- Rect.top = CurInfo->CursorClipInfo.Top;
- Rect.right = CurInfo->CursorClipInfo.Right;
- Rect.bottom = CurInfo->CursorClipInfo.Bottom;
- }
- else
- {
- Rect.left = 0;
- Rect.top = 0;
- Rect.right = NtUserGetSystemMetrics(SM_CXSCREEN);
- Rect.bottom = NtUserGetSystemMetrics(SM_CYSCREEN);
- }
-
- Status = MmCopyToCaller((PRECT)lpRect, &Rect, sizeof(RECT));
- if(!NT_SUCCESS(Status))
- {
- ObDereferenceObject(WinStaObject);
- SetLastNtError(Status);
- return FALSE;
- }
-
- ObDereferenceObject(WinStaObject);
-
- return TRUE;
-}
-
-
-/*
- * @implemented
- */
-HCURSOR
-STDCALL
-NtUserSetCursor(
- HCURSOR hCursor)
-{
- PCURICON_OBJECT CurIconObject;
- HICON OldCursor = (HCURSOR)0;
- PWINSTATION_OBJECT WinStaObject;
-
- WinStaObject = IntGetWinStaObj();
- if(WinStaObject == NULL)
- {
- return (HCURSOR)0;
- }
-
- CurIconObject = IntGetCurIconObject(WinStaObject, hCursor);
- if(CurIconObject)
- {
- OldCursor = IntSetCursor(WinStaObject, CurIconObject, FALSE);
- IntReleaseCurIconObject(CurIconObject);
- }
- else
- SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-
- ObDereferenceObject(WinStaObject);
- return OldCursor;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserSetCursorIconContents(
- HANDLE Handle,
- PICONINFO IconInfo)
-{
- PCURICON_OBJECT CurIconObject;
- PBITMAPOBJ bmp;
- PWINSTATION_OBJECT WinStaObject;
- NTSTATUS Status;
- BOOL Ret = FALSE;
-
- WinStaObject = IntGetWinStaObj();
- if(WinStaObject == NULL)
- {
- return FALSE;
- }
-
- CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
- if(CurIconObject)
- {
- /* Copy fields */
- Status = MmCopyFromCaller(&CurIconObject->IconInfo, IconInfo, sizeof(ICONINFO));
- if(!NT_SUCCESS(Status))
- {
- SetLastNtError(Status);
- goto done;
- }
-
- bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor);
- if(bmp)
- {
- CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
- CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy;
- BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmColor);
- }
- else
- {
- bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask);
- if(!bmp)
- goto done;
-
- CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
- CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
-
- BITMAPOBJ_UnlockBitmap(CurIconObject->IconInfo.hbmMask);
- }
-
- Ret = TRUE;
-
- done:
- IntReleaseCurIconObject(CurIconObject);
- ObDereferenceObject(WinStaObject);
- return Ret;
- }
-
- SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
- ObDereferenceObject(WinStaObject);
- return FALSE;
-}
-
-
-/*
- * @implemented
- */
-BOOL
-STDCALL
-NtUserSetCursorIconData(
- HANDLE Handle,
- PBOOL fIcon,
- POINT *Hotspot,
- HMODULE hModule,
- HRSRC hRsrc,
- HRSRC hGroupRsrc)
-{
- PCURICON_OBJECT CurIconObject;
- PWINSTATION_OBJECT WinStaObject;
- NTSTATUS Status;
- POINT SafeHotspot;
- BOOL Ret = FALSE;
-
- WinStaObject = IntGetWinStaObj();
- if(WinStaObject == NULL)
- {
- return FALSE;
- }
-
- CurIconObject = IntGetCurIconObject(WinStaObject, Handle);
- if(CurIconObject)
- {
- CurIconObject->hModule = hModule;
- CurIconObject->hRsrc = hRsrc;
- CurIconObject->hGroupRsrc = hGroupRsrc;
-
- /* Copy fields */
- if(fIcon)
- {
- Status = MmCopyFromCaller(&CurIconObject->IconInfo.fIcon, fIcon, sizeof(BOOL));
- if(!NT_SUCCESS(Status))
- {
- SetLastNtError(Status);
- goto done;
- }
- }
- else
- {
- if(!Hotspot)
- Ret = TRUE;
- }
-
- if(Hotspot)
- {
- Status = MmCopyFromCaller(&SafeHotspot, Hotspot, sizeof(POINT));
- if(NT_SUCCESS(Status))
- {
- CurIconObject->IconInfo.xHotspot = SafeHotspot.x;
- CurIconObject->IconInfo.yHotspot = SafeHotspot.y;
-
- Ret = TRUE;
- }
- else
- SetLastNtError(Status);
- }
-
- if(!fIcon && !Hotspot)
- {
- Ret = TRUE;
- }
-
- done:
- IntReleaseCurIconObject(CurIconObject);
- ObDereferenceObject(WinStaObject);
- return Ret;
- }
-
[truncated at 1000 lines; 205 more skipped]
reactos/subsys/win32k/stubs
diff -u -r1.30 -r1.31
--- stubs.c 11 Apr 2004 09:09:38 -0000 1.30
+++ stubs.c 12 Dec 2004 01:40:39 -0000 1.31
@@ -2,15 +2,7 @@
* Stubs for unimplemented WIN32K.SYS exports
*/
-#undef WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <stdlib.h>
-#include <win32k/bitmaps.h>
-#include <win32k/debug.h>
-#include <debug.h>
-#include <ddk/winddi.h>
-#include "../eng/objects.h"
-#include <include/error.h>
+#include <w32k.h>
#define STUB(x) void x(void) { DbgPrint("WIN32K: Stub for %s\n", #x); }
reactos/subsys/win32k/stubs
diff -u -r1.5 -r1.6
--- xpstubs.c 8 Mar 2004 07:04:57 -0000 1.5
+++ xpstubs.c 12 Dec 2004 01:40:39 -0000 1.6
@@ -3,15 +3,7 @@
* in Windows XP and beyond ( i.e. a low priority for us right now )
*/
-#undef WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <stdlib.h>
-#include <win32k/bitmaps.h>
-#include <win32k/debug.h>
-#include <debug.h>
-#include <ddk/winddi.h>
-#include "../eng/objects.h"
-#include <include/error.h>
+#include <w32k.h>
#define STUB(x) void x(void) { DbgPrint("WIN32K: Stub for %s\n", #x); }
CVSspam 0.2.8