diff options
Diffstat (limited to 'xorg-server/hw/xwin/winmouse.c')
-rw-r--r-- | xorg-server/hw/xwin/winmouse.c | 143 |
1 files changed, 112 insertions, 31 deletions
diff --git a/xorg-server/hw/xwin/winmouse.c b/xorg-server/hw/xwin/winmouse.c index be2b66a08..cf52bbaaf 100644 --- a/xorg-server/hw/xwin/winmouse.c +++ b/xorg-server/hw/xwin/winmouse.c @@ -36,13 +36,21 @@ #endif #include "win.h" -#if defined(XFree86Server) +#ifdef XKB +#ifndef XKB_IN_SERVER +#define XKB_IN_SERVER +#endif +#include <xkbsrv.h> +#endif + +#if 1 #include "inputstr.h" /* Peek the internal button mapping */ static CARD8 const *g_winMouseButtonMap = NULL; #endif +#include <X11/extensions/XIproto.h> /* * Local prototypes @@ -100,13 +108,12 @@ winMouseProc (DeviceIntPtr pDeviceInt, int iState) InitPointerDeviceStruct (pDevice, map, lngMouseButtons + lngWheelEvents, - GetMotionHistory, winMouseCtrl, GetMotionHistorySize(), 2); free(map); -#if defined(XFree86Server) +#if 1 g_winMouseButtonMap = pDeviceInt->button->map; #endif break; @@ -116,7 +123,7 @@ winMouseProc (DeviceIntPtr pDeviceInt, int iState) break; case DEVICE_CLOSE: -#if defined(XFree86Server) +#if 1 g_winMouseButtonMap = NULL; #endif case DEVICE_OFF: @@ -129,7 +136,7 @@ winMouseProc (DeviceIntPtr pDeviceInt, int iState) /* Handle the mouse wheel */ int -winMouseWheel (ScreenPtr pScreen, int iDeltaZ) +winMouseWheel (ScreenPtr pScreen, int iDeltaZ, int x, int y) { winScreenPriv(pScreen); int button; /* Button4 or Button5 */ @@ -204,10 +211,10 @@ winMouseWheel (ScreenPtr pScreen, int iDeltaZ) while (iDeltaZ--) { /* Push the wheel button */ - winMouseButtonsSendEvent (ButtonPress, button); + winMouseButtonsSendEvent (DeviceButtonPress, button,x,y); /* Release the wheel button */ - winMouseButtonsSendEvent (ButtonRelease, button); + winMouseButtonsSendEvent (DeviceButtonRelease, button,x,y); } return 0; @@ -219,32 +226,62 @@ winMouseWheel (ScreenPtr pScreen, int iDeltaZ) */ void -winMouseButtonsSendEvent (int iEventType, int iButton) +winMouseButtonsSendEvent (int iEventType, int iButton, int x, int y) { - xEvent xCurrentEvent; + DeviceIntPtr pDev; + deviceKeyButtonPointer xCurrentEvent; + deviceKeyButtonPointer *kbp = &xCurrentEvent; /* Load an xEvent and enqueue the event */ - xCurrentEvent.u.u.type = iEventType; -#if defined(XFree86Server) + kbp->type=iEventType; +#if 1 if (g_winMouseButtonMap) - xCurrentEvent.u.u.detail = g_winMouseButtonMap[iButton]; + kbp->detail = g_winMouseButtonMap[iButton]; else #endif - xCurrentEvent.u.u.detail = iButton; - xCurrentEvent.u.keyButtonPointer.time - = g_c32LastInputEventTime = GetTickCount (); - mieqEnqueue (&xCurrentEvent); + kbp->detail = iButton; + kbp->time = g_c32LastInputEventTime = GetTickCount (); + + kbp->root_x = x; + kbp->root_y = y; + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) + if ((pDev->coreEvents && pDev != inputInfo.pointer) && pDev->button) + { + kbp->deviceid = pDev->id; + mieqEnqueue (pDev, (xEventPtr)kbp); + } +} + +void winGetPtMouse(HWND hwnd, LPARAM lParam, POINT *ptMouse) +{ + /* Unpack the client area mouse coordinates */ + ptMouse->x = GET_X_LPARAM(lParam); + ptMouse->y = GET_Y_LPARAM(lParam); } +void winGetPtMouseScreen(HWND hwnd, LPARAM lParam, POINT *ptMouse) +{ + /* Unpack the client area mouse coordinates */ + ptMouse->x = GET_X_LPARAM(lParam); + ptMouse->y = GET_Y_LPARAM(lParam); + + /* Translate the client area mouse coordinates to screen coordinates */ + ClientToScreen (hwnd, ptMouse); + + /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */ + ptMouse->x -= GetSystemMetrics (SM_XVIRTUALSCREEN); + ptMouse->y -= GetSystemMetrics (SM_YVIRTUALSCREEN); +} /* * Decide what to do with a Windows mouse message */ -int -winMouseButtonsHandle (ScreenPtr pScreen, - int iEventType, int iButton, - WPARAM wParam) +static int +_winMouseButtonsHandle (ScreenPtr pScreen, + int iEventType, int iButton, + WPARAM wParam, POINT *ptMouse) { winScreenPriv(pScreen); winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; @@ -253,12 +290,12 @@ winMouseButtonsHandle (ScreenPtr pScreen, if (pScreenInfo->iE3BTimeout == WIN_E3B_OFF) { /* Emulate 3 buttons is off, send the button event */ - winMouseButtonsSendEvent (iEventType, iButton); + winMouseButtonsSendEvent (iEventType, iButton, ptMouse->x, ptMouse->y); return 0; } /* Emulate 3 buttons is on, let the fun begin */ - if (iEventType == ButtonPress + if (iEventType == DeviceButtonPress && pScreenPriv->iE3BCachedPress == 0 && !pScreenPriv->fE3BFakeButton2Sent) { @@ -279,7 +316,7 @@ winMouseButtonsHandle (ScreenPtr pScreen, pScreenInfo->iE3BTimeout, NULL); } - else if (iEventType == ButtonPress + else if (iEventType == DeviceButtonPress && pScreenPriv->iE3BCachedPress != 0 && pScreenPriv->iE3BCachedPress != iButton && !pScreenPriv->fE3BFakeButton2Sent) @@ -294,12 +331,12 @@ winMouseButtonsHandle (ScreenPtr pScreen, pScreenPriv->iE3BCachedPress = 0; /* Send fake middle button */ - winMouseButtonsSendEvent (ButtonPress, Button2); + winMouseButtonsSendEvent (DeviceButtonPress, Button2, ptMouse->x, ptMouse->y); /* Indicate that a fake middle button event was sent */ pScreenPriv->fE3BFakeButton2Sent = TRUE; } - else if (iEventType == ButtonRelease + else if (iEventType == DeviceButtonRelease && pScreenPriv->iE3BCachedPress == iButton) { /* @@ -310,10 +347,10 @@ winMouseButtonsHandle (ScreenPtr pScreen, pScreenPriv->iE3BCachedPress = 0; /* Send cached press, then send release */ - winMouseButtonsSendEvent (ButtonPress, iButton); - winMouseButtonsSendEvent (ButtonRelease, iButton); + winMouseButtonsSendEvent (DeviceButtonPress, iButton, ptMouse->x, ptMouse->y); + winMouseButtonsSendEvent (DeviceButtonRelease, iButton, ptMouse->x, ptMouse->y); } - else if (iEventType == ButtonRelease + else if (iEventType == DeviceButtonRelease && pScreenPriv->fE3BFakeButton2Sent && !(wParam & MK_LBUTTON) && !(wParam & MK_RBUTTON)) @@ -324,9 +361,9 @@ winMouseButtonsHandle (ScreenPtr pScreen, pScreenPriv->fE3BFakeButton2Sent = FALSE; /* Send middle mouse button release */ - winMouseButtonsSendEvent (ButtonRelease, Button2); + winMouseButtonsSendEvent (DeviceButtonRelease, Button2, ptMouse->x, ptMouse->y); } - else if (iEventType == ButtonRelease + else if (iEventType == DeviceButtonRelease && pScreenPriv->iE3BCachedPress == 0 && !pScreenPriv->fE3BFakeButton2Sent) { @@ -334,8 +371,52 @@ winMouseButtonsHandle (ScreenPtr pScreen, * Button was release, no button is cached, * and there is no fake button 2 release is pending. */ - winMouseButtonsSendEvent (ButtonRelease, iButton); + winMouseButtonsSendEvent (DeviceButtonRelease, iButton, ptMouse->x, ptMouse->y); } return 0; } + +int +winMouseButtonsHandle (ScreenPtr pScreen, + int iEventType, int iButton, + WPARAM wParam, HWND hwnd, LPARAM lParam) +{ + POINT ptMouse; + winGetPtMouse(hwnd,lParam,&ptMouse); + return _winMouseButtonsHandle(pScreen, iEventType, iButton, wParam ,&ptMouse); +} + +int +winMouseButtonsHandleScreen (ScreenPtr pScreen, + int iEventType, int iButton, + WPARAM wParam, HWND hwnd, LPARAM lParam) +{ + POINT ptMouse; + winGetPtMouseScreen(hwnd,lParam,&ptMouse); + return _winMouseButtonsHandle(pScreen, iEventType, iButton, wParam ,&ptMouse); +} + + +/** + * Enqueue a motion event. + */ +void winEnqueueMotion(int x, int y) +{ + int i, nevents; + int valuators[2]; + int MaxN=GetMaximumEventsNum(); + + EventListPtr events = InitEventList(MaxN); + + 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,MaxN); +} +// XXX: miPointerMove does exactly this, but is static :-( (and uses a static buffer) |