Misc. user fixes.
authorDavid Welch <welch@cwcom.net>
Tue, 17 Sep 2002 23:43:29 +0000 (23:43 +0000)
committerDavid Welch <welch@cwcom.net>
Tue, 17 Sep 2002 23:43:29 +0000 (23:43 +0000)
svn path=/trunk/; revision=3516

14 files changed:
reactos/subsys/win32k/eng/mouse.c
reactos/subsys/win32k/include/guicheck.h
reactos/subsys/win32k/include/mouse.h
reactos/subsys/win32k/include/window.h
reactos/subsys/win32k/include/winsta.h
reactos/subsys/win32k/main/dllmain.c
reactos/subsys/win32k/ntuser/guicheck.c
reactos/subsys/win32k/ntuser/input.c
reactos/subsys/win32k/ntuser/message.c
reactos/subsys/win32k/ntuser/painting.c
reactos/subsys/win32k/ntuser/window.c
reactos/subsys/win32k/ntuser/winpos.c
reactos/subsys/win32k/ntuser/winsta.c
reactos/subsys/win32k/objects/dc.c

index 661096a..03b0c48 100644 (file)
@@ -55,11 +55,11 @@ 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 = (PSURFOBJ)AccessUserObject(dc->Surface);
-  PSURFGDI SurfGDI = (PSURFGDI)AccessInternalObject(dc->Surface);
-  RECTL MouseRect; */
+  HDC hDC = W32kGetScreenDC();
+  PDC dc;
+  PSURFOBJ SurfObj;
+  PSURFGDI SurfGDI;
+  RECTL MouseRect; 
 
   PDEVICE_OBJECT ClassDeviceObject = NULL;
   PFILE_OBJECT FileObject = NULL;
@@ -69,6 +69,15 @@ VOID MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
   KEVENT event;
   PIRP irp;
 
+  if (hDC == 0)
+    {
+      return;
+    }
+
+  dc = DC_HandleToPtr(hDC);
+  SurfObj = (PSURFOBJ)AccessUserObject(dc->Surface);
+  SurfGDI = (PSURFGDI)AccessInternalObject(dc->Surface);
+
   // Compile the total mouse movement change
   for (i=0; i<InputCount; i++)
   {
@@ -87,53 +96,13 @@ VOID MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
     if(mouse_y > 460) mouse_y = 460;
 
     if((SafetySwitch == FALSE) && (SafetySwitch2 == FALSE)) ;
-/*      SurfGDI->MovePointer(SurfObj, mouse_x, mouse_y, &MouseRect); */
+    SurfGDI->MovePointer(SurfObj, mouse_x, mouse_y, &MouseRect); 
   }
 }
 
-NTSTATUS ConnectMouseClassDriver()
-{
-   PDEVICE_OBJECT ClassDeviceObject = NULL;
-   PFILE_OBJECT FileObject = NULL;
-   NTSTATUS status;
-   UNICODE_STRING ClassName = UNICODE_STRING_INITIALIZER(L"\\Device\\MouseClass");
-   IO_STATUS_BLOCK ioStatus;
-   KEVENT event;
-   PIRP irp;
-   GDI_INFORMATION GDIInformation;
-
-   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()
+VOID EnableMouse(HDC hDisplayDC)
 {
-  HDC hDC = RetrieveDisplayHDC();
-  PDC dc = DC_HandleToPtr(hDC);
+  PDC dc = DC_HandleToPtr(hDisplayDC);
   PSURFOBJ SurfObj = (PSURFOBJ)AccessUserObject(dc->Surface);
   PSURFGDI SurfGDI = (PSURFGDI)AccessInternalObject(dc->Surface);
   BOOL txt;
@@ -182,10 +151,8 @@ void TestMouse()
   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();
+  mouse_x = 320;
+  mouse_y = 240;
   MouseEnabled = TRUE;
 }
-*/
+
index 5d4ba60..60fca50 100644 (file)
@@ -6,6 +6,8 @@
 
 VOID
 W32kGuiCheck(VOID);
+VOID
+W32kGraphicsCheck(VOID);
 
 #endif /* __WIN32K_GUICHECK_H */
 
index 734a67e..abd734e 100644 (file)
@@ -3,5 +3,6 @@
 
 INT MouseSafetyOnDrawStart(PSURFOBJ SurfObj, PSURFGDI SurfGDI, LONG HazardX1, LONG HazardY1, LONG HazardX2, LONG HazardY2);
 INT MouseSafetyOnDrawEnd(PSURFOBJ SurfObj, PSURFGDI SurfGDI);
+VOID EnableMouse(HDC hDisplayDC);
 
 #endif /* __WIN32K_MOUSE_H */
index ff17a3f..66f123c 100644 (file)
@@ -15,18 +15,11 @@ typedef struct _PROPERTY
   ATOM Atom;
 } PROPERTY, *PPROPERTY;
 
-typedef struct _INTERNALPOS
-{
-  RECT NormalRect;
-  POINT IconPos;
-  POINT MaxPos;
-  HWND IconTitle;
-} INTERNALPOS, *PINTERNALPOS;
+VOID
+WinPosSetupInternalPos(VOID);
 
 typedef struct _WINDOW_OBJECT
 {
-  /* Internal position. */
-  PINTERNALPOS InternalPos;
   /* Pointer to the window class. */
   PWNDCLASS_OBJECT Class;
   /* Extended style. */
index 0bf8505..96eef24 100644 (file)
@@ -34,6 +34,10 @@ LRESULT CALLBACK
 W32kDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
 PDESKTOP_OBJECT
 W32kGetActiveDesktop(VOID);
+VOID
+W32kInitializeDesktopGraphics(VOID);
+HDC
+W32kGetScreenDC(VOID);
 
 #endif /* __WIN32K_WINSTA_H */
 
index 2d5b938..e9934a7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dllmain.c,v 1.29 2002/09/08 10:23:51 chorns Exp $
+/* $Id: dllmain.c,v 1.30 2002/09/17 23:43:28 dwelch Exp $
  *
  *  Entry Point for win32k.sys
  */
@@ -54,6 +54,8 @@ DllMain (
    */
   PsEstablishWin32Callouts(0, 0, 0, 0, sizeof(W32THREAD), sizeof(W32PROCESS));
 
+  WinPosSetupInternalPos();
+
   Status = InitWindowStationImpl();
   if (!NT_SUCCESS(Status))
   {
index 407dfa5..130d054 100644 (file)
@@ -1,4 +1,4 @@
- /* $Id: guicheck.c,v 1.8 2002/09/08 10:23:52 chorns Exp $
+ /* $Id: guicheck.c,v 1.9 2002/09/17 23:43:28 dwelch Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
 #define NDEBUG
 #include <debug.h>
 
+/* GLOBALS *******************************************************************/
+
+static ULONG NrGuiApplicationsRunning = 0;
+
 /* FUNCTIONS *****************************************************************/
 
 VOID
-W32kGuiCheck(VOID)
+W32kGraphicsCheck(VOID)
 {
+  if (NrGuiApplicationsRunning == 0)
+    {
+      W32kInitializeDesktopGraphics();
+    }
+  NrGuiApplicationsRunning++;
+}
+
+VOID
+W32kGuiCheck(VOID)
+{ 
   if (PsGetWin32Process() == NULL)
     {
       NTSTATUS Status;
index 37ffa63..2177643 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: input.c,v 1.2 2002/08/20 20:37:19 hyperion Exp $
+/* $Id: input.c,v 1.3 2002/09/17 23:43:28 dwelch Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
 #include <include/error.h>
 #include <include/winsta.h>
 #include <include/msgqueue.h>
+#include "../../drivers/input/include/mouse.h"
 
 #define NDEBUG
 #include <debug.h>
 
 /* GLOBALS *******************************************************************/
 
+static HANDLE MouseDeviceHandle;
 static HANDLE KeyboardThreadHandle;
 static CLIENT_ID KeyboardThreadId;
 static HANDLE KeyboardDeviceHandle;
 static KEVENT InputThreadsStart;
 static BOOLEAN InputThreadsRunning = FALSE;
 
+VOID MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount);
+
 /* FUNCTIONS *****************************************************************/
 
 NTSTATUS STDCALL STATIC
@@ -139,6 +143,14 @@ NTSTATUS
 InitInputImpl(VOID)
 {
   NTSTATUS Status;
+  UNICODE_STRING MouseDeviceName;
+  OBJECT_ATTRIBUTES MouseObjectAttributes;
+  IO_STATUS_BLOCK Iosb;
+  PIRP Irp;
+  PFILE_OBJECT FileObject;
+  GDI_INFORMATION GdiInfo;
+  KEVENT IoEvent;
+  PIO_STACK_LOCATION StackPtr;
 
   KeInitializeEvent(&InputThreadsStart, NotificationEvent, FALSE);
 
@@ -154,7 +166,70 @@ InitInputImpl(VOID)
       DbgPrint("W32K: Failed to create keyboard thread.\n");
       NtClose(KeyboardThreadHandle);
     }
-  return(STATUS_SUCCESS);
+
+  /*
+   * Connect to the mouse class driver.
+   */  
+  RtlInitUnicodeStringFromLiteral(&MouseDeviceName, L"\\??\\MouseClass");
+  InitializeObjectAttributes(&MouseObjectAttributes,
+                            &MouseDeviceName,
+                            0,
+                            NULL,
+                            NULL);
+  Status = NtOpenFile(&MouseDeviceHandle,
+                     FILE_ALL_ACCESS,
+                     &MouseObjectAttributes,
+                     &Iosb,
+                     0,
+                     0);
+  if (!NT_SUCCESS(Status))
+    {
+      DbgPrint("W32K: Failed to open mouse.\n");
+      return(Status);
+    }
+  Status = ObReferenceObjectByHandle(MouseDeviceHandle,
+                                    FILE_READ_DATA | FILE_WRITE_DATA,
+                                    IoFileObjectType,
+                                    KernelMode,
+                                    (PVOID *) &FileObject,
+                                    NULL);
+   
+   if (!NT_SUCCESS(Status))
+     {
+       DbgPrint("W32K: Failed to reference mouse file object.\n");
+       return(Status);
+     }
+   KeInitializeEvent(&IoEvent, FALSE, NotificationEvent);
+   GdiInfo.CallBack = MouseGDICallBack;
+   Irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_MOUSE_CONNECT,
+                                      FileObject->DeviceObject,
+                                      &GdiInfo,
+                                      sizeof(GdiInfo),
+                                      NULL,
+                                      0,
+                                      TRUE,
+                                      &FileObject->Event,
+                                      &Iosb);
+   StackPtr = IoGetNextIrpStackLocation(Irp);
+   StackPtr->FileObject = FileObject;
+   StackPtr->DeviceObject = FileObject->DeviceObject;
+   StackPtr->Parameters.DeviceIoControl.InputBufferLength = sizeof(GdiInfo);
+   StackPtr->Parameters.DeviceIoControl.OutputBufferLength = 0;
+
+   Status = IoCallDriver(FileObject->DeviceObject, Irp);
+   if (Status == STATUS_PENDING)
+     {
+       KeWaitForSingleObject(&FileObject->Event, Executive, KernelMode, FALSE,
+                            NULL);
+       Status = Iosb.Status;
+     }
+   if (!NT_SUCCESS(Status))
+     {
+       DbgPrint("W32K: Failed to connect to mouse driver.\n");
+       return(Status);
+     }
+
+   return(STATUS_SUCCESS);
 }
 
 NTSTATUS
index 1f205f3..ecebd23 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: message.c,v 1.9 2002/08/26 23:20:54 dwelch Exp $
+/* $Id: message.c,v 1.10 2002/09/17 23:43:28 dwelch Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -42,7 +42,7 @@ W32kCleanupMessageImpl(VOID)
 
 
 LRESULT STDCALL
-NtUserDispatchMessage(LPMSG lpMsg)
+NtUserDispatchMessage(CONST MSG* lpMsg)
 {
   LRESULT Result;
   ULONG PaintingFlag;
index 45f3873..2b4410d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: painting.c,v 1.5 2002/08/31 23:18:47 dwelch Exp $
+/* $Id: painting.c,v 1.6 2002/09/17 23:43:28 dwelch Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -733,7 +733,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
 }
 
 BOOL STDCALL
-NtUserEndPaint(HWND hWnd, PAINTSTRUCT* lPs)
+NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* lPs)
 {
   NtUserReleaseDC(hWnd, lPs->hdc);
   /* FIXME: Show claret. */
index 1fcb566..69db8bd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: window.c,v 1.17 2002/09/08 10:23:52 chorns Exp $
+/* $Id: window.c,v 1.18 2002/09/17 23:43:28 dwelch Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -348,6 +348,7 @@ NtUserCreateWindowEx(DWORD dwExStyle,
 
   /* Initialize gui state if necessary. */
   W32kGuiCheck();
+  W32kGraphicsCheck();
 
   if (!RtlCreateUnicodeString(&WindowName, lpWindowName->Buffer))
     {
index 6fdefa9..432981e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: winpos.c,v 1.4 2002/08/31 23:18:47 dwelch Exp $
+/* $Id: winpos.c,v 1.5 2002/09/17 23:43:28 dwelch Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -33,6 +33,8 @@
 
 #define SWP_EX_PAINTSELF 0x0002
 
+ATOM AtomInternalPos = NULL;
+
 /* FUNCTIONS *****************************************************************/
 
 #define HAS_DLGFRAME(Style, ExStyle) \
        (((Style) & WS_THICKFRAME) && \
         !((Style) & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)
 
+VOID
+WinPosSetupInternalPos(VOID)
+{
+  AtomInternalPos = NtAddAtom(L"SysIP", (ATOM*)(PULONG)&AtomInternalPos);
+}
+
+BOOL STDCALL
+NtUserGetClientOrigin(HWND hWnd, LPPOINT Point)
+{
+  PWINDOW_OBJECT WindowObject;
+
+  WindowObject = W32kGetWindowObject(hWnd);
+  if (WindowObject == NULL)
+    {
+      return(FALSE);
+    }
+  Point->x = WindowObject->ClientRect.left;
+  Point->y = WindowObject->ClientRect.right;
+  return(TRUE);
+}
+
 BOOL
 WinPosActivateOtherWindow(PWINDOW_OBJECT Window)
 {
@@ -62,7 +85,8 @@ WinPosCreateIconTitle(PWINDOW_OBJECT WindowObject)
 BOOL STATIC
 WinPosShowIconTitle(PWINDOW_OBJECT WindowObject, BOOL Show)
 {
-  PINTERNALPOS InternalPos = WindowObject->InternalPos;
+  PINTERNALPOS InternalPos = NtUserGetProp(WindowObject->Self,
+                                          AtomInternalPos);
   PWINDOW_OBJECT IconWindow;
   NTSTATUS Status;
 
@@ -105,30 +129,31 @@ WinPosShowIconTitle(PWINDOW_OBJECT WindowObject, BOOL Show)
 PINTERNALPOS STATIC
 WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, POINT pt, PRECT RestoreRect)
 {
-  if (WindowObject->InternalPos == NULL)
+  PINTERNALPOS InternalPos = NtUserGetProp(WindowObject->Self, 
+                                          AtomInternalPos);
+  if (InternalPos == NULL)
     {
-      WindowObject->InternalPos = 
+      InternalPos = 
        ExAllocatePool(NonPagedPool, sizeof(INTERNALPOS));
-      WindowObject->InternalPos->IconTitle = 0;
-      WindowObject->InternalPos->NormalRect = WindowObject->WindowRect;
-      WindowObject->InternalPos->IconPos.x = 
-       WindowObject->InternalPos->MaxPos.x = 0xFFFFFFFF;
-      WindowObject->InternalPos->IconPos.y = 
-       WindowObject->InternalPos->MaxPos.y = 0xFFFFFFFF;
+      NtUserSetProp(WindowObject->Self, AtomInternalPos, InternalPos);
+      InternalPos->IconTitle = 0;
+      InternalPos->NormalRect = WindowObject->WindowRect;
+      InternalPos->IconPos.x = InternalPos->MaxPos.x = 0xFFFFFFFF;
+      InternalPos->IconPos.y = InternalPos->MaxPos.y = 0xFFFFFFFF;
     }
   if (WindowObject->Style & WS_MINIMIZE)
     {
-      WindowObject->InternalPos->IconPos = pt;
+      InternalPos->IconPos = pt;
     }
   else if (WindowObject->Style & WS_MAXIMIZE)
     {
-      WindowObject->InternalPos->MaxPos = pt;
+      InternalPos->MaxPos = pt;
     }
   else if (RestoreRect != NULL)
     {
-      WindowObject->InternalPos->NormalRect = *RestoreRect;
+      InternalPos->NormalRect = *RestoreRect;
     }
-  return(WindowObject->InternalPos);
+  return(InternalPos);
 }
 
 UINT
@@ -270,7 +295,7 @@ WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
   MinMax.ptMaxSize.x += 2 * XInc;
   MinMax.ptMaxSize.y += 2 * YInc;
 
-  Pos = Window->InternalPos;
+  Pos = NtUserGetProp(Window->Self, AtomInternalPos);
   if (Pos != NULL)
     {
       MinMax.ptMaxPosition = Pos->MaxPos;
index 46af76b..e3484ea 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: winsta.c,v 1.9 2002/09/08 10:23:52 chorns Exp $
+/* $Id: winsta.c,v 1.10 2002/09/17 23:43:28 dwelch Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -43,6 +43,8 @@ STATIC HDESK InputDesktopHandle = NULL;
 STATIC PDESKTOP_OBJECT InputDesktop = NULL;
 STATIC PWINSTATION_OBJECT InputWindowStation = NULL;
 
+static HDC ScreenDeviceContext = NULL;
+
 /* FUNCTIONS *****************************************************************/
 
 PDESKTOP_OBJECT
@@ -836,6 +838,20 @@ NtUserSwitchDesktop(HDESK hDesktop)
   return(TRUE);
 }
 
+VOID
+W32kInitializeDesktopGraphics(VOID)
+{
+  ScreenDeviceContext = W32kCreateDC(L"DISPLAY", NULL, NULL, NULL);
+  GDIOBJ_MarkObjectGlobal(ScreenDeviceContext);
+  EnableMouse(ScreenDeviceContext);
+}
+
+HDC
+W32kGetScreenDC(VOID)
+{
+  return(ScreenDeviceContext);
+}
+
 LRESULT CALLBACK
 W32kDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
index f146aaa..5ddaabb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dc.c,v 1.38 2002/09/08 10:23:52 chorns Exp $
+/* $Id: dc.c,v 1.39 2002/09/17 23:43:29 dwelch Exp $
  *
  * DC.C - Device context functions
  *
@@ -311,6 +311,7 @@ HDC STDCALL  W32kCreateDC(LPCWSTR  Driver,
   W32kSetTextColor(hNewDC, RGB(0, 0, 0));
   W32kSetTextAlign(hNewDC, TA_BASELINE);
   DC_ReleasePtr( hNewDC );
+
   return hNewDC;
 
 Failure:
@@ -1162,6 +1163,8 @@ HDC  DC_AllocDC(LPCWSTR  Driver)
        NewDC->w.xformVport2World = NewDC->w.xformWorld2Wnd;
        NewDC->w.vport2WorldValid = TRUE;
 
+       NewDC->w.hFont = W32kGetStockObject(SYSTEM_FONT);
+
        GDIOBJ_UnlockObj( hDC, GO_DC_MAGIC );
        return  hDC;
 }