implemented support for double clicks
authorThomas Bluemel <thomas@reactsoft.com>
Thu, 28 Aug 2003 16:33:22 +0000 (16:33 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Thu, 28 Aug 2003 16:33:22 +0000 (16:33 +0000)
svn path=/trunk/; revision=5898

reactos/lib/user32/misc/stubs.c
reactos/lib/user32/windows/input.c
reactos/ntoskrnl/include/internal/ex.h
reactos/subsys/win32k/eng/mouse.c
reactos/subsys/win32k/ntuser/winsta.c

index 028c8b4..87c2f67 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.38 2003/08/28 14:22:05 weiden Exp $
+/* $Id: stubs.c,v 1.39 2003/08/28 16:33:22 weiden Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS user32.dll
@@ -142,17 +142,6 @@ EnableScrollBar(
   return FALSE;
 }
 
-/*
- * @unimplemented
- */
-UINT
-STDCALL
-GetDoubleClickTime(VOID)
-{
-  UNIMPLEMENTED;
-  return 0;
-}
-
 
 /*
  * @unimplemented
@@ -372,18 +361,6 @@ ScrollWindowEx(
   return 0;
 }
 
-/*
- * @unimplemented
- */
-WINBOOL
-STDCALL
-SetDoubleClickTime(
-  UINT uInterval)
-{
-  UNIMPLEMENTED;
-  return FALSE;
-}
-
 
 /*
  * @unimplemented
index bfe60d3..6c22905 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: input.c,v 1.15 2003/08/28 14:22:05 weiden Exp $
+/* $Id: input.c,v 1.16 2003/08/28 16:33:22 weiden Exp $
  *
  * PROJECT:         ReactOS user32.dll
  * FILE:            lib/user32/windows/input.c
@@ -100,6 +100,18 @@ GetAsyncKeyState(int vKey)
 }
 
 
+/*
+ * @unimplemented
+ */
+UINT
+STDCALL
+GetDoubleClickTime(VOID)
+{
+  UNIMPLEMENTED;
+  return 0;
+}
+
+
 /*
  * @unimplemented
  */
@@ -310,6 +322,19 @@ OemKeyScan(WORD wOemChar)
 }
 
 
+/*
+ * @unimplemented
+ */
+WINBOOL
+STDCALL
+SetDoubleClickTime(
+  UINT uInterval)
+{
+  UNIMPLEMENTED;
+  return FALSE;
+}
+
+
 /*
  * @unimplemented
  */
index 2edb2bc..908b8db 100644 (file)
@@ -39,6 +39,12 @@ typedef struct _SYSTEM_CURSORINFO
   FAST_MUTEX CursorMutex;
   CURSORCLIP_INFO CursorClipInfo;
   SYSCURSOR SystemCursors[SYSCURSORCOUNT];
+  UINT DblClickSpeed;
+  UINT DblClickWidth;
+  UINT DblClickHeight;
+  DWORD LastBtnDown;
+  LONG LastBtnDownX;
+  LONG LastBtnDownY;
 } SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO;
 
 typedef struct _WINSTATION_OBJECT
index 558ad5e..73ff67d 100644 (file)
@@ -16,7 +16,7 @@
  *  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.37 2003/08/28 14:22:05 weiden Exp $
+/* $Id: mouse.c,v 1.38 2003/08/28 16:33:22 weiden Exp $
  *
  * PROJECT:          ReactOS kernel
  * PURPOSE:          Mouse
@@ -135,6 +135,40 @@ IntCheckClipCursor(LONG *x, LONG *y, PSYSTEM_CURSORINFO CurInfo)
   return TRUE;
 }
 
+BOOL FASTCALL
+IntDetectDblClick(PSYSTEM_CURSORINFO CurInfo, DWORD TickCount)
+{
+  LONG dX, dY;
+  BOOL res = ((TickCount - CurInfo->LastBtnDown) < CurInfo->DblClickSpeed);
+  if(res)
+  {
+    /* check if the second click is within the DblClickWidth and DblClickHeight values */
+    dX = CurInfo->LastBtnDownX - CurInfo->x;
+    dY = CurInfo->LastBtnDownY - CurInfo->y;
+    if(dX < 0) dX = -dX;
+    if(dY < 0) dY = -dY;
+    
+    res = (dX <= CurInfo->DblClickWidth) &&
+          (dY <= CurInfo->DblClickHeight);
+
+    if(res)
+      CurInfo->LastBtnDown = 0; /* prevent sending 2 or more DBLCLK messages */
+    else
+    {
+      CurInfo->LastBtnDown = TickCount;
+      CurInfo->LastBtnDownX = CurInfo->x;
+      CurInfo->LastBtnDownY = CurInfo->y;
+    }
+  }
+  else
+  {
+    CurInfo->LastBtnDown = TickCount;
+    CurInfo->LastBtnDownX = CurInfo->x;
+    CurInfo->LastBtnDownY = CurInfo->y;
+  }
+  return res;
+}
+
 BOOL FASTCALL
 IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap)
 {
@@ -418,27 +452,48 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
     
     if (Data[i].ButtonFlags != 0)
     {
-    
-      if ((0 != Data[i].LastX) || (0 != Data[i].LastY))
-      {
-        MsqInsertSystemMessage(&Msg, FALSE);
-        MouseMoveAdded = TRUE;
-      }
-      
+
       if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_DOWN) > 0)
       {
+        /* insert WM_MOUSEMOVE messages before Button down messages */
+        if ((0 != Data[i].LastX) || (0 != Data[i].LastY))
+        {
+          MsqInsertSystemMessage(&Msg, FALSE);
+          MouseMoveAdded = TRUE;
+        }
        Msg.wParam  = CurInfo->SwapButtons ? MK_RBUTTON : MK_LBUTTON;
-        Msg.message = CurInfo->SwapButtons ? WM_RBUTTONDOWN : WM_LBUTTONDOWN;
+       if(IntDetectDblClick(CurInfo, TickCount))
+          Msg.message = CurInfo->SwapButtons ? WM_RBUTTONDBLCLK : WM_LBUTTONDBLCLK;
+        else
+          Msg.message = CurInfo->SwapButtons ? WM_RBUTTONDOWN : WM_LBUTTONDOWN;
       }
       if ((Data[i].ButtonFlags & MOUSE_MIDDLE_BUTTON_DOWN) > 0)
       {
+        /* insert WM_MOUSEMOVE messages before Button down messages */
+        if ((0 != Data[i].LastX) || (0 != Data[i].LastY))
+        {
+          MsqInsertSystemMessage(&Msg, FALSE);
+          MouseMoveAdded = TRUE;
+        }
        Msg.wParam  = MK_MBUTTON;
-        Msg.message = WM_MBUTTONDOWN;
+       if(IntDetectDblClick(CurInfo, TickCount))
+         Msg.message = WM_MBUTTONDBLCLK;
+       else
+          Msg.message = WM_MBUTTONDOWN;
       }
       if ((Data[i].ButtonFlags & MOUSE_RIGHT_BUTTON_DOWN) > 0)
       {
+        /* insert WM_MOUSEMOVE messages before Button down messages */
+        if ((0 != Data[i].LastX) || (0 != Data[i].LastY))
+        {
+          MsqInsertSystemMessage(&Msg, FALSE);
+          MouseMoveAdded = TRUE;
+        }
        Msg.wParam  = CurInfo->SwapButtons ? MK_LBUTTON : MK_RBUTTON;
-        Msg.message = CurInfo->SwapButtons ? WM_LBUTTONDOWN : WM_RBUTTONDOWN;
+       if(IntDetectDblClick(CurInfo, TickCount))
+         Msg.message = CurInfo->SwapButtons ? WM_LBUTTONDBLCLK : WM_RBUTTONDBLCLK;
+       else
+          Msg.message = CurInfo->SwapButtons ? WM_LBUTTONDOWN : WM_RBUTTONDOWN;
       }
 
       if ((Data[i].ButtonFlags & MOUSE_LEFT_BUTTON_UP) > 0)
@@ -458,6 +513,15 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount)
       }
 
       MsqInsertSystemMessage(&Msg, FALSE);
+      
+      /* insert WM_MOUSEMOVE messages after Button up messages */
+      if(!MouseMoveAdded && ((0 != Data[i].LastX) || (0 != Data[i].LastY)))
+      {
+        Msg.wParam = ButtonsDown;
+        Msg.message = WM_MOUSEMOVE;
+        MsqInsertSystemMessage(&Msg, FALSE);
+        MouseMoveAdded = TRUE;
+      }
     }
   }
 
index 573ce01..2845cd9 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: winsta.c,v 1.31 2003/08/28 14:22:05 weiden Exp $
+/* $Id: winsta.c,v 1.32 2003/08/28 16:33:22 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -354,14 +354,22 @@ NtUserCreateWindowStation(PUNICODE_STRING lpszWindowStationName,
     
   ExInitializeFastMutex(&WinStaObject->SystemCursor.CursorMutex);
   WinStaObject->SystemCursor.Enabled = FALSE;
-  WinStaObject->SystemCursor.SwapButtons = FALSE;
   WinStaObject->SystemCursor.CurrentCursor = 0;
   WinStaObject->SystemCursor.x = (LONG)0;
   WinStaObject->SystemCursor.y = (LONG)0;
+  WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE;
+  WinStaObject->SystemCursor.LastBtnDown = 0;
+  
+  /* FIXME Obtain the following information from the registry */
+  WinStaObject->SystemCursor.SwapButtons = FALSE;
   WinStaObject->SystemCursor.SafetySwitch = FALSE;
   WinStaObject->SystemCursor.SafetySwitch2 = TRUE;
-  WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE;
+  WinStaObject->SystemCursor.DblClickSpeed = 500;
+  WinStaObject->SystemCursor.DblClickWidth = 4;
+  WinStaObject->SystemCursor.DblClickHeight = 4;
   
+  /* FIXME tell user32 to load the cursors from it's rosource file or
+           to load the user's cursor scheme */
   WinStaObject->SystemCursor.SystemCursors[0].hCursor = (HANDLE)1;
   WinStaObject->SystemCursor.SystemCursors[0].cx = 32;
   WinStaObject->SystemCursor.SystemCursors[0].cy = 32;