Merged mouse dll into USER.

diff --git a/Makefile.in b/Makefile.in
index dc61207..c7aab69 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -31,7 +31,6 @@
 	dlls/advapi32 \
 	dlls/crtdll \
 	dlls/kernel \
-	dlls/mouse \
 	dlls/ntdll \
 	files \
 	graphics \
@@ -97,7 +96,6 @@
 	console/console.o \
 	dlls/advapi32/advapi32.o \
 	dlls/crtdll/crtdll.o \
-	dlls/mouse/mouse.o \
 	dlls/ntdll/ntdll.o \
 	files/files.o \
 	graphics/graphics.o \
diff --git a/configure b/configure
index 7a73d1c..5c3d1b8 100755
--- a/configure
+++ b/configure
@@ -6208,7 +6208,6 @@
 dlls/imm32/Makefile
 dlls/kernel/Makefile
 dlls/lzexpand/Makefile
-dlls/mouse/Makefile
 dlls/mpr/Makefile
 dlls/msacm/Makefile
 dlls/msacm32/Makefile
@@ -6442,7 +6441,6 @@
 dlls/imm32/Makefile
 dlls/kernel/Makefile
 dlls/lzexpand/Makefile
-dlls/mouse/Makefile
 dlls/mpr/Makefile
 dlls/msacm/Makefile
 dlls/msacm32/Makefile
diff --git a/configure.in b/configure.in
index 2bd3ae2..0a8d8c2 100644
--- a/configure.in
+++ b/configure.in
@@ -1002,7 +1002,6 @@
 dlls/imm32/Makefile
 dlls/kernel/Makefile
 dlls/lzexpand/Makefile
-dlls/mouse/Makefile
 dlls/mpr/Makefile
 dlls/msacm/Makefile
 dlls/msacm32/Makefile
diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index 5834ef6..ea9bdf1 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -85,6 +85,7 @@
 	keyboard \
 	lzexpand \
 	mmsystem \
+	mouse \
 	msvideo \
 	ole2 \
 	ole2conv \
@@ -303,7 +304,7 @@
 liburlmon.@LIBEXT@: urlmon/liburlmon.@LIBEXT@
 	$(RM) $@ && $(LN_S) urlmon/liburlmon.@LIBEXT@ $@
 
-libuser32.@LIBEXT@ libuser.@LIBEXT@ libkeyboard.@LIBEXT@ libddeml.@LIBEXT@ libdisplay.@LIBEXT@: user/libuser32.@LIBEXT@
+libuser32.@LIBEXT@ libuser.@LIBEXT@ libkeyboard.@LIBEXT@ libddeml.@LIBEXT@ libdisplay.@LIBEXT@ libmouse.@LIBEXT@: user/libuser32.@LIBEXT@
 	$(RM) $@ && $(LN_S) user/libuser32.@LIBEXT@ $@
 
 libversion.@LIBEXT@ libver.@LIBEXT@: version/libversion.@LIBEXT@
diff --git a/dlls/dinput/Makefile.in b/dlls/dinput/Makefile.in
index b0abec7..edca4c9 100644
--- a/dlls/dinput/Makefile.in
+++ b/dlls/dinput/Makefile.in
@@ -4,6 +4,7 @@
 VPATH     = @srcdir@
 MODULE    = dinput
 SOVERSION = 1.0
+IMPORTS   = user32
 
 SPEC_SRCS = dinput.spec
 
diff --git a/dlls/dinput/dinput.spec b/dlls/dinput/dinput.spec
index a7daa79..eb3894d 100644
--- a/dlls/dinput/dinput.spec
+++ b/dlls/dinput/dinput.spec
@@ -1,6 +1,8 @@
 name dinput
 type win32
 
+import user32.dll
+
 @ stdcall DirectInputCreateA(long long ptr ptr) DirectInputCreateA
 @ stub DirectInputCreateW
 @ stdcall DllCanUnloadNow() DINPUT_DllCanUnloadNow
diff --git a/dlls/mouse/.cvsignore b/dlls/mouse/.cvsignore
deleted file mode 100644
index 7f188e4..0000000
--- a/dlls/mouse/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-mouse.spec.c
-mouserc.s
diff --git a/dlls/mouse/Makefile.in b/dlls/mouse/Makefile.in
deleted file mode 100644
index baf19e4..0000000
--- a/dlls/mouse/Makefile.in
+++ /dev/null
@@ -1,21 +0,0 @@
-DEFS      = @DLLFLAGS@ -D__WINE__
-TOPSRCDIR = @top_srcdir@
-TOPOBJDIR = ../..
-SRCDIR    = @srcdir@
-VPATH     = @srcdir@
-MODULE    = mouse
-WRCEXTRA  = -s -w16 -pmouse
-SPEC_SRCS = mouse.spec
-
-C_SRCS = \
-	mouse_main.c
-
-RC_SRCS = \
-	mouserc.rc
-
-all: $(MODULE).o
-
-@MAKE_RULES@
-
-### Dependencies:
-
diff --git a/dlls/ttydrv/ttydrv_main.c b/dlls/ttydrv/ttydrv_main.c
index 0c7f056..2ac0abe 100644
--- a/dlls/ttydrv/ttydrv_main.c
+++ b/dlls/ttydrv/ttydrv_main.c
@@ -12,7 +12,6 @@
 #include "gdi.h"
 #include "message.h"
 #include "monitor.h"
-#include "mouse.h"
 #include "user.h"
 #include "win.h"
 #include "debugtools.h"
@@ -43,7 +42,6 @@
     TTYDRV_MOUSE_Init,
     TTYDRV_MOUSE_SetCursor,
     TTYDRV_MOUSE_MoveCursor,
-    TTYDRV_MOUSE_EnableWarpPointer,
     /* screen saver functions */
     TTYDRV_GetScreenSaveActive,
     TTYDRV_SetScreenSaveActive,
diff --git a/dlls/user/.cvsignore b/dlls/user/.cvsignore
index 2c62a4c..102a6ef 100644
--- a/dlls/user/.cvsignore
+++ b/dlls/user/.cvsignore
@@ -3,4 +3,5 @@
 Makefile
 disp.s
 libuser32.so.1.0
+mouserc.s
 thunk.glue.c
diff --git a/dlls/user/Makefile.in b/dlls/user/Makefile.in
index e627057..95b2cb4 100644
--- a/dlls/user/Makefile.in
+++ b/dlls/user/Makefile.in
@@ -4,24 +4,27 @@
 VPATH     = @srcdir@
 MODULE    = user32
 SOVERSION = 1.0
-WRCEXTRA  = -s -w16 -pdisplay
-ALTNAMES  = user keyboard ddeml display
+WRCEXTRA  = -w16
+ALTNAMES  = user keyboard ddeml display mouse
 
 SPEC_SRCS = \
 	user32.spec \
 	user.spec \
 	keyboard.spec \
 	ddeml.spec \
-	display.spec
+	display.spec \
+	mouse.spec
 
 C_SRCS = \
 	ddeml.c \
 	display.c \
+	mouse.c \
 	user_main.c \
 	thunk.c
 
 RC_SRCS = \
-	disp.rc
+	disp.rc \
+	mouserc.rc
 
 GLUE = thunk.c
 
diff --git a/dlls/user/display.c b/dlls/user/display.c
index e7005f8..5eb9ad7 100644
--- a/dlls/user/display.c
+++ b/dlls/user/display.c
@@ -6,7 +6,6 @@
  */
 
 #include "debugtools.h"
-#include "mouse.h"
 #include "windef.h"
 #include "user.h"
 #include "wine/winuser16.h"
diff --git a/dlls/user/display.spec b/dlls/user/display.spec
index d1fdab9..a325063 100644
--- a/dlls/user/display.spec
+++ b/dlls/user/display.spec
@@ -1,6 +1,6 @@
 name	display
 type	win16
-rsrc	display
+rsrc	disp
 
 1   stub BitBlt
 2   stub ColorInfo
diff --git a/dlls/mouse/mouse_main.c b/dlls/user/mouse.c
similarity index 60%
rename from dlls/mouse/mouse_main.c
rename to dlls/user/mouse.c
index ccfc08a..a74a8a3 100644
--- a/dlls/mouse/mouse_main.c
+++ b/dlls/user/mouse.c
@@ -12,16 +12,28 @@
 #include "builtin16.h"
 #include "module.h"
 #include "mouse.h"
-#include "monitor.h"
-#include "user.h"
 #include "windef.h"
 #include "wingdi.h"
 #include "winuser.h"
-#include "win.h"
 #include "wine/winbase16.h"
 
 DEFAULT_DEBUG_CHANNEL(event);
 
+#include "pshpack1.h"
+typedef struct _MOUSEINFO
+{
+    BYTE msExist;
+    BYTE msRelative;
+    WORD msNumButtons;
+    WORD msRate;
+    WORD msXThreshold;
+    WORD msYThreshold;
+    WORD msXRes;
+    WORD msYRes;
+    WORD msMouseCommPort;
+} MOUSEINFO, *LPMOUSEINFO;
+#include "poppack.h"
+
 /**********************************************************************/
 
 static LPMOUSE_EVENT_PROC DefMouseEventProc = NULL;
@@ -49,17 +61,9 @@
  */
 VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc)
 {
-    static BOOL initDone = FALSE;
-    
     THUNK_Free( (FARPROC)DefMouseEventProc );
     DefMouseEventProc = lpMouseEventProc;
-
-    /* Now initialize the mouse driver */
-    if (initDone == FALSE)
-    {
-        USER_Driver->pInitMouse();
-    	initDone = TRUE;
-    }
+    USER_Driver->pInitMouse( lpMouseEventProc );
 }
 
 static VOID WINAPI MOUSE_CallMouseEventProc( FARPROC16 proc,
@@ -96,41 +100,5 @@
 {
     THUNK_Free( (FARPROC)DefMouseEventProc );
     DefMouseEventProc = 0;
-}
-
-/***********************************************************************
- *           MOUSE_SendEvent
- */
-void MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY, 
-                      DWORD keyState, DWORD time, HWND hWnd )
-{
-    int width  = MONITOR_GetWidth (&MONITOR_PrimaryMonitor);
-    int height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
-    int iWndsLocks;
-    WINE_MOUSEEVENT wme;
-
-    if ( !DefMouseEventProc ) return;
-
-    TRACE("(%04lX,%ld,%ld)\n", mouseStatus, posX, posY );
-
-    if (mouseStatus & MOUSEEVENTF_MOVE) {
-      if (mouseStatus & MOUSEEVENTF_ABSOLUTE) {
-	/* Relative mouse movements seems not to be scaled as absolute ones */
-	posX = (((long)posX << 16) + width-1)  / width;
-	posY = (((long)posY << 16) + height-1) / height;
-      }
-    }
-
-    wme.magic    = WINE_MOUSEEVENT_MAGIC;
-    wme.time     = time;
-    wme.hWnd     = hWnd;
-    wme.keyState = keyState;
-    
-    USER_Driver->pEnableWarpPointer(FALSE);
-    /* To avoid deadlocks, we have to suspend all locks on windows structures
-       before the program control is passed to the mouse driver */
-    iWndsLocks = WIN_SuspendWndsLock();
-    DefMouseEventProc( mouseStatus, posX, posY, 0, (DWORD)&wme );
-    WIN_RestoreWndsLock(iWndsLocks);
-    USER_Driver->pEnableWarpPointer(TRUE);
+    USER_Driver->pInitMouse( 0 );
 }
diff --git a/dlls/mouse/mouse.spec b/dlls/user/mouse.spec
similarity index 95%
rename from dlls/mouse/mouse.spec
rename to dlls/user/mouse.spec
index e9b2ca4..ef4d8dc 100644
--- a/dlls/mouse/mouse.spec
+++ b/dlls/user/mouse.spec
@@ -1,6 +1,6 @@
 name	mouse
 type	win16
-rsrc	mouse
+rsrc	mouserc
 
 1 pascal16 Inquire(ptr) MOUSE_Inquire
 2 pascal16 Enable(segptr) WIN16_MOUSE_Enable
diff --git a/dlls/mouse/mouserc.rc b/dlls/user/mouserc.rc
similarity index 100%
rename from dlls/mouse/mouserc.rc
rename to dlls/user/mouserc.rc
diff --git a/dlls/user/user_main.c b/dlls/user/user_main.c
index 55748a2..6318cce 100644
--- a/dlls/user/user_main.c
+++ b/dlls/user/user_main.c
@@ -14,7 +14,6 @@
 #include "keyboard.h"
 #include "menu.h"
 #include "message.h"
-#include "mouse.h"
 #include "queue.h"
 #include "spy.h"
 #include "sysmetrics.h"
diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c
index 38b7e76..fb00206 100644
--- a/dlls/x11drv/x11drv_main.c
+++ b/dlls/x11drv/x11drv_main.c
@@ -54,7 +54,6 @@
     X11DRV_MOUSE_Init,
     X11DRV_MOUSE_SetCursor,
     X11DRV_MOUSE_MoveCursor,
-    X11DRV_MOUSE_EnableWarpPointer,
     /* screen saver functions */
     X11DRV_GetScreenSaveActive,
     X11DRV_SetScreenSaveActive,
diff --git a/include/mouse.h b/include/mouse.h
index 4fe6fb8..302c4ee 100644
--- a/include/mouse.h
+++ b/include/mouse.h
@@ -8,29 +8,7 @@
 #define __WINE_MOUSE_H
 
 #include "windef.h"
-
-struct tagCURSORICONINFO;
-
-#include "pshpack1.h"
-typedef struct _MOUSEINFO
-{
-    BYTE msExist;
-    BYTE msRelative;
-    WORD msNumButtons;
-    WORD msRate;
-    WORD msXThreshold;
-    WORD msYThreshold;
-    WORD msXRes;
-    WORD msYRes;
-    WORD msMouseCommPort;
-} MOUSEINFO, *LPMOUSEINFO;
-#include "poppack.h"
-
-typedef VOID (CALLBACK *LPMOUSE_EVENT_PROC)(DWORD,DWORD,DWORD,DWORD,DWORD);
-
-WORD WINAPI MOUSE_Inquire(LPMOUSEINFO lpMouseInfo);
-VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc);
-VOID WINAPI MOUSE_Disable(VOID);
+#include "user.h"
 
 /* Wine internals */
 
@@ -44,9 +22,6 @@
 
 } WINE_MOUSEEVENT;
 
-extern void MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
-			     DWORD keyState, DWORD time, HWND hWnd );
-
 /***********************************
  * 	MouseWheel support (defines)
  */
diff --git a/include/ttydrv.h b/include/ttydrv.h
index ba86666..142f89a 100644
--- a/include/ttydrv.h
+++ b/include/ttydrv.h
@@ -18,6 +18,7 @@
 #include "wingdi.h"
 #include "wine/winuser16.h"
 #include "wine/wingdi16.h"
+#include "user.h"
 
 struct tagBITMAPOBJ;
 struct tagCLASS;
@@ -170,10 +171,9 @@
 
 /* TTY mouse driver */
 
-extern void TTYDRV_MOUSE_Init();
+extern void TTYDRV_MOUSE_Init(LPMOUSE_EVENT_PROC);
 extern void TTYDRV_MOUSE_SetCursor(struct tagCURSORICONINFO *lpCursor);
 extern void TTYDRV_MOUSE_MoveCursor(WORD wAbsX, WORD wAbsY);
-extern LONG TTYDRV_MOUSE_EnableWarpPointer(BOOL bEnable);
 
 /* TTY windows driver */
 
diff --git a/include/user.h b/include/user.h
index 741428a..ec5775b 100644
--- a/include/user.h
+++ b/include/user.h
@@ -37,6 +37,8 @@
   BOOL auto_repeat;
 } KEYBOARD_CONFIG;
 
+typedef VOID (CALLBACK *LPMOUSE_EVENT_PROC)(DWORD,DWORD,DWORD,DWORD,DWORD);
+
 typedef struct tagUSER_DRIVER {
     /* event functions */
     void   (*pSynchronize)(void);
@@ -56,10 +58,9 @@
     void   (*pGetKeyboardConfig)(KEYBOARD_CONFIG *);
     void   (*pSetKeyboardConfig)(KEYBOARD_CONFIG *, DWORD);
     /* mouse functions */
-    void   (*pInitMouse)(void);
+    void   (*pInitMouse)(LPMOUSE_EVENT_PROC);
     void   (*pSetCursor)(struct tagCURSORICONINFO *);
     void   (*pMoveCursor)(WORD, WORD);
-    LONG   (*pEnableWarpPointer)(BOOL);
     /* screen saver functions */
     BOOL   (*pGetScreenSaveActive)(void);
     void   (*pSetScreenSaveActive)(BOOL);
@@ -74,4 +75,7 @@
 WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
                             DWORD dwFlags, HMODULE16 hModule );
 
+VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc);
+VOID WINAPI MOUSE_Disable(VOID);
+
 #endif  /* __WINE_USER_H */
diff --git a/include/x11drv.h b/include/x11drv.h
index ca1deb4..ccbd4ec 100644
--- a/include/x11drv.h
+++ b/include/x11drv.h
@@ -15,9 +15,10 @@
 # include <X11/extensions/XShm.h>
 #endif /* defined(HAVE_LIBXXSHM) */
 
-#include "gdi.h"
-#include "winbase.h"
 #include "windef.h"
+#include "winbase.h"
+#include "gdi.h"
+#include "user.h"
 
 #define MAX_PIXELFORMATS 8
 
@@ -393,10 +394,11 @@
 
 /* X11 mouse driver */
 
-extern void X11DRV_MOUSE_Init();
+extern void X11DRV_MOUSE_Init(LPMOUSE_EVENT_PROC);
 extern void X11DRV_MOUSE_SetCursor(struct tagCURSORICONINFO *lpCursor);
 extern void X11DRV_MOUSE_MoveCursor(WORD wAbsX, WORD wAbsY);
-extern LONG X11DRV_MOUSE_EnableWarpPointer(BOOL bEnable);
+extern void X11DRV_MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
+                                    DWORD keyState, DWORD time, HWND hWnd );
 
 /* X11 windows driver */
 
diff --git a/windows/ttydrv/mouse.c b/windows/ttydrv/mouse.c
index 9e74c4d..1804256 100644
--- a/windows/ttydrv/mouse.c
+++ b/windows/ttydrv/mouse.c
@@ -21,16 +21,8 @@
 }
 
 /***********************************************************************
- *           TTYDRV_MOUSE_EnableWarpPointer
- */
-LONG TTYDRV_MOUSE_EnableWarpPointer(BOOL bEnable)
-{
-  return 0;
-}
-
-/***********************************************************************
  *           TTYDRV_MOUSE_Init
  */
-void TTYDRV_MOUSE_Init()
+void TTYDRV_MOUSE_Init(LPMOUSE_EVENT_PROC proc)
 {
 }
diff --git a/windows/x11drv/event.c b/windows/x11drv/event.c
index 660ea0c..229873b 100644
--- a/windows/x11drv/event.c
+++ b/windows/x11drv/event.c
@@ -694,15 +694,15 @@
     int yOffset = pWnd? pWnd->rectWindow.top  : 0;
     WIN_ReleaseWndPtr(pWnd);
     
-    MOUSE_SendEvent( MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, 
-		     xOffset + event->x, yOffset + event->y,
-		     X11DRV_EVENT_XStateToKeyState( event->state ), 
-		     event->time, hWnd);
+    X11DRV_MOUSE_SendEvent( MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, 
+                            xOffset + event->x, yOffset + event->y,
+                            X11DRV_EVENT_XStateToKeyState( event->state ), 
+                            event->time, hWnd);
   } else {
-    MOUSE_SendEvent( MOUSEEVENTF_MOVE,
-                     event->x_root, event->y_root,
-                     X11DRV_EVENT_XStateToKeyState( event->state ), 
-                     event->time, hWnd);
+    X11DRV_MOUSE_SendEvent( MOUSEEVENTF_MOVE,
+                            event->x_root, event->y_root,
+                            X11DRV_EVENT_XStateToKeyState( event->state ), 
+                            event->time, hWnd);
   }
 }
 
@@ -753,10 +753,10 @@
         break;
   }
   
-  MOUSE_SendEvent( statusCodes[buttonNum], 
-		   xOffset + event->x, yOffset + event->y,
-		   MAKEWPARAM(keystate,wData),
-		   event->time, hWnd);
+  X11DRV_MOUSE_SendEvent( statusCodes[buttonNum], 
+                          xOffset + event->x, yOffset + event->y,
+                          MAKEWPARAM(keystate,wData),
+                          event->time, hWnd);
 }
 
 
@@ -801,9 +801,9 @@
       return;
   }
 
-  MOUSE_SendEvent( statusCodes[buttonNum], 
-		   xOffset + event->x, yOffset + event->y,
-		   keystate, event->time, hWnd);
+  X11DRV_MOUSE_SendEvent( statusCodes[buttonNum], 
+                          xOffset + event->x, yOffset + event->y,
+                          keystate, event->time, hWnd);
 }
 
 
diff --git a/windows/x11drv/mouse.c b/windows/x11drv/mouse.c
index 1a09917..eab97ec 100644
--- a/windows/x11drv/mouse.c
+++ b/windows/x11drv/mouse.c
@@ -11,17 +11,19 @@
 #include "callback.h"
 #include "debugtools.h"
 #include "mouse.h"
+#include "monitor.h"
 #include "win.h"
 #include "windef.h"
 #include "x11drv.h"
 
-DEFAULT_DEBUG_CHANNEL(cursor)
+DEFAULT_DEBUG_CHANNEL(cursor);
 
 /**********************************************************************/
 
 Cursor X11DRV_MOUSE_XCursor = None;    /* Current X cursor */
 
 static LONG X11DRV_MOUSE_WarpPointer = 0;  /* hack; see DISPLAY_MoveCursor */
+static LPMOUSE_EVENT_PROC DefMouseEventProc = NULL;
 
 /***********************************************************************
  *		X11DRV_MOUSE_DoSetCursor
@@ -240,33 +242,65 @@
 }
 
 /***********************************************************************
- *           X11DRV_MOUSE_EnableWarpPointer
- */
-LONG X11DRV_MOUSE_EnableWarpPointer(BOOL bEnable)
-{
-  if (bEnable)
-    return InterlockedIncrement( &X11DRV_MOUSE_WarpPointer );
-  else
-    return InterlockedDecrement( &X11DRV_MOUSE_WarpPointer );
-}
-
-/***********************************************************************
  *           X11DRV_MOUSE_Init
  */
-void X11DRV_MOUSE_Init()
+void X11DRV_MOUSE_Init( LPMOUSE_EVENT_PROC proc )
 {
-  Window root, child;
-  int root_x, root_y, child_x, child_y;
-  unsigned int KeyState;
-  
-  /* Get the current mouse position and simulate an absolute mouse
-     movement to initialize the mouse global variables */
-  TSXQueryPointer( display, X11DRV_GetXRootWindow(), &root, &child,
-		   &root_x, &root_y, &child_x, &child_y, &KeyState);
+    static int init_done;
 
-  MOUSE_SendEvent(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
-		  root_x, root_y,
-		  X11DRV_EVENT_XStateToKeyState(KeyState),
-		  GetTickCount(),
-		  0);
+    DefMouseEventProc = proc;
+
+    if (!init_done)
+    {
+        Window root, child;
+        int root_x, root_y, child_x, child_y;
+        unsigned int KeyState;
+  
+        init_done = 1;
+        /* Get the current mouse position and simulate an absolute mouse
+           movement to initialize the mouse global variables */
+        TSXQueryPointer( display, X11DRV_GetXRootWindow(), &root, &child,
+                         &root_x, &root_y, &child_x, &child_y, &KeyState);
+        X11DRV_MOUSE_SendEvent(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
+                               root_x, root_y, X11DRV_EVENT_XStateToKeyState(KeyState),
+                               GetTickCount(), 0 );
+    }
+}
+
+
+/***********************************************************************
+ *           X11DRV_MOUSE_SendEvent
+ */
+void X11DRV_MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY, 
+                             DWORD keyState, DWORD time, HWND hWnd )
+{
+    int width  = MONITOR_GetWidth (&MONITOR_PrimaryMonitor);
+    int height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
+    int iWndsLocks;
+    WINE_MOUSEEVENT wme;
+
+    if ( !DefMouseEventProc ) return;
+
+    TRACE("(%04lX,%ld,%ld)\n", mouseStatus, posX, posY );
+
+    if (mouseStatus & MOUSEEVENTF_MOVE) {
+      if (mouseStatus & MOUSEEVENTF_ABSOLUTE) {
+	/* Relative mouse movements seems not to be scaled as absolute ones */
+	posX = (((long)posX << 16) + width-1)  / width;
+	posY = (((long)posY << 16) + height-1) / height;
+      }
+    }
+
+    wme.magic    = WINE_MOUSEEVENT_MAGIC;
+    wme.time     = time;
+    wme.hWnd     = hWnd;
+    wme.keyState = keyState;
+    
+    InterlockedDecrement( &X11DRV_MOUSE_WarpPointer );
+    /* To avoid deadlocks, we have to suspend all locks on windows structures
+       before the program control is passed to the mouse driver */
+    iWndsLocks = WIN_SuspendWndsLock();
+    DefMouseEventProc( mouseStatus, posX, posY, 0, (DWORD)&wme );
+    WIN_RestoreWndsLock(iWndsLocks);
+    InterlockedIncrement( &X11DRV_MOUSE_WarpPointer );
 }