/*
- * ReactOS kernel
- * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
+ * 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
* 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.19 2003/03/09 15:00:51 jfilby Exp $
+/* $Id: mouse.c,v 1.25 2003/05/18 19:30:55 ea Exp $
*
* PROJECT: ReactOS kernel
* PURPOSE: Mouse
#include <win32k/dc.h>
#include "objects.h"
#include "include/msgqueue.h"
+#include "include/object.h"
+#include "include/winsta.h"
+#include <include/mouse.h>
#define NDEBUG
#include <debug.h>
static BOOLEAN MouseEnabled = FALSE;
static LONG mouse_x, mouse_y;
static UINT mouse_width = 0, mouse_height = 0;
+static ULONG PointerStatus;
static UCHAR DefaultCursor[256] = {
+ 0x3F, 0xFF, 0xFF, 0xFF,
+ 0x1F, 0xFF, 0xFF, 0xFF,
+ 0x0F, 0xFF, 0xFF, 0xFF,
+ 0x07, 0xFF, 0xFF, 0xFF,
+ 0x03, 0xFF, 0xFF, 0xFF,
+ 0x01, 0xFF, 0xFF, 0xFF,
+ 0x00, 0xFF, 0xFF, 0xFF,
+ 0x00, 0x7F, 0xFF, 0xFF,
+ 0x00, 0x3F, 0xFF, 0xFF,
+ 0x00, 0x1F, 0xFF, 0xFF,
+ 0x00, 0x0F, 0xFF, 0xFF,
+ 0x00, 0xFF, 0xFF, 0xFF,
+ 0x00, 0xFF, 0xFF, 0xFF,
+ 0x18, 0x7F, 0xFF, 0xFF,
+ 0x38, 0x7F, 0xFF, 0xFF,
+ 0x7C, 0x3F, 0xFF, 0xFF,
+ 0xFC, 0x3F, 0xFF, 0xFF,
+ 0xFE, 0x1F, 0xFF, 0xFF,
+ 0xFE, 0x1F, 0xFF, 0xFF,
+ 0xFF, 0x3F, 0xFF, 0x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FF, 0xFF, 0xFF,
- 0x0F, 0xFF, 0xFF, 0xFF,
- 0x1F, 0xFF, 0xFF, 0xFF,
- 0x3F, 0xFF, 0xFF, 0xFF};
+ 0x00, 0x00, 0x00, 0x00};
/* FUNCTIONS *****************************************************************/
-INT
+INT STDCALL
MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1,
LONG HazardY1, LONG HazardX2, LONG HazardY2)
/*
RECTL MouseRect;
LONG tmp;
+
/* Mouse is not allowed to move if GDI is busy drawing */
SafetySwitch2 = TRUE;
return(FALSE);
}
+ if (SPS_ACCEPT_NOEXCLUDE == PointerStatus)
+ {
+ /* Hardware cursor, no need to remove it */
+ return(FALSE);
+ }
+
if (HazardX1 > HazardX2)
{
tmp = HazardX2; HazardX2 = HazardX1; HazardX1 = tmp;
return(TRUE);
}
-INT
+INT FASTCALL
MouseSafetyOnDrawEnd(PSURFOBJ SurfObj, PSURFGDI SurfGDI)
/*
* FUNCTION: Notify the mouse driver that drawing has finished on a surface.
if (SurfObj == NULL)
{
+ SafetySwitch2 = FALSE;
return(FALSE);
}
if (SurfObj->iType != STYPE_DEVICE || MouseEnabled == FALSE)
{
+ SafetySwitch2 = FALSE;
+ return(FALSE);
+ }
+
+ if (SPS_ACCEPT_NOEXCLUDE == PointerStatus)
+ {
+ /* Hardware cursor, it wasn't removed so need to restore it */
+ SafetySwitch2 = FALSE;
return(FALSE);
}
return(TRUE);
}
-VOID
+VOID /* STDCALL */
MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
/*
* FUNCTION: Call by the mouse driver when input events occur.
PSURFGDI SurfGDI;
RECTL MouseRect;
MSG Msg;
- ULONG j;
LARGE_INTEGER LargeTickCount;
ULONG TickCount;
static ULONG ButtonsDown = 0;
- const UINT MouseButtonDownMessage[3] =
- {WM_RBUTTONDOWN, WM_MBUTTONDOWN, WM_LBUTTONDOWN};
- const UINT MouseButtonUpMessage[3] =
- {WM_RBUTTONUP, WM_MBUTTONUP, WM_LBUTTONUP};
- const ULONG MouseButtonFlag[3] = {MK_RBUTTON, MK_MBUTTON, MK_LBUTTON};
KeQueryTickCount(&LargeTickCount);
TickCount = LargeTickCount.u.LowPart;
}
dc = DC_HandleToPtr(hDC);
- SurfObj = (PSURFOBJ)AccessUserObject(dc->Surface);
- SurfGDI = (PSURFGDI)AccessInternalObject(dc->Surface);
+ SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
+ SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
DC_ReleasePtr( hDC );
/* Compile the total mouse movement change and dispatch button events. */
Msg.time = TickCount;
Msg.pt.x = mouse_x + mouse_cx;
Msg.pt.y = mouse_y + mouse_cy;
- if ((mouse_cx > 0) || (mouse_cy > 0))
+ if ((0 != Data[i].LastX) || (0 != Data[i].LastY))
{
MsqInsertSystemMessage(&Msg);
}
mouse_x = min(mouse_x, 620);
mouse_y = min(mouse_y, 460);
+
if (SafetySwitch == FALSE && SafetySwitch2 == FALSE)
{
SurfGDI->MovePointer(SurfObj, mouse_x, mouse_y, &MouseRect);
}
}
-VOID
+VOID FASTCALL
EnableMouse(HDC hDisplayDC)
{
PDC dc;
SIZEL MouseSize;
RECTL MouseRect;
- dc = DC_HandleToPtr(hDisplayDC);
- if( dc ){
- SurfObj = (PSURFOBJ)AccessUserObject(dc->Surface);
- SurfGDI = (PSURFGDI)AccessInternalObject(dc->Surface);
- DC_ReleasePtr( hDisplayDC );
-
- /* Create the default mouse cursor. */
- mouse_width = 32;
- mouse_height = 32;
- MouseSize.cx = 32;
- MouseSize.cy = 64;
- hMouseSurf = EngCreateBitmap(MouseSize, 4, BMF_1BPP, 0, DefaultCursor);
- MouseSurf = (PSURFOBJ)AccessUserObject(hMouseSurf);
-
- /* Tell the display driver to set the pointer shape. */
- SurfGDI->SetPointerShape(SurfObj, MouseSurf, NULL, NULL, 0, 0, 320, 240,
- &MouseRect, 0);
-
- mouse_x = 320;
- mouse_y = 240;
- MouseEnabled = TRUE;
+ if( hDisplayDC )
+ {
+ dc = DC_HandleToPtr(hDisplayDC);
+ SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
+ SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
+ DC_ReleasePtr( hDisplayDC );
+
+ /* Create the default mouse cursor. */
+ mouse_width = 32;
+ mouse_height = 32;
+ MouseSize.cx = 32;
+ MouseSize.cy = 64;
+ hMouseSurf = EngCreateBitmap(MouseSize, 4, BMF_1BPP, BMF_TOPDOWN, DefaultCursor);
+ MouseSurf = (PSURFOBJ)AccessUserObject((ULONG) hMouseSurf);
+
+ /* Tell the display driver to set the pointer shape. */
+#if 0
+ mouse_x = SurfObj->sizlBitmap.cx / 2;
+ mouse_y = SurfObj->sizlBitmap.cy / 2;
+#else
+ mouse_x = 320;
+ mouse_y = 240;
+#endif
+ PointerStatus = SurfGDI->SetPointerShape(SurfObj, MouseSurf, NULL, NULL,
+ 0, 0, mouse_x, mouse_y, &MouseRect,
+ SPS_CHANGE);
+
+ MouseEnabled = (SPS_ACCEPT_EXCLUDE == PointerStatus ||
+ SPS_ACCEPT_NOEXCLUDE == PointerStatus);
+
+ EngDeleteSurface(hMouseSurf);
}
- else{
- MouseEnabled = FALSE;
+ else
+ {
+ MouseEnabled = FALSE;
}
}
-
+/* EOF */