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
* 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
* FILE: drivers/dd/vga/display/objects/pointer.c
@ -28,12 +28,15 @@
#include "../vgaddi.h"
#include "../vgavideo/vgavideo.h"
#define NDEBUG
#include <debug.h>
/* GLOBALS *******************************************************************/
static LONG oldx, oldy;
static PSAVED_SCREEN_BITS ImageBehindCursor = NULL;
VOID VGADDI_HideCursor(PPDEV ppdev);
VOID VGADDI_ShowCursor(PPDEV ppdev);
static VOID VGADDI_HideCursor(PPDEV ppdev);
static VOID VGADDI_ShowCursor(PPDEV ppdev, PRECTL prcl);
/* FUNCTIONS *****************************************************************/
@ -194,7 +197,6 @@ DrvMovePointer(IN SURFOBJ* pso,
{
PPDEV ppdev = (PPDEV)pso->dhpdev;
if (x < 0 && 0 == (ppdev->flCursor & CURSOR_DOWN))
{
/* 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))
{
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;
/* Show the cursor */
VGADDI_ShowCursor(ppdev);
VGADDI_ShowCursor(ppdev, prcl);
return SPS_ACCEPT_EXCLUDE;
}
VOID
VGADDI_HideCursor(PPDEV ppdev)
static VOID FASTCALL
VGADDI_ComputePointerRect(PPDEV ppdev, LONG X, LONG Y, PRECTL Rect)
{
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 */
SizeX = min(((oldx + ppdev->pPointerAttributes->Width) + 7) & ~0x7, ppdev->sizeSurf.cx);
SizeX -= (oldx & ~0x7);
SizeY = min(ppdev->pPointerAttributes->Height, ppdev->sizeSurf.cy - oldy);
VGADDI_BltFromSavedScreenBits(max(oldx, 0) & ~0x7,
max(oldy, 0),
ImageBehindCursor,
SizeX,
SizeY);
VGADDI_BltFromSavedScreenBits(Rect.left,
Rect.top,
ImageBehindCursor,
Rect.right - Rect.left,
Rect.bottom - Rect.top);
ppdev->pPointerAttributes->Enable = 0;
}
VOID
VGADDI_ShowCursor(PPDEV ppdev)
static VOID
VGADDI_ShowCursor(PPDEV ppdev, PRECTL prcl)
{
LONG cx, cy;
PUCHAR AndMask, XorMask;
ULONG SizeX, SizeY;
RECTL Rect;
if (ppdev->pPointerAttributes->Enable != 0)
{
VGADDI_HideCursor(ppdev);
}
/* Capture pixels behind the cursor */
cx = ppdev->xyCursor.x - ppdev->xyHotSpot.x;
cy = ppdev->xyCursor.y - ppdev->xyHotSpot.y;
/* Used to repaint background */
SizeX = min(((cx + ppdev->pPointerAttributes->Width) + 7) & ~0x7, ppdev->sizeSurf.cx);
SizeX -= (cx & ~0x7);
SizeY = min(ppdev->pPointerAttributes->Height, ppdev->sizeSurf.cy - cy);
/* Capture pixels behind the cursor */
VGADDI_ComputePointerRect(ppdev, cx, cy, &Rect);
VGADDI_BltToSavedScreenBits(ImageBehindCursor,
max(cx, 0) & ~0x7,
max(cy, 0),
SizeX,
SizeY);
Rect.left,
Rect.top,
Rect.right - Rect.left,
Rect.bottom - Rect.top);
/* Display the cursor. */
SizeX = min(ppdev->pPointerAttributes->Width, ppdev->sizeSurf.cx - cx);
@ -379,4 +390,9 @@ VGADDI_ShowCursor(PPDEV ppdev)
/* Mark the cursor as currently displayed. */
ppdev->pPointerAttributes->Enable = 1;
if (NULL != prcl)
{
*prcl = Rect;
}
}

View file

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

View file

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

View file

@ -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.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
@ -94,7 +94,6 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL Fo
PSURFOBJ SurfObj;
PSURFGDI SurfGDI;
SIZEL MouseSize;
RECTL MouseRect;
PDEVINFO DevInfo;
PBITMAPOBJ MaskBmpObj;
PSYSTEM_CURSORINFO CurInfo;
@ -137,7 +136,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL Fo
0,
CurInfo->x,
CurInfo->y,
&MouseRect,
&CurInfo->PointerRect,
SPS_CHANGE);
CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
@ -211,7 +210,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL Fo
NewCursor->IconInfo.yHotspot,
CurInfo->x,
CurInfo->y,
&MouseRect,
&CurInfo->PointerRect,
SPS_CHANGE);
if(hMask)