From 73b9ac6994cca644714e1fef6bc8e76a6263eaed Mon Sep 17 00:00:00 2001 From: Jason Filby Date: Sat, 26 May 2001 08:15:40 +0000 Subject: [PATCH] Initial GDI Mouse support, small DC fix svn path=/trunk/; revision=1916 --- reactos/subsys/win32k/eng/bitblt.c | 1 - reactos/subsys/win32k/eng/mouse.c | 135 +++++++++++++++++++++++++++ reactos/subsys/win32k/eng/objects.h | 5 + reactos/subsys/win32k/eng/surface.c | 2 + reactos/subsys/win32k/makefile | 4 +- reactos/subsys/win32k/objects/dc.c | 8 +- reactos/subsys/win32k/objects/text.c | 1 + 7 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 reactos/subsys/win32k/eng/mouse.c diff --git a/reactos/subsys/win32k/eng/bitblt.c b/reactos/subsys/win32k/eng/bitblt.c index 399e706cd2e..6b08034cdbb 100644 --- a/reactos/subsys/win32k/eng/bitblt.c +++ b/reactos/subsys/win32k/eng/bitblt.c @@ -72,7 +72,6 @@ BOOL EngBitBlt(SURFOBJ *Dest, SURFOBJ *Source, { // Destination surface is device managed DestGDI = AccessInternalObjectFromUserObject(Dest); - if (DestGDI->BitBlt!=NULL) { if (Source!=NULL) diff --git a/reactos/subsys/win32k/eng/mouse.c b/reactos/subsys/win32k/eng/mouse.c new file mode 100644 index 00000000000..5413949dc89 --- /dev/null +++ b/reactos/subsys/win32k/eng/mouse.c @@ -0,0 +1,135 @@ +#include +#include +#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 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"); +} diff --git a/reactos/subsys/win32k/eng/objects.h b/reactos/subsys/win32k/eng/objects.h index 331c77f083a..cdc848b2c66 100644 --- a/reactos/subsys/win32k/eng/objects.h +++ b/reactos/subsys/win32k/eng/objects.h @@ -92,6 +92,9 @@ typedef VOID (*PFN_Synchronize)(DHPDEV, 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 BOOL (*PFN_SetPalette)(DHPDEV, PALOBJ*, ULONG, ULONG, ULONG); @@ -113,6 +116,8 @@ typedef struct _SURFGDI { BOOL SynchronizeAccess; PFN_CreateDeviceBitmap CreateDeviceBitmap; PFN_SetPalette SetPalette; + PFN_MovePointer MovePointer; + PFN_SetPointerShape SetPointerShape; } SURFGDI, *PSURFGDI; typedef struct _XFORMGDI { diff --git a/reactos/subsys/win32k/eng/surface.c b/reactos/subsys/win32k/eng/surface.c index 1fdf07ad8b6..3d3c057edcf 100644 --- a/reactos/subsys/win32k/eng/surface.c +++ b/reactos/subsys/win32k/eng/surface.c @@ -190,6 +190,8 @@ BOOL EngAssociateSurface(HSURF Surface, HDEV Dev, ULONG Hooks) SurfGDI->CreateDeviceBitmap = Dc->DriverFunctions.CreateDeviceBitmap; SurfGDI->SetPalette = Dc->DriverFunctions.SetPalette; + SurfGDI->MovePointer = Dc->DriverFunctions.MovePointer; + SurfGDI->SetPointerShape = Dc->DriverFunctions.SetPointerShape; return TRUE; } diff --git a/reactos/subsys/win32k/makefile b/reactos/subsys/win32k/makefile index e4832d9682a..ab6cb5b2273 100644 --- a/reactos/subsys/win32k/makefile +++ b/reactos/subsys/win32k/makefile @@ -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 # @@ -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/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 MISC_OBJECTS = misc/driver.o misc/math.o LDR_OBJECTS = ldr/loader.o diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index 080367743a1..c767049a9b0 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -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 * @@ -188,6 +188,7 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver, HDC hDC = NULL; DRVENABLEDATA DED; HDC hNewDC; + PSURFOBJ SurfObj; /* Check for existing DC object */ if ((NewDC = DC_FindOpenDC(Driver)) != NULL) @@ -294,6 +295,9 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver, NewDC->Surface = NewDC->DriverFunctions.EnableSurface(NewDC->PDev); // hsurf NewDC->w.hPalette = NewDC->DevInfo.hpalDefault; + SurfObj = AccessUserObject(NewDC->Surface); + SurfObj->dhpdev = NewDC->PDev; + DPRINT("Bits per pel: %u\n", NewDC->w.bitsPerPixel); /* Initialize the DC state */ @@ -309,6 +313,8 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver, hDISPLAY_DC = hNewDC; } + TestMouse(); + return hNewDC; Failure: diff --git a/reactos/subsys/win32k/objects/text.c b/reactos/subsys/win32k/objects/text.c index 419a7b43c4c..b42c2008a9e 100644 --- a/reactos/subsys/win32k/objects/text.c +++ b/reactos/subsys/win32k/objects/text.c @@ -708,6 +708,7 @@ W32kTextOut(HDC hDC, // 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 + HSourceGlyph = EngCreateBitmap(bitSize, pitch, BMF_1BPP, 0, glyph->bitmap.buffer); SourceGlyphSurf = AccessUserObject(HSourceGlyph);