From 9ac102fb1720823051acf25c00592aabdb51e4cf Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 4 Jul 2004 01:23:32 +0000 Subject: [PATCH] - Support resursive locking of the GDI objects. - Call EngMovePointer instead of DrvMovePointer if driver DrvSetPointerShape returned SPS_DECLINE. svn path=/trunk/; revision=9989 --- reactos/include/win32k/dc.h | 2 + reactos/include/win32k/gdiobj.h | 4 +- reactos/subsys/win32k/ntuser/input.c | 11 ++--- reactos/subsys/win32k/objects/cursoricon.c | 18 ++++--- reactos/subsys/win32k/objects/gdiobj.c | 55 +++++++++++++++++++++- 5 files changed, 73 insertions(+), 17 deletions(-) diff --git a/reactos/include/win32k/dc.h b/reactos/include/win32k/dc.h index 4f877f0bfd9..dc7cf9e0cae 100644 --- a/reactos/include/win32k/dc.h +++ b/reactos/include/win32k/dc.h @@ -116,6 +116,8 @@ typedef struct DRIVER_FUNCTIONS DriverFunctions; PFILE_OBJECT VideoFileObject; + PGD_MOVEPOINTER MovePointer; + struct { BOOL Enable; LONG Column; diff --git a/reactos/include/win32k/gdiobj.h b/reactos/include/win32k/gdiobj.h index fd2ac756d9a..801b50eb021 100644 --- a/reactos/include/win32k/gdiobj.h +++ b/reactos/include/win32k/gdiobj.h @@ -49,7 +49,9 @@ typedef struct _GDIOBJHDR WORD Magic; const char* lockfile; int lockline; - FAST_MUTEX Lock; +/* FAST_MUTEX Lock;*/ + DWORD LockTid; + DWORD LockCount; } GDIOBJHDR, *PGDIOBJHDR; typedef struct _GDIMULTILOCK diff --git a/reactos/subsys/win32k/ntuser/input.c b/reactos/subsys/win32k/ntuser/input.c index e86347993d6..8d8506f2600 100644 --- a/reactos/subsys/win32k/ntuser/input.c +++ b/reactos/subsys/win32k/ntuser/input.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: input.c,v 1.35 2004/07/03 13:55:36 navaraf Exp $ +/* $Id: input.c,v 1.36 2004/07/04 01:23:32 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -640,14 +640,9 @@ IntMouseInput(MOUSEINPUT *mi) { SurfObj = &BitmapObj->SurfObj; - if(GDIDEVFUNCS(SurfObj).MovePointer) + if (GDIDEV(SurfObj)->MovePointer) { - GDIDEVFUNCS(SurfObj).MovePointer( - SurfObj, MousePos.x, MousePos.y, &PointerRect); - } - else - { - EngMovePointer(SurfObj, MousePos.x, MousePos.y, &PointerRect); + GDIDEV(SurfObj)->MovePointer(SurfObj, MousePos.x, MousePos.y, &PointerRect); } BITMAPOBJ_UnlockBitmap(hBitmap); diff --git a/reactos/subsys/win32k/objects/cursoricon.c b/reactos/subsys/win32k/objects/cursoricon.c index 0e951e5f0e1..3acd970ed80 100644 --- a/reactos/subsys/win32k/objects/cursoricon.c +++ b/reactos/subsys/win32k/objects/cursoricon.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: cursoricon.c,v 1.59 2004/07/03 17:40:27 navaraf Exp $ */ +/* $Id: cursoricon.c,v 1.60 2004/07/04 01:23:32 navaraf Exp $ */ #include PCURICON_OBJECT FASTCALL @@ -88,10 +88,8 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, if (NULL != CurInfo->CurrentCursorObject && CurInfo->ShowingCursor) { /* Remove the cursor if it was displayed */ - if (GDIDEVFUNCS(SurfObj).MovePointer) - GDIDEVFUNCS(SurfObj).MovePointer(SurfObj, -1, -1, &PointerRect); - else - EngMovePointer(SurfObj, -1, -1, &PointerRect); + if (GDIDEV(SurfObj)->MovePointer) + GDIDEV(SurfObj)->MovePointer(SurfObj, -1, -1, &PointerRect); SetPointerRect(CurInfo, &PointerRect); } @@ -174,13 +172,15 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, CurInfo->y, &PointerRect, SPS_CHANGE); + DbgPrint("SetCursor: DrvSetPointerShape() returned %x\n", + GDIDEV(SurfObj)->PointerStatus); } else { GDIDEV(SurfObj)->PointerStatus = SPS_DECLINE; } - if(((GDIDEVICE *)SurfObj->hdev)->PointerStatus == SPS_DECLINE) + if(GDIDEV(SurfObj)->PointerStatus == SPS_DECLINE) { GDIDEV(SurfObj)->PointerStatus = EngSetPointerShape( SurfObj, soMask, soColor, XlateObj, @@ -190,7 +190,11 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, CurInfo->y, &PointerRect, SPS_CHANGE); - DbgPrint("SetCursor: DrvSetPointerShape() returned SPS_DECLINE\n"); + GDIDEV(SurfObj)->MovePointer = EngMovePointer; + } + else + { + GDIDEV(SurfObj)->MovePointer = GDIDEVFUNCS(SurfObj).MovePointer; } SetPointerRect(CurInfo, &PointerRect); diff --git a/reactos/subsys/win32k/objects/gdiobj.c b/reactos/subsys/win32k/objects/gdiobj.c index 0627c3ecbbb..a26e967ddec 100644 --- a/reactos/subsys/win32k/objects/gdiobj.c +++ b/reactos/subsys/win32k/objects/gdiobj.c @@ -19,7 +19,7 @@ /* * GDIOBJ.C - GDI object manipulation routines * - * $Id: gdiobj.c,v 1.69 2004/07/03 13:55:36 navaraf Exp $ + * $Id: gdiobj.c,v 1.70 2004/07/04 01:23:32 navaraf Exp $ * */ #include @@ -178,6 +178,7 @@ static HGDIOBJ StockObjects[NB_STOCK_OBJECTS]; static PGDI_HANDLE_TABLE HandleTable = 0; static FAST_MUTEX HandleTableMutex; static FAST_MUTEX RefCountHandling; +static LARGE_INTEGER ShortDelay; /*! * Allocate GDI object table. @@ -344,7 +345,12 @@ GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProc) newObject->Magic = GDI_TYPE_TO_MAGIC(ObjectType); newObject->lockfile = NULL; newObject->lockline = 0; +#if 0 ExInitializeFastMutex(&newObject->Lock); +#else + newObject->LockTid = 0; + newObject->LockCount = 0; +#endif HandleTable->Handles[Index] = newObject; #if GDI_COUNT_OBJECTS HandleTable->HandlesCount++; @@ -550,6 +556,8 @@ InitGdiObjectHandleTable (VOID) ExInitializeFastMutex (&HandleTableMutex); ExInitializeFastMutex (&RefCountHandling); + ShortDelay.QuadPart = -100; + HandleTable = GDIOBJ_iAllocHandleTable (GDI_HANDLE_COUNT); DPRINT("HandleTable: %x\n", HandleTable ); @@ -704,6 +712,7 @@ GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType) return NULL; } +#if 0 #ifdef NDEBUG ExAcquireFastMutex(&ObjHdr->Lock); #else /* NDEBUG */ @@ -719,6 +728,24 @@ GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType) DPRINT1(" Disregard previous message about object 0x%x, it's ok\n", hObj); } #endif /* NDEBUG */ +#else + if (ObjHdr->LockTid == (DWORD)PsGetCurrentThreadId()) + { + InterlockedIncrement(&ObjHdr->LockCount); + } + else + { + for (;;) + { + if (InterlockedCompareExchange(&ObjHdr->LockTid, (DWORD)PsGetCurrentThreadId(), 0)) + { + InterlockedIncrement(&ObjHdr->LockCount); + break; + } + /* FIXME: KeDelayExecutionThread(KernelMode, FALSE, &ShortDelay); */ + } + } +#endif ExAcquireFastMutex(&RefCountHandling); ObjHdr->dwCount++; @@ -780,7 +807,26 @@ GDIOBJ_LockObj(HGDIOBJ hObj, DWORD ObjectType) return NULL; } +#if 0 ExAcquireFastMutex(&ObjHdr->Lock); +#else + if (ObjHdr->LockTid == (DWORD)PsGetCurrentThreadId()) + { + InterlockedIncrement(&ObjHdr->LockCount); + } + else + { + for (;;) + { + if (InterlockedCompareExchange(&ObjHdr->LockTid, (DWORD)PsGetCurrentThreadId(), 0)) + { + InterlockedIncrement(&ObjHdr->LockCount); + break; + } + /* FIXME: KeDelayExecutionThread(KernelMode, FALSE, &ShortDelay); */ + } + } +#endif ExAcquireFastMutex(&RefCountHandling); ObjHdr->dwCount++; @@ -813,7 +859,14 @@ GDIOBJ_UnlockObj(HGDIOBJ hObj, DWORD ObjectType) return FALSE; } +#if 0 ExReleaseFastMutex(&ObjHdr->Lock); +#else + if (InterlockedDecrement(&ObjHdr->LockCount) == 0) + { + InterlockedExchange(&ObjHdr->LockTid, 0); + } +#endif ExAcquireFastMutex(&RefCountHandling); if (0 == (ObjHdr->dwCount & ~0x80000000))