Moved the generic mouse pointer implementation to win32k (not complete yet).

svn path=/trunk/; revision=7865
This commit is contained in:
Filip Navara 2004-01-24 19:47:05 +00:00
parent db0f9b9ba4
commit e25e386086
6 changed files with 389 additions and 147 deletions

View file

@ -26,7 +26,7 @@
#include <ddk/winddi.h> #include <ddk/winddi.h>
#include <ddk/ntddvdeo.h> #include <ddk/ntddvdeo.h>
#define EXPERIMENTAL_MOUSE_CURSOR_SUPPORT //#define EXPERIMENTAL_MOUSE_CURSOR_SUPPORT
typedef struct _PDEV typedef struct _PDEV
{ {
@ -48,12 +48,11 @@ typedef struct _PDEV
#ifdef EXPERIMENTAL_MOUSE_CURSOR_SUPPORT #ifdef EXPERIMENTAL_MOUSE_CURSOR_SUPPORT
VIDEO_POINTER_ATTRIBUTES PointerAttributes; VIDEO_POINTER_ATTRIBUTES PointerAttributes;
XLATEOBJ *PointerXlateObject;
HSURF PointerColorSurface; HSURF PointerColorSurface;
HSURF PointerMaskSurface; HSURF PointerMaskSurface;
HSURF PointerSaveSurface; HSURF PointerSaveSurface;
XLATEOBJ *XlateObject; POINTL PointerHotSpot;
POINTL HotSpot;
CLIPOBJ *ScreenClipObj;
#endif #endif
} PDEV, *PPDEV; } PDEV, *PPDEV;

View file

@ -44,7 +44,8 @@ DrvSetPointerShape(
IN RECTL *prcl, IN RECTL *prcl,
IN FLONG fl) IN FLONG fl)
{ {
return SPS_DECLINE; /* return SPS_DECLINE;*/
return EngSetPointerShape(pso, psoMask, psoColor, pxlo, xHot, yHot, x, y, prcl, fl);
} }
/* /*
@ -64,13 +65,13 @@ DrvMovePointer(
IN LONG y, IN LONG y,
IN RECTL *prcl) IN RECTL *prcl)
{ {
return EngMovePointer(pso, x, y, prcl);
} }
#else #else
VOID FASTCALL VOID FASTCALL
IntHideMousePointer(PPDEV ppdev) IntHideMousePointer(PPDEV ppdev, SURFOBJ *DestSurface)
{ {
if (ppdev->PointerAttributes.Enable == FALSE) if (ppdev->PointerAttributes.Enable == FALSE)
{ {
@ -83,7 +84,6 @@ IntHideMousePointer(PPDEV ppdev)
RECTL DestRect; RECTL DestRect;
POINTL SrcPoint; POINTL SrcPoint;
SURFOBJ *SaveSurface; SURFOBJ *SaveSurface;
SURFOBJ *DestSurface;
SURFOBJ *MaskSurface; SURFOBJ *MaskSurface;
DestRect.left = max(ppdev->PointerAttributes.Column, 0); DestRect.left = max(ppdev->PointerAttributes.Column, 0);
@ -99,18 +99,16 @@ IntHideMousePointer(PPDEV ppdev)
SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0); SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0);
SaveSurface = EngLockSurface(ppdev->PointerSaveSurface); SaveSurface = EngLockSurface(ppdev->PointerSaveSurface);
DestSurface = EngLockSurface(ppdev->hSurfEng);
MaskSurface = EngLockSurface(ppdev->PointerMaskSurface); MaskSurface = EngLockSurface(ppdev->PointerMaskSurface);
EngBitBlt(DestSurface, SaveSurface, MaskSurface, NULL, NULL, EngBitBlt(DestSurface, SaveSurface, MaskSurface, NULL, NULL,
&DestRect, &SrcPoint, &SrcPoint, NULL, NULL, SRCCOPY); &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, SRCCOPY);
EngUnlockSurface(MaskSurface); EngUnlockSurface(MaskSurface);
EngUnlockSurface(DestSurface);
EngUnlockSurface(SaveSurface); EngUnlockSurface(SaveSurface);
} }
} }
VOID FASTCALL VOID FASTCALL
IntShowMousePointer(PPDEV ppdev) IntShowMousePointer(PPDEV ppdev, SURFOBJ *DestSurface)
{ {
if (ppdev->PointerAttributes.Enable == TRUE) if (ppdev->PointerAttributes.Enable == TRUE)
{ {
@ -128,7 +126,6 @@ IntShowMousePointer(PPDEV ppdev)
RECTL DestRect; RECTL DestRect;
POINTL SrcPoint; POINTL SrcPoint;
SURFOBJ *SaveSurface; SURFOBJ *SaveSurface;
SURFOBJ *DestSurface;
SrcPoint.x = max(ppdev->PointerAttributes.Column, 0); SrcPoint.x = max(ppdev->PointerAttributes.Column, 0);
SrcPoint.y = max(ppdev->PointerAttributes.Row, 0); SrcPoint.y = max(ppdev->PointerAttributes.Row, 0);
@ -143,10 +140,8 @@ IntShowMousePointer(PPDEV ppdev)
ppdev->ScreenHeight - ppdev->PointerAttributes.Row - 1); ppdev->ScreenHeight - ppdev->PointerAttributes.Row - 1);
SaveSurface = EngLockSurface(ppdev->PointerSaveSurface); SaveSurface = EngLockSurface(ppdev->PointerSaveSurface);
DestSurface = EngLockSurface(ppdev->hSurfEng);
EngBitBlt(SaveSurface, DestSurface, NULL, NULL, NULL, EngBitBlt(SaveSurface, DestSurface, NULL, NULL, NULL,
&DestRect, &SrcPoint, NULL, NULL, NULL, SRCCOPY); &DestRect, &SrcPoint, NULL, NULL, NULL, SRCCOPY);
EngUnlockSurface(DestSurface);
EngUnlockSurface(SaveSurface); EngUnlockSurface(SaveSurface);
} }
@ -157,7 +152,6 @@ IntShowMousePointer(PPDEV ppdev)
{ {
RECTL DestRect; RECTL DestRect;
POINTL SrcPoint; POINTL SrcPoint;
SURFOBJ *DestSurf;
SURFOBJ *ColorSurf; SURFOBJ *ColorSurf;
SURFOBJ *MaskSurf; SURFOBJ *MaskSurf;
@ -173,26 +167,24 @@ IntShowMousePointer(PPDEV ppdev)
SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0); SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0);
SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0); SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0);
DestSurf = EngLockSurface(ppdev->hSurfEng);
MaskSurf = EngLockSurface(ppdev->PointerMaskSurface); MaskSurf = EngLockSurface(ppdev->PointerMaskSurface);
if (ppdev->PointerColorSurface != NULL) if (ppdev->PointerColorSurface != NULL)
{ {
ColorSurf = EngLockSurface(ppdev->PointerColorSurface); ColorSurf = EngLockSurface(ppdev->PointerColorSurface);
EngBitBlt(DestSurf, ColorSurf, MaskSurf, NULL, ppdev->XlateObject, EngBitBlt(DestSurface, ColorSurf, MaskSurf, NULL, ppdev->PointerXlateObject,
&DestRect, &SrcPoint, &SrcPoint, NULL, NULL, 0xAACC); &DestRect, &SrcPoint, &SrcPoint, NULL, NULL, 0xAACC);
EngUnlockSurface(ColorSurf); EngUnlockSurface(ColorSurf);
} }
else else
{ {
/* FIXME */ /* FIXME */
EngBitBlt(DestSurf, MaskSurf, NULL, NULL, NULL, EngBitBlt(DestSurface, MaskSurf, NULL, NULL, ppdev->PointerXlateObject,
&DestRect, &SrcPoint, NULL, NULL, NULL, SRCAND); &DestRect, &SrcPoint, NULL, NULL, NULL, SRCAND);
SrcPoint.y += ppdev->PointerAttributes.Height; SrcPoint.y += ppdev->PointerAttributes.Height;
EngBitBlt(DestSurf, MaskSurf, NULL, NULL, NULL, EngBitBlt(DestSurface, MaskSurf, NULL, NULL, ppdev->PointerXlateObject,
&DestRect, &SrcPoint, NULL, NULL, NULL, SRCINVERT); &DestRect, &SrcPoint, NULL, NULL, NULL, SRCINVERT);
} }
EngUnlockSurface(MaskSurf); EngUnlockSurface(MaskSurf);
EngUnlockSurface(DestSurf);
} }
} }
@ -221,7 +213,7 @@ DrvSetPointerShape(
PPDEV ppdev = (PPDEV)pso->dhpdev; PPDEV ppdev = (PPDEV)pso->dhpdev;
SURFOBJ *TempSurfObj; SURFOBJ *TempSurfObj;
IntHideMousePointer(ppdev); IntHideMousePointer(ppdev, pso);
if (ppdev->PointerColorSurface != NULL) if (ppdev->PointerColorSurface != NULL)
{ {
@ -262,10 +254,10 @@ DrvSetPointerShape(
return SPS_ACCEPT_EXCLUDE; return SPS_ACCEPT_EXCLUDE;
} }
ppdev->HotSpot.x = xHot; ppdev->PointerHotSpot.x = xHot;
ppdev->HotSpot.y = yHot; ppdev->PointerHotSpot.y = yHot;
ppdev->XlateObject = pxlo; ppdev->PointerXlateObject = pxlo;
ppdev->PointerAttributes.Column = x - xHot; ppdev->PointerAttributes.Column = x - xHot;
ppdev->PointerAttributes.Row = y - yHot; ppdev->PointerAttributes.Row = y - yHot;
ppdev->PointerAttributes.Width = psoMask->lDelta << 3; ppdev->PointerAttributes.Width = psoMask->lDelta << 3;
@ -330,7 +322,7 @@ DrvSetPointerShape(
Size, lDelta, pso->iBitmapFormat, BMF_NOZEROINIT, NULL); Size, lDelta, pso->iBitmapFormat, BMF_NOZEROINIT, NULL);
} }
IntShowMousePointer(ppdev); IntShowMousePointer(ppdev, pso);
return SPS_ACCEPT_EXCLUDE; return SPS_ACCEPT_EXCLUDE;
} }
@ -358,7 +350,7 @@ DrvMovePointer(
WasVisible = ppdev->PointerAttributes.Enable; WasVisible = ppdev->PointerAttributes.Enable;
if (WasVisible) if (WasVisible)
{ {
IntHideMousePointer(ppdev); IntHideMousePointer(ppdev, pso);
} }
if (x == -1) if (x == -1)
@ -366,12 +358,12 @@ DrvMovePointer(
return; return;
} }
ppdev->PointerAttributes.Column = x - ppdev->HotSpot.x; ppdev->PointerAttributes.Column = x - ppdev->PointerHotSpot.x;
ppdev->PointerAttributes.Row = y - ppdev->HotSpot.y; ppdev->PointerAttributes.Row = y - ppdev->PointerHotSpot.y;
if (WasVisible) if (WasVisible)
{ {
IntShowMousePointer(ppdev); IntShowMousePointer(ppdev, pso);
} }
} }

View file

@ -111,15 +111,6 @@ DrvEnableSurface(
ppdev->hSurfEng = hSurface; ppdev->hSurfEng = hSurface;
#ifdef EXPERIMENTAL_MOUSE_CURSOR_SUPPORT
ppdev->ScreenClipObj = EngCreateClip();
ppdev->ScreenClipObj->iDComplexity = DC_RECT;
ppdev->ScreenClipObj->rclBounds.left = 0;
ppdev->ScreenClipObj->rclBounds.top = 0;
ppdev->ScreenClipObj->rclBounds.right = ppdev->ScreenWidth;
ppdev->ScreenClipObj->rclBounds.bottom = ppdev->ScreenHeight;
#endif
return hSurface; return hSurface;
} }
@ -145,9 +136,6 @@ DrvDisableSurface(
ppdev->hSurfEng = NULL; ppdev->hSurfEng = NULL;
#ifdef EXPERIMENTAL_MOUSE_CURSOR_SUPPORT #ifdef EXPERIMENTAL_MOUSE_CURSOR_SUPPORT
EngDeleteClip(ppdev->ScreenClipObj);
ppdev->ScreenClipObj = NULL;
/* Clear all mouse pointer surfaces. */ /* Clear all mouse pointer surfaces. */
DrvSetPointerShape(NULL, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0); DrvSetPointerShape(NULL, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0);
#endif #endif

View file

@ -117,6 +117,19 @@ typedef struct
DRIVER_FUNCTIONS DriverFunctions; DRIVER_FUNCTIONS DriverFunctions;
PFILE_OBJECT VideoFileObject; PFILE_OBJECT VideoFileObject;
FAST_MUTEX DriverLock; FAST_MUTEX DriverLock;
struct {
BOOL Enable;
LONG Column;
LONG Row;
LONG Width;
LONG Height;
} PointerAttributes;
XLATEOBJ *PointerXlateObject;
HSURF PointerColorSurface;
HSURF PointerMaskSurface;
HSURF PointerSaveSurface;
POINTL PointerHotSpot;
} GDIDEVICE; } GDIDEVICE;
/* Internal functions */ /* Internal functions */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: mouse.c,v 1.56 2004/01/17 15:20:25 navaraf Exp $ /* $Id: mouse.c,v 1.57 2004/01/24 19:47:05 navaraf Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: Mouse * PURPOSE: Mouse
@ -533,40 +533,291 @@ EnableMouse(HDC hDisplayDC)
} }
} }
ULONG /* SOFTWARE MOUSE POINTER IMPLEMENTATION **************************************/
STDCALL
EngSetPointerShape( #define MOUSE_TAG TAG('M', 'O', 'U', 'S')
IN SURFOBJ *pso,
IN SURFOBJ *psoMask, VOID FASTCALL
IN SURFOBJ *psoColor, IntHideMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
IN XLATEOBJ *pxlo,
IN LONG xHot,
IN LONG yHot,
IN LONG x,
IN LONG y,
IN RECTL *prcl,
IN FLONG fl
)
{ {
// www.osr.com/ddk/graphics/gdifncs_1y5j.htm if (ppdev->PointerAttributes.Enable == FALSE)
UNIMPLEMENTED; {
return 0; return;
}
ppdev->PointerAttributes.Enable = FALSE;
if (ppdev->PointerSaveSurface != NULL)
{
RECTL DestRect;
POINTL SrcPoint;
SURFOBJ *SaveSurface;
SURFOBJ *MaskSurface;
DestRect.left = max(ppdev->PointerAttributes.Column, 0);
DestRect.top = max(ppdev->PointerAttributes.Row, 0);
DestRect.right = min(
ppdev->PointerAttributes.Column + ppdev->PointerAttributes.Width,
DestSurface->sizlBitmap.cx - 1);
DestRect.bottom = min(
ppdev->PointerAttributes.Row + ppdev->PointerAttributes.Height,
DestSurface->sizlBitmap.cy - 1);
SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0);
SrcPoint.y = max(-ppdev->PointerAttributes.Row, 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);
}
}
VOID FASTCALL
IntShowMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
{
if (ppdev->PointerAttributes.Enable == TRUE)
{
return;
}
ppdev->PointerAttributes.Enable = TRUE;
/*
* Copy the pixels under the cursor to temporary surface.
*/
if (ppdev->PointerSaveSurface != NULL)
{
RECTL DestRect;
POINTL SrcPoint;
SURFOBJ *SaveSurface;
SrcPoint.x = max(ppdev->PointerAttributes.Column, 0);
SrcPoint.y = max(ppdev->PointerAttributes.Row, 0);
DestRect.left = SrcPoint.x - ppdev->PointerAttributes.Column;
DestRect.top = SrcPoint.y - ppdev->PointerAttributes.Row;
DestRect.right = min(
ppdev->PointerAttributes.Width,
DestSurface->sizlBitmap.cx - ppdev->PointerAttributes.Column - 1);
DestRect.bottom = min(
ppdev->PointerAttributes.Height,
DestSurface->sizlBitmap.cy - ppdev->PointerAttributes.Row - 1);
SaveSurface = EngLockSurface(ppdev->PointerSaveSurface);
EngBitBlt(SaveSurface, DestSurface, NULL, NULL, NULL,
&DestRect, &SrcPoint, NULL, NULL, NULL, SRCCOPY);
EngUnlockSurface(SaveSurface);
}
/*
* Blit the cursor on the screen.
*/
{
RECTL DestRect;
POINTL SrcPoint;
SURFOBJ *ColorSurf;
SURFOBJ *MaskSurf;
DestRect.left = max(ppdev->PointerAttributes.Column, 0);
DestRect.top = max(ppdev->PointerAttributes.Row, 0);
DestRect.right = min(
ppdev->PointerAttributes.Column + ppdev->PointerAttributes.Width,
DestSurface->sizlBitmap.cx - 1);
DestRect.bottom = min(
ppdev->PointerAttributes.Row + ppdev->PointerAttributes.Height,
DestSurface->sizlBitmap.cy - 1);
SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0);
SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0);
MaskSurf = EngLockSurface(ppdev->PointerMaskSurface);
if (ppdev->PointerColorSurface != 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);
}
EngUnlockSurface(MaskSurf);
}
} }
/* /*
* @unimplemented * @implemented
*/ */
VOID
STDCALL ULONG STDCALL
EngMovePointer( EngSetPointerShape(
IN SURFOBJ *pso, IN SURFOBJ *pso,
IN LONG x, IN SURFOBJ *psoMask,
IN LONG y, IN SURFOBJ *psoColor,
IN RECTL *prcl IN XLATEOBJ *pxlo,
) IN LONG xHot,
IN LONG yHot,
IN LONG x,
IN LONG y,
IN RECTL *prcl,
IN FLONG fl)
{ {
// www.osr.com/ddk/graphics/gdifncs_8wfb.htm GDIDEVICE *ppdev = (GDIDEVICE *)pso->hdev;
UNIMPLEMENTED; SURFOBJ *TempSurfObj;
IntHideMousePointer(ppdev, pso);
if (ppdev->PointerColorSurface != NULL)
{
/* FIXME: Is this really needed? */
TempSurfObj = EngLockSurface(ppdev->PointerColorSurface);
EngFreeMem(TempSurfObj->pvBits);
TempSurfObj->pvBits = 0;
EngUnlockSurface(TempSurfObj);
EngDeleteSurface(ppdev->PointerColorSurface);
ppdev->PointerMaskSurface = NULL;
}
if (ppdev->PointerMaskSurface != NULL)
{
/* FIXME: Is this really needed? */
TempSurfObj = EngLockSurface(ppdev->PointerMaskSurface);
EngFreeMem(TempSurfObj->pvBits);
TempSurfObj->pvBits = 0;
EngUnlockSurface(TempSurfObj);
EngDeleteSurface(ppdev->PointerMaskSurface);
ppdev->PointerMaskSurface = NULL;
}
if (ppdev->PointerSaveSurface != NULL)
{
EngDeleteSurface(ppdev->PointerSaveSurface);
ppdev->PointerSaveSurface = NULL;
}
/*
* See if we are being asked to hide the pointer.
*/
if (psoMask == NULL)
{
return SPS_ACCEPT_EXCLUDE;
}
ppdev->PointerHotSpot.x = xHot;
ppdev->PointerHotSpot.y = yHot;
ppdev->PointerAttributes.Column = x - xHot;
ppdev->PointerAttributes.Row = y - yHot;
ppdev->PointerAttributes.Width = psoMask->lDelta << 3;
ppdev->PointerAttributes.Height = (psoMask->cjBits / psoMask->lDelta) >> 1;
ppdev->PointerXlateObject = pxlo;
if (psoColor != NULL)
{
SIZEL Size;
PBYTE Bits;
Size.cx = ppdev->PointerAttributes.Width;
Size.cy = ppdev->PointerAttributes.Height;
Bits = EngAllocMem(0, psoColor->cjBits, MOUSE_TAG);
memcpy(Bits, psoColor->pvBits, psoColor->cjBits);
ppdev->PointerColorSurface = (HSURF)EngCreateBitmap(Size,
psoColor->lDelta, psoColor->iBitmapFormat, 0, Bits);
}
else
{
ppdev->PointerColorSurface = NULL;
}
{
SIZEL Size;
PBYTE Bits;
Size.cx = ppdev->PointerAttributes.Width;
Size.cy = ppdev->PointerAttributes.Height << 1;
Bits = EngAllocMem(0, psoMask->cjBits, MOUSE_TAG);
memcpy(Bits, psoMask->pvBits, psoMask->cjBits);
ppdev->PointerMaskSurface = (HSURF)EngCreateBitmap(Size,
psoMask->lDelta, psoMask->iBitmapFormat, 0, Bits);
}
/*
* Create surface for saving the pixels under the cursor.
*/
{
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;
}
ppdev->PointerSaveSurface = (HSURF)EngCreateBitmap(
Size, lDelta, pso->iBitmapFormat, BMF_NOZEROINIT, NULL);
}
IntShowMousePointer(ppdev, pso);
return SPS_ACCEPT_EXCLUDE;
}
/*
* @implemented
*/
VOID STDCALL
EngMovePointer(
IN SURFOBJ *pso,
IN LONG x,
IN LONG y,
IN RECTL *prcl)
{
GDIDEVICE *ppdev = (GDIDEVICE *)pso->hdev;
BOOL WasVisible;
WasVisible = ppdev->PointerAttributes.Enable;
if (WasVisible)
{
IntHideMousePointer(ppdev, pso);
}
if (x == -1)
{
return;
}
ppdev->PointerAttributes.Column = x - ppdev->PointerHotSpot.x;
ppdev->PointerAttributes.Row = y - ppdev->PointerHotSpot.y;
if (WasVisible)
{
IntShowMousePointer(ppdev, pso);
}
} }
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: cursoricon.c,v 1.44 2004/01/17 15:20:25 navaraf Exp $ */ /* $Id: cursoricon.c,v 1.45 2004/01/24 19:47:05 navaraf Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
@ -98,87 +98,85 @@ SetPointerRect(PSYSTEM_CURSORINFO CurInfo, PRECTL PointerRect)
#define COLORCURSORS_ALLOWED FALSE #define COLORCURSORS_ALLOWED FALSE
HCURSOR FASTCALL HCURSOR FASTCALL
IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL ForceChange) IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
BOOL ForceChange)
{ {
PSURFOBJ SurfObj; PSURFOBJ SurfObj;
PSURFGDI SurfGDI; PSURFGDI SurfGDI;
SIZEL MouseSize; SIZEL MouseSize;
PDEVINFO DevInfo; PDEVINFO DevInfo;
PBITMAPOBJ MaskBmpObj; PBITMAPOBJ MaskBmpObj;
PSYSTEM_CURSORINFO CurInfo; PSYSTEM_CURSORINFO CurInfo;
PCURICON_OBJECT OldCursor; PCURICON_OBJECT OldCursor;
HCURSOR Ret = (HCURSOR)0; HCURSOR Ret = (HCURSOR)0;
HBITMAP hMask = (HBITMAP)0, hColor = (HBITMAP)0; HBITMAP hMask = (HBITMAP)0, hColor = (HBITMAP)0;
PSURFOBJ soMask = NULL, soColor = NULL; PSURFOBJ soMask = NULL, soColor = NULL;
PXLATEOBJ XlateObj = NULL; PXLATEOBJ XlateObj = NULL;
RECTL PointerRect; RECTL PointerRect;
CurInfo = &WinStaObject->SystemCursor; CurInfo = &WinStaObject->SystemCursor;
OldCursor = CurInfo->CurrentCursorObject; OldCursor = CurInfo->CurrentCursorObject;
if(OldCursor) if (OldCursor)
{ {
Ret = (HCURSOR)OldCursor->Self; Ret = (HCURSOR)OldCursor->Self;
} }
if(!ForceChange && (OldCursor == NewCursor)) if (!ForceChange && OldCursor == NewCursor)
{ {
return Ret;
}
{
/* FIXME use the desktop's HDC instead of using ScreenDeviceContext */
PDC dc = DC_LockDc(IntGetScreenDC());
if(!dc)
{
return Ret;
}
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
DevInfo = dc->DevInfo;
DC_UnlockDc(IntGetScreenDC());
}
if(!NewCursor && (CurInfo->CurrentCursorObject || ForceChange))
{
ExAcquireFastMutex(SurfGDI->DriverLock);
SurfGDI->PointerStatus = SurfGDI->SetPointerShape(SurfObj, NULL, NULL, NULL,
0,
0,
CurInfo->x,
CurInfo->y,
&PointerRect,
SPS_CHANGE);
ExReleaseFastMutex(SurfGDI->DriverLock);
SetPointerRect(CurInfo, &PointerRect);
CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
CurInfo->ShowingCursor = 0;
return Ret;
}
if (!NewCursor)
{
return Ret;
}
/* TODO: Fixme. Logic is screwed above */
ASSERT(NewCursor);
MaskBmpObj = BITMAPOBJ_LockBitmap(NewCursor->IconInfo.hbmMask);
if(MaskBmpObj)
{
const int maskBpp = MaskBmpObj->bitmap.bmBitsPixel;
BITMAPOBJ_UnlockBitmap(NewCursor->IconInfo.hbmMask);
if(maskBpp != 1)
{
DbgPrint("SetCursor: The Mask bitmap must have 1BPP!\n");
return Ret; return Ret;
}
{
/* FIXME use the desktop's HDC instead of using ScreenDeviceContext */
PDC dc = DC_LockDc(IntGetScreenDC());
if (!dc)
{
return Ret;
}
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
DevInfo = dc->DevInfo;
DC_UnlockDc(IntGetScreenDC());
}
if (!NewCursor && (CurInfo->CurrentCursorObject || ForceChange))
{
ExAcquireFastMutex(SurfGDI->DriverLock);
SurfGDI->PointerStatus = SurfGDI->SetPointerShape(SurfObj, NULL, NULL, NULL,
0, 0, CurInfo->x, CurInfo->y,
&PointerRect, SPS_CHANGE);
ExReleaseFastMutex(SurfGDI->DriverLock);
SetPointerRect(CurInfo, &PointerRect);
CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
CurInfo->ShowingCursor = 0;
return Ret;
}
if (!NewCursor)
{
return Ret;
}
/* TODO: Fixme. Logic is screwed above */
ASSERT(NewCursor);
MaskBmpObj = BITMAPOBJ_LockBitmap(NewCursor->IconInfo.hbmMask);
if (MaskBmpObj)
{
const int maskBpp = MaskBmpObj->bitmap.bmBitsPixel;
BITMAPOBJ_UnlockBitmap(NewCursor->IconInfo.hbmMask);
if (maskBpp != 1)
{
DbgPrint("SetCursor: The Mask bitmap must have 1BPP!\n");
return Ret;
} }
if((DevInfo->flGraphicsCaps2 & GCAPS2_ALPHACURSOR) && if ((DevInfo->flGraphicsCaps2 & GCAPS2_ALPHACURSOR) &&
(SurfGDI->BitsPerPixel >= 16) && NewCursor->Shadow (SurfGDI->BitsPerPixel >= 16) && NewCursor->Shadow
&& COLORCURSORS_ALLOWED) && COLORCURSORS_ALLOWED)
{ {
/* FIXME - Create a color pointer, only 32bit bitmap, set alpha bits! /* FIXME - Create a color pointer, only 32bit bitmap, set alpha bits!
Do not pass a mask bitmap to DrvSetPointerShape()! Do not pass a mask bitmap to DrvSetPointerShape()!
@ -232,7 +230,8 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL Fo
{ {
SurfGDI->SetPointerShape = EngSetPointerShape; SurfGDI->SetPointerShape = EngSetPointerShape;
SurfGDI->MovePointer = EngMovePointer; SurfGDI->MovePointer = EngMovePointer;
EngSetPointerShape(SurfObj, soMask, soColor, XlateObj, SurfGDI->PointerStatus = EngSetPointerShape(
SurfObj, soMask, soColor, XlateObj,
NewCursor->IconInfo.xHotspot, NewCursor->IconInfo.xHotspot,
NewCursor->IconInfo.yHotspot, NewCursor->IconInfo.yHotspot,
CurInfo->x, CurInfo->x,