Make sure that the keystate received by the WM_XBUTTONUP and
[wine] / windows / mouse.c
1 /*
2  * MOUSE driver
3  * 
4  * Copyright 1998 Ulrich Weigand
5  * 
6  */
7
8 #include <assert.h>
9 #include "windows.h"
10 #include "gdi.h"
11 #include "mouse.h"
12 #include "debug.h"
13 #include "debugtools.h"
14 #include "x11drv.h"
15
16 static LPMOUSE_EVENT_PROC DefMouseEventProc = NULL;
17
18 /***********************************************************************
19  *           MOUSE_Inquire                       (MOUSE.1)
20  */
21 WORD WINAPI MOUSE_Inquire(LPMOUSEINFO mouseInfo)
22 {
23     mouseInfo->msExist = TRUE;
24     mouseInfo->msRelative = FALSE;
25     mouseInfo->msNumButtons = 2;
26     mouseInfo->msRate = 34;  /* the DDK says so ... */
27     mouseInfo->msXThreshold = 0;
28     mouseInfo->msYThreshold = 0;
29     mouseInfo->msXRes = 0;
30     mouseInfo->msYRes = 0;
31     mouseInfo->msMouseCommPort = 0;
32
33     return sizeof(MOUSEINFO);
34 }
35
36 /***********************************************************************
37  *           MOUSE_Enable                        (MOUSE.2)
38  */
39 VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc)
40 {
41     DefMouseEventProc = lpMouseEventProc;
42 }
43
44 /***********************************************************************
45  *           MOUSE_Disable                       (MOUSE.3)
46  */
47 VOID WINAPI MOUSE_Disable(VOID)
48 {
49     DefMouseEventProc = 0;
50 }
51
52 /***********************************************************************
53  *           MOUSE_SendEvent
54  */
55 void MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY, 
56                       DWORD keyState, DWORD time, HWND32 hWnd )
57 {
58     extern BOOL32 DISPLAY_DisableWarpPointer;
59     WINE_MOUSEEVENT wme;
60
61     if ( !DefMouseEventProc ) return;
62
63     TRACE( event, "(%04lX,%ld,%ld)\n", mouseStatus, posX, posY );
64
65     mouseStatus |= MOUSEEVENTF_ABSOLUTE;
66     posX = (((long)posX << 16) + screenWidth-1)  / screenWidth;
67     posY = (((long)posY << 16) + screenHeight-1) / screenHeight;
68
69     wme.magic    = WINE_MOUSEEVENT_MAGIC;
70     wme.keyState = keyState;
71     wme.time     = time;
72     wme.hWnd     = hWnd;
73
74     DISPLAY_DisableWarpPointer = TRUE;
75     DefMouseEventProc( mouseStatus, posX, posY, 0, (DWORD)&wme );
76     DISPLAY_DisableWarpPointer = FALSE;
77 }
78