mirror of
https://github.com/reactos/reactos.git
synced 2025-07-27 14:53:16 +00:00
Initial GDI Mouse support, small DC fix
svn path=/trunk/; revision=1916
This commit is contained in:
parent
caae64da4b
commit
73b9ac6994
7 changed files with 152 additions and 4 deletions
|
@ -72,7 +72,6 @@ BOOL EngBitBlt(SURFOBJ *Dest, SURFOBJ *Source,
|
||||||
{
|
{
|
||||||
// Destination surface is device managed
|
// Destination surface is device managed
|
||||||
DestGDI = AccessInternalObjectFromUserObject(Dest);
|
DestGDI = AccessInternalObjectFromUserObject(Dest);
|
||||||
|
|
||||||
if (DestGDI->BitBlt!=NULL)
|
if (DestGDI->BitBlt!=NULL)
|
||||||
{
|
{
|
||||||
if (Source!=NULL)
|
if (Source!=NULL)
|
||||||
|
|
135
reactos/subsys/win32k/eng/mouse.c
Normal file
135
reactos/subsys/win32k/eng/mouse.c
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <win32k/dc.h>
|
||||||
|
#include "..\..\services\input\include\mouse.h"
|
||||||
|
#include "objects.h"
|
||||||
|
|
||||||
|
LONG mouse_x, mouse_y;
|
||||||
|
|
||||||
|
VOID MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
LONG mouse_cx = 0, mouse_cy = 0;
|
||||||
|
HDC hDC = RetrieveDisplayHDC();
|
||||||
|
PDC dc = DC_HandleToPtr(hDC);
|
||||||
|
PSURFOBJ SurfObj = AccessUserObject(dc->Surface);
|
||||||
|
PSURFGDI SurfGDI = AccessInternalObject(dc->Surface);
|
||||||
|
RECTL MouseRect;
|
||||||
|
|
||||||
|
PDEVICE_OBJECT ClassDeviceObject = NULL;
|
||||||
|
PFILE_OBJECT FileObject = NULL;
|
||||||
|
NTSTATUS status;
|
||||||
|
UNICODE_STRING ClassName;
|
||||||
|
IO_STATUS_BLOCK ioStatus;
|
||||||
|
KEVENT event;
|
||||||
|
PIRP irp;
|
||||||
|
|
||||||
|
// Compile the total mouse movement change
|
||||||
|
for (i=0; i<InputCount; i++)
|
||||||
|
{
|
||||||
|
mouse_cx += Data[i].LastX;
|
||||||
|
mouse_cy += Data[i].LastY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((mouse_cx != 0) || (mouse_cy != 0))
|
||||||
|
{
|
||||||
|
mouse_x += mouse_cx;
|
||||||
|
mouse_y += mouse_cy;
|
||||||
|
|
||||||
|
if(mouse_x < 0) mouse_x = 0;
|
||||||
|
if(mouse_y < 0) mouse_y = 0;
|
||||||
|
if(mouse_x > 620) mouse_x = 620;
|
||||||
|
if(mouse_y > 460) mouse_y = 460;
|
||||||
|
|
||||||
|
SurfGDI->MovePointer(SurfObj, mouse_x, mouse_y, &MouseRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS ConnectMouseClassDriver()
|
||||||
|
{
|
||||||
|
PDEVICE_OBJECT ClassDeviceObject = NULL;
|
||||||
|
PFILE_OBJECT FileObject = NULL;
|
||||||
|
NTSTATUS status;
|
||||||
|
UNICODE_STRING ClassName;
|
||||||
|
IO_STATUS_BLOCK ioStatus;
|
||||||
|
KEVENT event;
|
||||||
|
PIRP irp;
|
||||||
|
GDI_INFORMATION GDIInformation;
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&ClassName, L"\\Device\\MouseClass");
|
||||||
|
|
||||||
|
status = IoGetDeviceObjectPointer(&ClassName, FILE_READ_ATTRIBUTES, &FileObject, &ClassDeviceObject);
|
||||||
|
|
||||||
|
if(status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
DbgPrint("Win32k: Could not connect to mouse class driver\n");
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect our callback to the class driver
|
||||||
|
|
||||||
|
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
||||||
|
|
||||||
|
GDIInformation.CallBack = MouseGDICallBack;
|
||||||
|
|
||||||
|
irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_MOUSE_CONNECT,
|
||||||
|
ClassDeviceObject, &GDIInformation, sizeof(CLASS_INFORMATION), NULL, 0, TRUE, &event, &ioStatus);
|
||||||
|
|
||||||
|
status = IoCallDriver(ClassDeviceObject, irp);
|
||||||
|
|
||||||
|
if (status == STATUS_PENDING) {
|
||||||
|
KeWaitForSingleObject(&event, Suspended, KernelMode, FALSE, NULL);
|
||||||
|
} else {
|
||||||
|
ioStatus.Status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ioStatus.Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestMouse()
|
||||||
|
{
|
||||||
|
HDC hDC = RetrieveDisplayHDC(RetrieveDisplayHDC());
|
||||||
|
PDC dc = DC_HandleToPtr(hDC);
|
||||||
|
PSURFOBJ SurfObj = AccessUserObject(dc->Surface);
|
||||||
|
PSURFGDI SurfGDI = AccessInternalObject(dc->Surface);
|
||||||
|
BOOL txt;
|
||||||
|
|
||||||
|
BRUSHOBJ Brush;
|
||||||
|
HBITMAP hMouseSurf;
|
||||||
|
PSURFOBJ MouseSurf;
|
||||||
|
SIZEL MouseSize;
|
||||||
|
POINTL ZeroPoint;
|
||||||
|
RECTL MouseRect;
|
||||||
|
|
||||||
|
// Draw a test mouse cursor
|
||||||
|
Brush.iSolidColor = 1;
|
||||||
|
EngLineTo(SurfObj, NULL, &Brush, 0, 0, 15, 0, NULL, 0);
|
||||||
|
EngLineTo(SurfObj, NULL, &Brush, 0, 0, 0, 15, NULL, 0);
|
||||||
|
EngLineTo(SurfObj, NULL, &Brush, 0, 15, 15, 0, NULL, 0);
|
||||||
|
Brush.iSolidColor = 15;
|
||||||
|
EngLineTo(SurfObj, NULL, &Brush, 1, 1, 13, 1, NULL, 0);
|
||||||
|
EngLineTo(SurfObj, NULL, &Brush, 1, 1, 1, 13, NULL, 0);
|
||||||
|
EngLineTo(SurfObj, NULL, &Brush, 1, 13, 13, 1, NULL, 0);
|
||||||
|
|
||||||
|
// Create the bitmap for the mouse cursor data
|
||||||
|
MouseSize.cx = 16;
|
||||||
|
MouseSize.cy = 16;
|
||||||
|
hMouseSurf = EngCreateBitmap(MouseSize, 16, BMF_4BPP, 0, NULL);
|
||||||
|
MouseSurf = AccessUserObject(hMouseSurf);
|
||||||
|
|
||||||
|
// Capture the cursor we drew in the mouse cursor buffer
|
||||||
|
ZeroPoint.x = 0;
|
||||||
|
ZeroPoint.y = 0;
|
||||||
|
MouseRect.top = 0;
|
||||||
|
MouseRect.left = 0;
|
||||||
|
MouseRect.bottom = 16;
|
||||||
|
MouseRect.right = 16;
|
||||||
|
EngBitBlt(MouseSurf, SurfObj, NULL, NULL, NULL, &MouseRect, &ZeroPoint, NULL, NULL, NULL, 0);
|
||||||
|
SurfGDI->SetPointerShape(SurfObj, MouseSurf, NULL, NULL, 0, 0, 50, 50, &MouseRect, 0);
|
||||||
|
|
||||||
|
// Connect the mouse class driver to the GDI
|
||||||
|
mouse_x = 50;
|
||||||
|
mouse_y = 50;
|
||||||
|
ConnectMouseClassDriver();
|
||||||
|
|
||||||
|
DbgPrint("OK\n");
|
||||||
|
}
|
|
@ -92,6 +92,9 @@ typedef VOID (*PFN_Synchronize)(DHPDEV, PRECTL);
|
||||||
|
|
||||||
typedef VOID (*PFN_MovePointer)(PSURFOBJ, LONG, LONG, PRECTL);
|
typedef VOID (*PFN_MovePointer)(PSURFOBJ, LONG, LONG, PRECTL);
|
||||||
|
|
||||||
|
typedef VOID (*PFN_SetPointerShape)(PSURFOBJ, PSURFOBJ, PSURFOBJ, PXLATEOBJ,
|
||||||
|
LONG, LONG, LONG, LONG, PRECTL, ULONG);
|
||||||
|
|
||||||
typedef HBITMAP (*PFN_CreateDeviceBitmap)(DHPDEV, SIZEL, ULONG);
|
typedef HBITMAP (*PFN_CreateDeviceBitmap)(DHPDEV, SIZEL, ULONG);
|
||||||
|
|
||||||
typedef BOOL (*PFN_SetPalette)(DHPDEV, PALOBJ*, ULONG, ULONG, ULONG);
|
typedef BOOL (*PFN_SetPalette)(DHPDEV, PALOBJ*, ULONG, ULONG, ULONG);
|
||||||
|
@ -113,6 +116,8 @@ typedef struct _SURFGDI {
|
||||||
BOOL SynchronizeAccess;
|
BOOL SynchronizeAccess;
|
||||||
PFN_CreateDeviceBitmap CreateDeviceBitmap;
|
PFN_CreateDeviceBitmap CreateDeviceBitmap;
|
||||||
PFN_SetPalette SetPalette;
|
PFN_SetPalette SetPalette;
|
||||||
|
PFN_MovePointer MovePointer;
|
||||||
|
PFN_SetPointerShape SetPointerShape;
|
||||||
} SURFGDI, *PSURFGDI;
|
} SURFGDI, *PSURFGDI;
|
||||||
|
|
||||||
typedef struct _XFORMGDI {
|
typedef struct _XFORMGDI {
|
||||||
|
|
|
@ -190,6 +190,8 @@ BOOL EngAssociateSurface(HSURF Surface, HDEV Dev, ULONG Hooks)
|
||||||
|
|
||||||
SurfGDI->CreateDeviceBitmap = Dc->DriverFunctions.CreateDeviceBitmap;
|
SurfGDI->CreateDeviceBitmap = Dc->DriverFunctions.CreateDeviceBitmap;
|
||||||
SurfGDI->SetPalette = Dc->DriverFunctions.SetPalette;
|
SurfGDI->SetPalette = Dc->DriverFunctions.SetPalette;
|
||||||
|
SurfGDI->MovePointer = Dc->DriverFunctions.MovePointer;
|
||||||
|
SurfGDI->SetPointerShape = Dc->DriverFunctions.SetPointerShape;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.30 2001/05/02 12:33:42 jfilby Exp $
|
# $Id: makefile,v 1.31 2001/05/26 08:15:39 jfilby Exp $
|
||||||
#
|
#
|
||||||
# WIN32K.SYS build spec
|
# WIN32K.SYS build spec
|
||||||
#
|
#
|
||||||
|
@ -15,7 +15,7 @@ CFLAGS = -I.
|
||||||
|
|
||||||
ENG_OBJECTS= eng/debug.o eng/mem.o eng/brush.o eng/bitblt.o eng/clip.o eng/copybits.o \
|
ENG_OBJECTS= eng/debug.o eng/mem.o eng/brush.o eng/bitblt.o eng/clip.o eng/copybits.o \
|
||||||
eng/device.o eng/handle.o eng/lineto.o eng/paint.o eng/palette.o \
|
eng/device.o eng/handle.o eng/lineto.o eng/paint.o eng/palette.o \
|
||||||
eng/surface.o eng/xlate.o eng/transblt.o
|
eng/surface.o eng/xlate.o eng/transblt.o eng/mouse.o
|
||||||
MAIN_OBJECTS = main/dllmain.o
|
MAIN_OBJECTS = main/dllmain.o
|
||||||
MISC_OBJECTS = misc/driver.o misc/math.o
|
MISC_OBJECTS = misc/driver.o misc/math.o
|
||||||
LDR_OBJECTS = ldr/loader.o
|
LDR_OBJECTS = ldr/loader.o
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: dc.c,v 1.21 2001/05/07 22:03:27 chorns Exp $
|
/* $Id: dc.c,v 1.22 2001/05/26 08:15:40 jfilby Exp $
|
||||||
*
|
*
|
||||||
* DC.C - Device context functions
|
* DC.C - Device context functions
|
||||||
*
|
*
|
||||||
|
@ -188,6 +188,7 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
|
||||||
HDC hDC = NULL;
|
HDC hDC = NULL;
|
||||||
DRVENABLEDATA DED;
|
DRVENABLEDATA DED;
|
||||||
HDC hNewDC;
|
HDC hNewDC;
|
||||||
|
PSURFOBJ SurfObj;
|
||||||
|
|
||||||
/* Check for existing DC object */
|
/* Check for existing DC object */
|
||||||
if ((NewDC = DC_FindOpenDC(Driver)) != NULL)
|
if ((NewDC = DC_FindOpenDC(Driver)) != NULL)
|
||||||
|
@ -294,6 +295,9 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
|
||||||
NewDC->Surface = NewDC->DriverFunctions.EnableSurface(NewDC->PDev); // hsurf
|
NewDC->Surface = NewDC->DriverFunctions.EnableSurface(NewDC->PDev); // hsurf
|
||||||
NewDC->w.hPalette = NewDC->DevInfo.hpalDefault;
|
NewDC->w.hPalette = NewDC->DevInfo.hpalDefault;
|
||||||
|
|
||||||
|
SurfObj = AccessUserObject(NewDC->Surface);
|
||||||
|
SurfObj->dhpdev = NewDC->PDev;
|
||||||
|
|
||||||
DPRINT("Bits per pel: %u\n", NewDC->w.bitsPerPixel);
|
DPRINT("Bits per pel: %u\n", NewDC->w.bitsPerPixel);
|
||||||
|
|
||||||
/* Initialize the DC state */
|
/* Initialize the DC state */
|
||||||
|
@ -309,6 +313,8 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
|
||||||
hDISPLAY_DC = hNewDC;
|
hDISPLAY_DC = hNewDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TestMouse();
|
||||||
|
|
||||||
return hNewDC;
|
return hNewDC;
|
||||||
|
|
||||||
Failure:
|
Failure:
|
||||||
|
|
|
@ -708,6 +708,7 @@ W32kTextOut(HDC hDC,
|
||||||
|
|
||||||
// We should create the bitmap out of the loop at the biggest possible glyph size
|
// We should create the bitmap out of the loop at the biggest possible glyph size
|
||||||
// Then use memset with 0 to clear it and sourcerect to limit the work of the transbitblt
|
// Then use memset with 0 to clear it and sourcerect to limit the work of the transbitblt
|
||||||
|
|
||||||
HSourceGlyph = EngCreateBitmap(bitSize, pitch, BMF_1BPP, 0, glyph->bitmap.buffer);
|
HSourceGlyph = EngCreateBitmap(bitSize, pitch, BMF_1BPP, 0, glyph->bitmap.buffer);
|
||||||
SourceGlyphSurf = AccessUserObject(HSourceGlyph);
|
SourceGlyphSurf = AccessUserObject(HSourceGlyph);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue