Store area touched by mouse pointer as this may be larger than the cursor

size. Fixes bug #63.

svn path=/trunk/; revision=7679
This commit is contained in:
Gé van Geldorp 2004-01-16 13:18:23 +00:00
parent 3fb858b15e
commit ade9a80f9a
4 changed files with 60 additions and 48 deletions

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: pointer.c,v 1.1 2004/01/10 14:39:20 navaraf Exp $ /* $Id: pointer.c,v 1.2 2004/01/16 13:18:23 gvg Exp $
* *
* PROJECT: ReactOS VGA16 display driver * PROJECT: ReactOS VGA16 display driver
* FILE: drivers/dd/vga/display/objects/pointer.c * FILE: drivers/dd/vga/display/objects/pointer.c
@ -28,12 +28,15 @@
#include "../vgaddi.h" #include "../vgaddi.h"
#include "../vgavideo/vgavideo.h" #include "../vgavideo/vgavideo.h"
#define NDEBUG
#include <debug.h>
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
static LONG oldx, oldy; static LONG oldx, oldy;
static PSAVED_SCREEN_BITS ImageBehindCursor = NULL; static PSAVED_SCREEN_BITS ImageBehindCursor = NULL;
VOID VGADDI_HideCursor(PPDEV ppdev); static VOID VGADDI_HideCursor(PPDEV ppdev);
VOID VGADDI_ShowCursor(PPDEV ppdev); static VOID VGADDI_ShowCursor(PPDEV ppdev, PRECTL prcl);
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -194,7 +197,6 @@ DrvMovePointer(IN SURFOBJ* pso,
{ {
PPDEV ppdev = (PPDEV)pso->dhpdev; PPDEV ppdev = (PPDEV)pso->dhpdev;
if (x < 0 && 0 == (ppdev->flCursor & CURSOR_DOWN)) if (x < 0 && 0 == (ppdev->flCursor & CURSOR_DOWN))
{ {
/* x < 0 and y < 0 indicates we must hide the cursor */ /* x < 0 and y < 0 indicates we must hide the cursor */
@ -207,11 +209,8 @@ DrvMovePointer(IN SURFOBJ* pso,
if (0 == (ppdev->flCursor & CURSOR_DOWN)) if (0 == (ppdev->flCursor & CURSOR_DOWN))
{ {
VGADDI_ShowCursor(ppdev); VGADDI_ShowCursor(ppdev, prcl);
} }
/* Give feedback on the new cursor rectangle */
/*if (prcl != NULL) ComputePointerRect(ppdev, prcl);*/
} }
@ -300,55 +299,67 @@ DrvSetPointerShape(SURFOBJ* pso,
ppdev->xyHotSpot.y = yHot; ppdev->xyHotSpot.y = yHot;
/* Show the cursor */ /* Show the cursor */
VGADDI_ShowCursor(ppdev); VGADDI_ShowCursor(ppdev, prcl);
return SPS_ACCEPT_EXCLUDE; return SPS_ACCEPT_EXCLUDE;
} }
VOID static VOID FASTCALL
VGADDI_HideCursor(PPDEV ppdev) VGADDI_ComputePointerRect(PPDEV ppdev, LONG X, LONG Y, PRECTL Rect)
{ {
ULONG SizeX, SizeY; ULONG SizeX, SizeY;
SizeX = min(((X + ppdev->pPointerAttributes->Width) + 7) & ~0x7, ppdev->sizeSurf.cx);
SizeX -= (X & ~0x7);
SizeY = min(ppdev->pPointerAttributes->Height, ppdev->sizeSurf.cy - Y);
Rect->left = max(X, 0) & ~0x7;
Rect->top = max(Y, 0);
Rect->right = Rect->left + SizeX;
Rect->bottom = Rect->top + SizeY;
}
static VOID
VGADDI_HideCursor(PPDEV ppdev)
{
RECTL Rect;
VGADDI_ComputePointerRect(ppdev, oldx, oldy, &Rect);
/* Display what was behind cursor */ /* Display what was behind cursor */
SizeX = min(((oldx + ppdev->pPointerAttributes->Width) + 7) & ~0x7, ppdev->sizeSurf.cx); VGADDI_BltFromSavedScreenBits(Rect.left,
SizeX -= (oldx & ~0x7); Rect.top,
SizeY = min(ppdev->pPointerAttributes->Height, ppdev->sizeSurf.cy - oldy); ImageBehindCursor,
VGADDI_BltFromSavedScreenBits(max(oldx, 0) & ~0x7, Rect.right - Rect.left,
max(oldy, 0), Rect.bottom - Rect.top);
ImageBehindCursor,
SizeX,
SizeY);
ppdev->pPointerAttributes->Enable = 0; ppdev->pPointerAttributes->Enable = 0;
} }
VOID static VOID
VGADDI_ShowCursor(PPDEV ppdev) VGADDI_ShowCursor(PPDEV ppdev, PRECTL prcl)
{ {
LONG cx, cy; LONG cx, cy;
PUCHAR AndMask, XorMask; PUCHAR AndMask, XorMask;
ULONG SizeX, SizeY; ULONG SizeX, SizeY;
RECTL Rect;
if (ppdev->pPointerAttributes->Enable != 0) if (ppdev->pPointerAttributes->Enable != 0)
{ {
VGADDI_HideCursor(ppdev); VGADDI_HideCursor(ppdev);
} }
/* Capture pixels behind the cursor */
cx = ppdev->xyCursor.x - ppdev->xyHotSpot.x; cx = ppdev->xyCursor.x - ppdev->xyHotSpot.x;
cy = ppdev->xyCursor.y - ppdev->xyHotSpot.y; cy = ppdev->xyCursor.y - ppdev->xyHotSpot.y;
/* Used to repaint background */ /* Capture pixels behind the cursor */
SizeX = min(((cx + ppdev->pPointerAttributes->Width) + 7) & ~0x7, ppdev->sizeSurf.cx); VGADDI_ComputePointerRect(ppdev, cx, cy, &Rect);
SizeX -= (cx & ~0x7);
SizeY = min(ppdev->pPointerAttributes->Height, ppdev->sizeSurf.cy - cy);
VGADDI_BltToSavedScreenBits(ImageBehindCursor, VGADDI_BltToSavedScreenBits(ImageBehindCursor,
max(cx, 0) & ~0x7, Rect.left,
max(cy, 0), Rect.top,
SizeX, Rect.right - Rect.left,
SizeY); Rect.bottom - Rect.top);
/* Display the cursor. */ /* Display the cursor. */
SizeX = min(ppdev->pPointerAttributes->Width, ppdev->sizeSurf.cx - cx); SizeX = min(ppdev->pPointerAttributes->Width, ppdev->sizeSurf.cx - cx);
@ -379,4 +390,9 @@ VGADDI_ShowCursor(PPDEV ppdev)
/* Mark the cursor as currently displayed. */ /* Mark the cursor as currently displayed. */
ppdev->pPointerAttributes->Enable = 1; ppdev->pPointerAttributes->Enable = 1;
if (NULL != prcl)
{
*prcl = Rect;
}
} }

View file

@ -25,6 +25,7 @@ typedef struct _SYSTEM_CURSORINFO
LONG x, y; LONG x, y;
BOOL SafetySwitch; BOOL SafetySwitch;
UINT SafetyRemoveCount; UINT SafetyRemoveCount;
RECTL PointerRect;
FAST_MUTEX CursorMutex; FAST_MUTEX CursorMutex;
CURSORCLIP_INFO CursorClipInfo; CURSORCLIP_INFO CursorClipInfo;
PVOID CurIconHandleTable; PVOID CurIconHandleTable;

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.52 2004/01/15 16:29:10 gvg Exp $ /* $Id: mouse.c,v 1.53 2004/01/16 13:18:23 gvg Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: Mouse * PURPOSE: Mouse
@ -83,7 +83,6 @@ MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1,
* a rectangle on a particular surface. * a rectangle on a particular surface.
*/ */
{ {
RECTL MouseRect;
LONG tmp; LONG tmp;
PSYSTEM_CURSORINFO CurInfo; PSYSTEM_CURSORINFO CurInfo;
BOOL MouseEnabled = FALSE; BOOL MouseEnabled = FALSE;
@ -136,10 +135,10 @@ MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1,
tmp = HazardY2; HazardY2 = HazardY1; HazardY1 = tmp; tmp = HazardY2; HazardY2 = HazardY1; HazardY1 = tmp;
} }
if (CurInfo->x - (INT) Cursor->IconInfo.xHotspot + Cursor->Size.cx >= HazardX1 if (CurInfo->PointerRect.right >= HazardX1
&& CurInfo->x - (INT) Cursor->IconInfo.xHotspot <= HazardX2 && CurInfo->PointerRect.left <= HazardX2
&& CurInfo->y - (INT) Cursor->IconInfo.yHotspot + Cursor->Size.cy >= HazardY1 && CurInfo->PointerRect.bottom >= HazardY1
&& CurInfo->y - (INT) Cursor->IconInfo.yHotspot <= HazardY2) && CurInfo->PointerRect.top <= HazardY2)
{ {
/* Mouse is not allowed to move if GDI is busy drawing */ /* Mouse is not allowed to move if GDI is busy drawing */
ExAcquireFastMutex(&CurInfo->CursorMutex); ExAcquireFastMutex(&CurInfo->CursorMutex);
@ -151,7 +150,7 @@ MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1,
return FALSE; return FALSE;
} }
CurInfo->SafetySwitch = TRUE; CurInfo->SafetySwitch = TRUE;
SurfGDI->MovePointer(SurfObj, -1, -1, &MouseRect); SurfGDI->MovePointer(SurfObj, -1, -1, NULL);
ExReleaseFastMutex(&CurInfo->CursorMutex); ExReleaseFastMutex(&CurInfo->CursorMutex);
} }
@ -165,7 +164,6 @@ MouseSafetyOnDrawEnd(PSURFOBJ SurfObj, PSURFGDI SurfGDI)
* FUNCTION: Notify the mouse driver that drawing has finished on a surface. * FUNCTION: Notify the mouse driver that drawing has finished on a surface.
*/ */
{ {
RECTL MouseRect;
PSYSTEM_CURSORINFO CurInfo; PSYSTEM_CURSORINFO CurInfo;
BOOL MouseEnabled = FALSE; BOOL MouseEnabled = FALSE;
@ -210,7 +208,7 @@ MouseSafetyOnDrawEnd(PSURFOBJ SurfObj, PSURFGDI SurfGDI)
ObDereferenceObject(InputWindowStation); ObDereferenceObject(InputWindowStation);
return FALSE; return FALSE;
} }
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &CurInfo->PointerRect);
CurInfo->SafetySwitch = FALSE; CurInfo->SafetySwitch = FALSE;
} }
@ -224,7 +222,6 @@ MouseMoveCursor(LONG X, LONG Y)
{ {
HDC hDC; HDC hDC;
PDC dc; PDC dc;
RECTL MouseRect;
BOOL res = FALSE; BOOL res = FALSE;
PSURFOBJ SurfObj; PSURFOBJ SurfObj;
PSURFGDI SurfGDI; PSURFGDI SurfGDI;
@ -263,7 +260,7 @@ MouseMoveCursor(LONG X, LONG Y)
if(CurInfo->Enabled) if(CurInfo->Enabled)
{ {
ExAcquireFastMutex(&CurInfo->CursorMutex); ExAcquireFastMutex(&CurInfo->CursorMutex);
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &CurInfo->PointerRect);
ExReleaseFastMutex(&CurInfo->CursorMutex); ExReleaseFastMutex(&CurInfo->CursorMutex);
} }
/* send MOUSEMOVE message */ /* send MOUSEMOVE message */
@ -303,7 +300,6 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
PDC dc; PDC dc;
PSURFOBJ SurfObj; PSURFOBJ SurfObj;
PSURFGDI SurfGDI; PSURFGDI SurfGDI;
RECTL MouseRect;
MSG Msg; MSG Msg;
hDC = IntGetScreenDC(); hDC = IntGetScreenDC();
@ -421,7 +417,7 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y))) ((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y)))
{ {
ExAcquireFastMutex(&CurInfo->CursorMutex); ExAcquireFastMutex(&CurInfo->CursorMutex);
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &CurInfo->PointerRect);
ExReleaseFastMutex(&CurInfo->CursorMutex); ExReleaseFastMutex(&CurInfo->CursorMutex);
mouse_cx = 0; mouse_cx = 0;
mouse_cy = 0; mouse_cy = 0;
@ -448,7 +444,7 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y))) ((mouse_ox != CurInfo->x) || (mouse_oy != CurInfo->y)))
{ {
ExAcquireFastMutex(&CurInfo->CursorMutex); ExAcquireFastMutex(&CurInfo->CursorMutex);
SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &MouseRect); SurfGDI->MovePointer(SurfObj, CurInfo->x, CurInfo->y, &CurInfo->PointerRect);
ExReleaseFastMutex(&CurInfo->CursorMutex); ExReleaseFastMutex(&CurInfo->CursorMutex);
} }
} }

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.40 2003/12/18 23:04:54 gvg Exp $ */ /* $Id: cursoricon.c,v 1.41 2004/01/16 13:18:23 gvg Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
@ -94,7 +94,6 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL Fo
PSURFOBJ SurfObj; PSURFOBJ SurfObj;
PSURFGDI SurfGDI; PSURFGDI SurfGDI;
SIZEL MouseSize; SIZEL MouseSize;
RECTL MouseRect;
PDEVINFO DevInfo; PDEVINFO DevInfo;
PBITMAPOBJ MaskBmpObj; PBITMAPOBJ MaskBmpObj;
PSYSTEM_CURSORINFO CurInfo; PSYSTEM_CURSORINFO CurInfo;
@ -137,7 +136,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL Fo
0, 0,
CurInfo->x, CurInfo->x,
CurInfo->y, CurInfo->y,
&MouseRect, &CurInfo->PointerRect,
SPS_CHANGE); SPS_CHANGE);
CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */ CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
@ -211,7 +210,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL Fo
NewCursor->IconInfo.yHotspot, NewCursor->IconInfo.yHotspot,
CurInfo->x, CurInfo->x,
CurInfo->y, CurInfo->y,
&MouseRect, &CurInfo->PointerRect,
SPS_CHANGE); SPS_CHANGE);
if(hMask) if(hMask)