---
 xserver/hw/xwin/InitInput.c               |   10 ++++--
 xserver/hw/xwin/win.h                     |    3 +
 xserver/hw/xwin/winkeybd.c                |   22 +++++++------
 xserver/hw/xwin/winmouse.c                |   50 ++++++++++++++++++++++--------
 xserver/hw/xwin/winmultiwindowwndproc.c   |    6 +--
 xserver/hw/xwin/winwin32rootlesswndproc.c |    6 +--
 xserver/hw/xwin/winwndproc.c              |    8 +---
 7 files changed, 71 insertions(+), 34 deletions(-)

Index: xorg-git/xserver/hw/xwin/InitInput.c
===================================================================
--- xorg-git.orig/xserver/hw/xwin/InitInput.c
+++ xorg-git/xserver/hw/xwin/InitInput.c
@@ -102,6 +102,13 @@ ProcessInputEvents (void)
 }
 
 
+void DDXRingBell(int volume, int pitch, int duration)
+{
+  /* winKeybdBell is used instead */
+  return;
+}
+
+
 int
 TimeSinceLastInputEvent ()
 {
@@ -144,8 +151,7 @@ InitInput (int argc, char *argv[])
   RegisterPointerDevice (pMouse);
   RegisterKeyboardDevice (pKeyboard);
 
-  miRegisterPointerDevice (screenInfo.screens[0], pMouse);
-  mieqInit ((DevicePtr)pKeyboard, (DevicePtr)pMouse);
+  mieqInit ();
 
   /* Initialize the mode key states */
   winInitializeModeKeyStates ();
Index: xorg-git/xserver/hw/xwin/win.h
===================================================================
--- xorg-git.orig/xserver/hw/xwin/win.h
+++ xorg-git/xserver/hw/xwin/win.h
@@ -1004,6 +1004,9 @@ winMouseButtonsHandle (ScreenPtr pScreen
 		       int iEventType, int iButton,
 		       WPARAM wParam);
 
+void
+winEnqueueMotion(int x, int y);
+
 #ifdef XWIN_NATIVEGDI
 /*
  * winnativegdi.c
Index: xorg-git/xserver/hw/xwin/winkeybd.c
===================================================================
--- xorg-git.orig/xserver/hw/xwin/winkeybd.c
+++ xorg-git/xserver/hw/xwin/winkeybd.c
@@ -580,8 +580,6 @@ winKeybdReleaseKeys ()
 void
 winSendKeyEvent (DWORD dwKey, Bool fDown)
 {
-  xEvent			xCurrentEvent;
-
   /*
    * When alt-tabing between screens we can get phantom key up messages
    * Here we only pass them through it we think we should!
@@ -590,14 +588,20 @@ winSendKeyEvent (DWORD dwKey, Bool fDown
 
   /* Update the keyState map */
   g_winKeyState[dwKey] = fDown;
-  
-  ZeroMemory (&xCurrentEvent, sizeof (xCurrentEvent));
 
-  xCurrentEvent.u.u.type = fDown ? KeyPress : KeyRelease;
-  xCurrentEvent.u.keyButtonPointer.time =
-    g_c32LastInputEventTime = GetTickCount ();
-  xCurrentEvent.u.u.detail = dwKey + MIN_KEYCODE;
-  mieqEnqueue (&xCurrentEvent);
+  EventList *events = InitEventList(GetMaximumEventsNum());
+  int i, nevents;
+  nevents = GetKeyboardEvents(events, inputInfo.keyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE);
+
+  for (i = 0; i < nevents; i++)
+    mieqEnqueue(inputInfo.keyboard, events[i].event);
+
+  FreeEventList(events, GetMaximumEventsNum());
+
+#if CYGDEBUG
+  ErrorF("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n",
+          dwKey, fDown, nevents);
+#endif
 }
 
 BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
Index: xorg-git/xserver/hw/xwin/winmouse.c
===================================================================
--- xorg-git.orig/xserver/hw/xwin/winmouse.c
+++ xorg-git/xserver/hw/xwin/winmouse.c
@@ -100,7 +100,6 @@ winMouseProc (DeviceIntPtr pDeviceInt, i
       InitPointerDeviceStruct (pDevice,
 			       map,
 			       lngMouseButtons + lngWheelEvents,
-			       GetMotionHistory,
 			       winMouseCtrl,
 			       GetMotionHistorySize(),
 			       2);
@@ -221,19 +220,21 @@ winMouseWheel (ScreenPtr pScreen, int iD
 void
 winMouseButtonsSendEvent (int iEventType, int iButton)
 {
-  xEvent		xCurrentEvent;
+  EventList *events = InitEventList(GetMaximumEventsNum());
+  int i, nevents;
 
-  /* Load an xEvent and enqueue the event */
-  xCurrentEvent.u.u.type = iEventType;
-#if defined(XFree86Server)
-  if (g_winMouseButtonMap)
-    xCurrentEvent.u.u.detail = g_winMouseButtonMap[iButton];
-  else
+  nevents = GetPointerEvents(events, inputInfo.pointer, iEventType, iButton,
+			     POINTER_RELATIVE, 0, 0, NULL);
+
+  for (i = 0; i < nevents; i++)
+    mieqEnqueue(inputInfo.pointer, events[i].event);
+
+  FreeEventList(events, GetMaximumEventsNum());
+
+#if CYGDEBUG
+  ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n",
+          iEventType, iButton, nevents);
 #endif
-  xCurrentEvent.u.u.detail = iButton;
-  xCurrentEvent.u.keyButtonPointer.time
-    = g_c32LastInputEventTime = GetTickCount ();
-  mieqEnqueue (&xCurrentEvent);
 }
 
 
@@ -339,3 +340,28 @@ winMouseButtonsHandle (ScreenPtr pScreen
 
   return 0;
 }
+
+/**
+ * Enqueue a motion event.
+ *
+ *  XXX: miPointerMove does exactly this, but is static :-( (and uses a static buffer)
+ *
+ */
+void winEnqueueMotion(int x, int y)
+{
+  int i, nevents;
+  int valuators[2];
+
+  EventList *events = InitEventList(GetMaximumEventsNum());
+
+  valuators[0] = x;
+  valuators[1] = y;
+  nevents = GetPointerEvents(events, inputInfo.pointer, MotionNotify, 0,
+			     POINTER_ABSOLUTE, 0, 2, valuators);
+
+  for (i = 0; i < nevents; i++)
+    mieqEnqueue(inputInfo.pointer, events[i].event);
+
+  FreeEventList(events, GetMaximumEventsNum());
+}
+
Index: xorg-git/xserver/hw/xwin/winmultiwindowwndproc.c
===================================================================
--- xorg-git.orig/xserver/hw/xwin/winmultiwindowwndproc.c
+++ xorg-git/xserver/hw/xwin/winmultiwindowwndproc.c
@@ -535,9 +535,9 @@ winTopLevelWindowProc (HWND hwnd, UINT m
 	}
 
       /* Deliver absolute cursor position to X Server */
-      miPointerAbsoluteCursor (ptMouse.x - s_pScreenInfo->dwXOffset,
-			       ptMouse.y - s_pScreenInfo->dwYOffset,
-			       g_c32LastInputEventTime = GetTickCount ());
+      winEnqueueMotion(ptMouse.x - s_pScreenInfo->dwXOffset, 
+		       ptMouse.y - s_pScreenInfo->dwYOffset);
+
       return 0;
       
     case WM_NCMOUSEMOVE:
Index: xorg-git/xserver/hw/xwin/winwin32rootlesswndproc.c
===================================================================
--- xorg-git.orig/xserver/hw/xwin/winwin32rootlesswndproc.c
+++ xorg-git/xserver/hw/xwin/winwin32rootlesswndproc.c
@@ -571,9 +571,9 @@ winMWExtWMWindowProc (HWND hwnd, UINT me
 	}
 
       /* Deliver absolute cursor position to X Server */
-      miPointerAbsoluteCursor (ptMouse.x - pScreenInfo->dwXOffset,
-			       ptMouse.y - pScreenInfo->dwYOffset,
-			       g_c32LastInputEventTime = GetTickCount ());
+      winEnqueueMotion(ptMouse.x - pScreenInfo->dwXOffset, 
+		       ptMouse.y - pScreenInfo->dwYOffset);
+
       return 0;
       
     case WM_NCMOUSEMOVE:
Index: xorg-git/xserver/hw/xwin/winwndproc.c
===================================================================
--- xorg-git.orig/xserver/hw/xwin/winwndproc.c
+++ xorg-git/xserver/hw/xwin/winwndproc.c
@@ -764,9 +764,8 @@ winWindowProc (HWND hwnd, UINT message, 
 	}
       
       /* Deliver absolute cursor position to X Server */
-      miPointerAbsoluteCursor (GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
-			       GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset,
-			       g_c32LastInputEventTime = GetTickCount ());
+      winEnqueueMotion(GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
+		       GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset);
       return 0;
 
     case WM_NCMOUSEMOVE:
@@ -929,8 +928,7 @@ winWindowProc (HWND hwnd, UINT message, 
 	    point.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
 	    
 	    /* Deliver absolute cursor position to X Server */
-	    miPointerAbsoluteCursor (point.x, point.y,
-				     g_c32LastInputEventTime = GetTickCount());
+	    winEnqueueMotion(point.x , point.y);
 
 	    /* Check if a button was released but we didn't see it */
 	    GetCursorPos (&point);

-- 

