Get mouse cursor working under VMware

svn path=/trunk/; revision=4286
This commit is contained in:
Gé van Geldorp 2003-03-11 00:21:41 +00:00
parent aee47209b1
commit ab42b89f19
7 changed files with 145 additions and 100 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.13 2003/01/25 23:06:32 ei Exp $ /* $Id: pointer.c,v 1.14 2003/03/11 00:21:40 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
@ -76,9 +76,10 @@ VGADDI_BltPointerToVGA(ULONG StartX, ULONG StartY, ULONG SizeX,
/* Write the mask. */ /* Write the mask. */
Video = (PUCHAR)vidmem + StartY * 80 + (StartX >> 3); Video = (PUCHAR)vidmem + StartY * 80 + (StartX >> 3);
Src = MaskBits; Src = MaskBits + SizeY * MaskPitch;
for (i = 0; i < SizeY; i++, Video+=80, Src+=MaskPitch) for (i = 0; i < SizeY; i++, Video+=80)
{ {
Src -= MaskPitch;
SrcValue = (*Src) >> (StartX % 8); SrcValue = (*Src) >> (StartX % 8);
(VOID)READ_REGISTER_UCHAR(Video); (VOID)READ_REGISTER_UCHAR(Video);
WRITE_REGISTER_UCHAR(Video, SrcValue); WRITE_REGISTER_UCHAR(Video, SrcValue);
@ -101,7 +102,7 @@ VGADDI_BltPointerToVGA(ULONG StartX, ULONG StartY, ULONG SizeX,
for (i = StartY; i < EndY; i++) for (i = StartY; i < EndY; i++)
{ {
Video = (PUCHAR)vidmem + i * 80 + (Left >> 3); Video = (PUCHAR)vidmem + i * 80 + (Left >> 3);
Src = MaskBits + (i - StartY) * MaskPitch; Src = MaskBits + (EndY - i - 1) * MaskPitch;
for (j = 0; j < Length; j++, Video++, Src++) for (j = 0; j < Length; j++, Video++, Src++)
{ {
if ((StartX % 8) != 0) if ((StartX % 8) != 0)
@ -127,9 +128,10 @@ VGADDI_BltPointerToVGA(ULONG StartX, ULONG StartY, ULONG SizeX,
WRITE_PORT_UCHAR((PUCHAR)GRA_D, Mask); WRITE_PORT_UCHAR((PUCHAR)GRA_D, Mask);
Video = (PUCHAR)vidmem + StartY * 80 + (EndX >> 3); Video = (PUCHAR)vidmem + StartY * 80 + (EndX >> 3);
Src = MaskBits + (SizeX >> 3) - 1; Src = MaskBits + SizeY * MaskPitch + (SizeX >> 3) - 1;
for (i = StartY; i < EndY; i++, Video+=80, Src+=MaskPitch) for (i = StartY; i < EndY; i++, Video+=80)
{ {
Src -= MaskPitch;
SrcValue = (Src[0] << (8 - (StartX % 8))); SrcValue = (Src[0] << (8 - (StartX % 8)));
(VOID)READ_REGISTER_UCHAR(Video); (VOID)READ_REGISTER_UCHAR(Video);
WRITE_REGISTER_UCHAR(Video, SrcValue); WRITE_REGISTER_UCHAR(Video, SrcValue);
@ -279,6 +281,8 @@ DrvSetPointerShape(PSURFOBJ pso,
/* Show the cursor */ /* Show the cursor */
VGADDI_ShowCursor(ppdev); VGADDI_ShowCursor(ppdev);
return SPS_ACCEPT_EXCLUDE;
} }
VOID VOID
@ -303,7 +307,7 @@ VOID
VGADDI_ShowCursor(PPDEV ppdev) VGADDI_ShowCursor(PPDEV ppdev)
{ {
ULONG i, j, cx, cy; ULONG i, j, cx, cy;
PUCHAR AndMask; PUCHAR XorMask;
ULONG SizeX; ULONG SizeX;
if (ppdev->pPointerAttributes->Enable != 0) if (ppdev->pPointerAttributes->Enable != 0)
@ -326,20 +330,20 @@ VGADDI_ShowCursor(PPDEV ppdev)
ppdev->pPointerAttributes->Height); ppdev->pPointerAttributes->Height);
/* Display the cursor. */ /* Display the cursor. */
AndMask = ppdev->pPointerAttributes->Pixels + XorMask = ppdev->pPointerAttributes->Pixels +
ppdev->pPointerAttributes->WidthInBytes * ppdev->pPointerAttributes->WidthInBytes *
ppdev->pPointerAttributes->Height; ppdev->pPointerAttributes->Height;
VGADDI_BltPointerToVGA(ppdev->xyCursor.x, VGADDI_BltPointerToVGA(ppdev->xyCursor.x,
ppdev->xyCursor.y, ppdev->xyCursor.y,
ppdev->pPointerAttributes->Width, ppdev->pPointerAttributes->Width,
ppdev->pPointerAttributes->Height, ppdev->pPointerAttributes->Height,
AndMask, ppdev->pPointerAttributes->Pixels,
VGA_AND); VGA_AND);
VGADDI_BltPointerToVGA(ppdev->xyCursor.x, VGADDI_BltPointerToVGA(ppdev->xyCursor.x,
ppdev->xyCursor.y, ppdev->xyCursor.y,
ppdev->pPointerAttributes->Width, ppdev->pPointerAttributes->Width,
ppdev->pPointerAttributes->Height, ppdev->pPointerAttributes->Height,
ppdev->pPointerAttributes->Pixels, XorMask,
VGA_XOR); VGA_XOR);
/* Save the new cursor location. */ /* Save the new cursor location. */

View file

@ -1,6 +1,9 @@
#ifndef __WIN32K_MISC_H #ifndef __WIN32K_MISC_H
#define __WIN32K_MISC_H #define __WIN32K_MISC_H
/* Process context in which miniport driver is opened/used */
extern PEPROCESS W32kDeviceProcess;
BOOLEAN BOOLEAN
STDCALL STDCALL
W32kInitialize (VOID); W32kInitialize (VOID);

View file

@ -9,6 +9,7 @@
*/ */
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <win32k/misc.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -32,12 +33,17 @@ EngDeviceIoControl(HANDLE hDevice,
KeInitializeEvent(&Event, SynchronizationEvent, FALSE); KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
/* Switch to process context in which hDevice is valid */
KeAttachProcess(W32kDeviceProcess);
Status = ObReferenceObjectByHandle(hDevice, Status = ObReferenceObjectByHandle(hDevice,
FILE_READ_DATA | FILE_WRITE_DATA, FILE_READ_DATA | FILE_WRITE_DATA,
IoFileObjectType, IoFileObjectType,
KernelMode, KernelMode,
(PVOID *)&FileObject, (PVOID *)&FileObject,
NULL); NULL);
KeDetachProcess();
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return(Status); return(Status);

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.19 2003/03/09 15:00:51 jfilby Exp $ /* $Id: mouse.c,v 1.20 2003/03/11 00:21:41 gvg Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: Mouse * PURPOSE: Mouse
@ -33,6 +33,8 @@
#include <win32k/dc.h> #include <win32k/dc.h>
#include "objects.h" #include "objects.h"
#include "include/msgqueue.h" #include "include/msgqueue.h"
#include "include/object.h"
#include "include/winsta.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -44,73 +46,74 @@ static BOOLEAN SafetySwitch2 = FALSE;
static BOOLEAN MouseEnabled = FALSE; static BOOLEAN MouseEnabled = FALSE;
static LONG mouse_x, mouse_y; static LONG mouse_x, mouse_y;
static UINT mouse_width = 0, mouse_height = 0; static UINT mouse_width = 0, mouse_height = 0;
static ULONG PointerStatus;
static UCHAR DefaultCursor[256] = { static UCHAR DefaultCursor[256] = {
0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0xC0, 0x00, 0x00,
0x00, 0xC0, 0x00, 0x00,
0x01, 0x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00, 0x00,
0x76, 0x00, 0x00, 0x00,
0x76, 0x00, 0x00, 0x00,
0x43, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00,
0x01, 0x80, 0x00, 0x00,
0x01, 0x80, 0x00, 0x00,
0x00, 0xC0, 0x00, 0x00,
0x00, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00};
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -125,6 +128,7 @@ MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1,
RECTL MouseRect; RECTL MouseRect;
LONG tmp; LONG tmp;
/* Mouse is not allowed to move if GDI is busy drawing */ /* Mouse is not allowed to move if GDI is busy drawing */
SafetySwitch2 = TRUE; SafetySwitch2 = TRUE;
@ -138,6 +142,12 @@ MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1,
return(FALSE); return(FALSE);
} }
if (SPS_ACCEPT_NOEXCLUDE == PointerStatus)
{
/* Hardware cursor, no need to remove it */
return(FALSE);
}
if (HazardX1 > HazardX2) if (HazardX1 > HazardX2)
{ {
tmp = HazardX2; HazardX2 = HazardX1; HazardX1 = tmp; tmp = HazardX2; HazardX2 = HazardX1; HazardX1 = tmp;
@ -167,11 +177,20 @@ MouseSafetyOnDrawEnd(PSURFOBJ SurfObj, PSURFGDI SurfGDI)
if (SurfObj == NULL) if (SurfObj == NULL)
{ {
SafetySwitch2 = FALSE;
return(FALSE); return(FALSE);
} }
if (SurfObj->iType != STYPE_DEVICE || MouseEnabled == 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(FALSE);
} }
@ -200,15 +219,9 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
PSURFGDI SurfGDI; PSURFGDI SurfGDI;
RECTL MouseRect; RECTL MouseRect;
MSG Msg; MSG Msg;
ULONG j;
LARGE_INTEGER LargeTickCount; LARGE_INTEGER LargeTickCount;
ULONG TickCount; ULONG TickCount;
static ULONG ButtonsDown = 0; 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); KeQueryTickCount(&LargeTickCount);
TickCount = LargeTickCount.u.LowPart; TickCount = LargeTickCount.u.LowPart;
@ -219,8 +232,8 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
} }
dc = DC_HandleToPtr(hDC); dc = DC_HandleToPtr(hDC);
SurfObj = (PSURFOBJ)AccessUserObject(dc->Surface); SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
SurfGDI = (PSURFGDI)AccessInternalObject(dc->Surface); SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
DC_ReleasePtr( hDC ); DC_ReleasePtr( hDC );
/* Compile the total mouse movement change and dispatch button events. */ /* Compile the total mouse movement change and dispatch button events. */
@ -309,8 +322,8 @@ EnableMouse(HDC hDisplayDC)
dc = DC_HandleToPtr(hDisplayDC); dc = DC_HandleToPtr(hDisplayDC);
if( dc ){ if( dc ){
SurfObj = (PSURFOBJ)AccessUserObject(dc->Surface); SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
SurfGDI = (PSURFGDI)AccessInternalObject(dc->Surface); SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
DC_ReleasePtr( hDisplayDC ); DC_ReleasePtr( hDisplayDC );
/* Create the default mouse cursor. */ /* Create the default mouse cursor. */
@ -318,16 +331,23 @@ EnableMouse(HDC hDisplayDC)
mouse_height = 32; mouse_height = 32;
MouseSize.cx = 32; MouseSize.cx = 32;
MouseSize.cy = 64; MouseSize.cy = 64;
hMouseSurf = EngCreateBitmap(MouseSize, 4, BMF_1BPP, 0, DefaultCursor); hMouseSurf = EngCreateBitmap(MouseSize, 4, BMF_1BPP, BMF_TOPDOWN, DefaultCursor);
MouseSurf = (PSURFOBJ)AccessUserObject(hMouseSurf); MouseSurf = (PSURFOBJ)AccessUserObject((ULONG) hMouseSurf);
/* Tell the display driver to set the pointer shape. */ /* Tell the display driver to set the pointer shape. */
SurfGDI->SetPointerShape(SurfObj, MouseSurf, NULL, NULL, 0, 0, 320, 240, #if 0
&MouseRect, 0); mouse_x = SurfObj->sizlBitmap.cx / 2;
mouse_y = SurfObj->sizlBitmap.cy / 2;
#else
mouse_x = 320; mouse_x = 320;
mouse_y = 240; mouse_y = 240;
MouseEnabled = TRUE; #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);
} }
else{ else{
MouseEnabled = FALSE; MouseEnabled = FALSE;

View file

@ -214,6 +214,7 @@ EngCreateBitmap(IN SIZEL Size,
SurfObj->sizlBitmap = Size; SurfObj->sizlBitmap = Size;
SurfObj->iBitmapFormat = Format; SurfObj->iBitmapFormat = Format;
SurfObj->iType = STYPE_BITMAP; SurfObj->iType = STYPE_BITMAP;
SurfObj->fjBitmap = Flags & (BMF_TOPDOWN | BMF_NOZEROINIT);
SurfObj->pvScan0 = SurfObj->pvBits; SurfObj->pvScan0 = SurfObj->pvBits;
InitializeFuncs(SurfGDI, Format); InitializeFuncs(SurfGDI, Format);

View file

@ -1,4 +1,4 @@
/* $Id: dllmain.c,v 1.30 2002/09/17 23:43:28 dwelch Exp $ /* $Id: dllmain.c,v 1.31 2003/03/11 00:21:41 gvg Exp $
* *
* Entry Point for win32k.sys * Entry Point for win32k.sys
*/ */
@ -17,7 +17,7 @@
#include <include/class.h> #include <include/class.h>
#include <include/window.h> #include <include/window.h>
//#define NDEBUG #define NDEBUG
#include <win32k/debug1.h> #include <win32k/debug1.h>
extern SSDT Win32kSSDT[]; extern SSDT Win32kSSDT[];
@ -94,12 +94,16 @@ DllMain (
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
PEPROCESS W32kDeviceProcess;
BOOLEAN BOOLEAN
STDCALL STDCALL
W32kInitialize (VOID) W32kInitialize (VOID)
{ {
DPRINT("in W32kInitialize\n"); DPRINT("in W32kInitialize\n");
W32kDeviceProcess = PsGetCurrentProcess();
InitGdiObjectHandleTable (); InitGdiObjectHandleTable ();
// Create surface used to draw the internal font onto // Create surface used to draw the internal font onto

View file

@ -1,4 +1,4 @@
/* $Id: driver.c,v 1.23 2003/02/25 23:08:53 gvg Exp $ /* $Id: driver.c,v 1.24 2003/03/11 00:21:41 gvg Exp $
* *
* GDI Driver support routines * GDI Driver support routines
* (mostly swiped from Wine) * (mostly swiped from Wine)
@ -11,6 +11,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <windows.h> #include <windows.h>
#include <win32k/driver.h> #include <win32k/driver.h>
#include <win32k/misc.h>
#include <wchar.h> #include <wchar.h>
#include <ddk/winddi.h> #include <ddk/winddi.h>
#include <ddk/ntddvid.h> #include <ddk/ntddvid.h>
@ -67,7 +68,7 @@ PGD_ENABLEDRIVER DRIVER_FindDDIDriver(LPCWSTR Name)
GRAPHICS_DRIVER *Driver = DriverList; GRAPHICS_DRIVER *Driver = DriverList;
NTSTATUS Status; NTSTATUS Status;
WCHAR *FullName; WCHAR *FullName;
WCHAR *p; LPCWSTR p;
BOOL PathSeparatorFound; BOOL PathSeparatorFound;
BOOL DotFound; BOOL DotFound;
UINT Size; UINT Size;
@ -226,6 +227,9 @@ HANDLE DRIVER_FindMPDriver(LPCWSTR Name)
HANDLE DisplayHandle; HANDLE DisplayHandle;
NTSTATUS Status; NTSTATUS Status;
/* Switch to process context in which handle is to be valid */
KeAttachProcess(W32kDeviceProcess);
RtlInitUnicodeStringFromLiteral(&DeviceName, L"\\??\\DISPLAY1"); RtlInitUnicodeStringFromLiteral(&DeviceName, L"\\??\\DISPLAY1");
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&DeviceName, &DeviceName,
@ -238,6 +242,9 @@ HANDLE DRIVER_FindMPDriver(LPCWSTR Name)
&Iosb, &Iosb,
0, 0,
FILE_SYNCHRONOUS_IO_ALERT); FILE_SYNCHRONOUS_IO_ALERT);
KeDetachProcess();
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("ZwOpenFile() failed (Status %lx)\n", Status); DPRINT("ZwOpenFile() failed (Status %lx)\n", Status);