From f4106c02318fcc4b534224df5b95a58aff555fb4 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 13 Apr 2010 14:44:59 +1000 Subject: xkb: use GPE for XKB fake motion events. Section 4.6.1 of the XKB spec says that "the initial event always moves the cursor the distance specified in the action [...]", so skip the POINTER_ACCELERATE flag for GPE, it would cause double-acceleration. Potential regression - GPE expects the coordinates to be either relative or both. XKB in theory allows for x to be relative and y to be absolute (or vice versa). Let's pretend that scenario has no users. Signed-off-by: Peter Hutterer Reviewed-by: Simon Thum Reviewed-by: Daniel Stone --- include/xkbsrv.h | 1 + xkb/ddxFakeMtn.c | 100 +++++++++++++------------------------------------------ xkb/xkbActions.c | 4 +-- 3 files changed, 26 insertions(+), 79 deletions(-) diff --git a/include/xkbsrv.h b/include/xkbsrv.h index 278ff769d..239b7a180 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -769,6 +769,7 @@ extern _X_EXPORT void XkbDDXUpdateDeviceIndicators( ); extern _X_EXPORT void XkbDDXFakePointerMotion( + DeviceIntPtr /* dev */, unsigned int /* flags */, int /* x */, int /* y */ diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c index f90d2099a..b38371614 100644 --- a/xkb/ddxFakeMtn.c +++ b/xkb/ddxFakeMtn.c @@ -28,91 +28,37 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #endif -#include -#include -#include -#include #include "inputstr.h" -#include "scrnintstr.h" -#include "windowstr.h" #include -#include - -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" -#endif - -#include "mipointer.h" -#include "mipointrst.h" +#include "mi.h" void -XkbDDXFakePointerMotion(unsigned flags,int x,int y) +XkbDDXFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y) { -int oldX,oldY; -ScreenPtr pScreen, oldScreen; - - GetSpritePosition(inputInfo.pointer, &oldX, &oldY); - pScreen = oldScreen = GetSpriteWindow(inputInfo.pointer)->drawable.pScreen; - -#ifdef PANORAMIX - if (!noPanoramiXExtension) { - BoxRec box; - int i; + EventListPtr events; + int nevents, i; + DeviceIntPtr ptr; + int gpe_flags = 0; - if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum], - oldX, oldY, &box)) { - FOR_NSCREENS(i) { - if(i == pScreen->myNum) - continue; - if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], - oldX, oldY, &box)) { - pScreen = screenInfo.screens[i]; - break; - } - } - } - oldScreen = pScreen; - - if (flags&XkbSA_MoveAbsoluteX) - oldX= x; - else oldX+= x; - if (flags&XkbSA_MoveAbsoluteY) - oldY= y; - else oldY+= y; + if (!dev->u.master) + ptr = dev; + else + ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER)); - if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum], - oldX, oldY, &box)) { - FOR_NSCREENS(i) { - if(i == pScreen->myNum) - continue; - if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], - oldX, oldY, &box)) { - pScreen = screenInfo.screens[i]; - break; - } - } - } - oldX -= panoramiXdataPtr[pScreen->myNum].x; - oldY -= panoramiXdataPtr[pScreen->myNum].y; - } + if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY) + gpe_flags = POINTER_ABSOLUTE; else -#endif - { - if (flags&XkbSA_MoveAbsoluteX) - oldX= x; - else oldX+= x; - if (flags&XkbSA_MoveAbsoluteY) - oldY= y; - else oldY+= y; + gpe_flags = POINTER_RELATIVE; + + events = InitEventList(GetMaximumEventsNum()); + OsBlockSignals(); + nevents = GetPointerEvents(events, ptr, + MotionNotify, 0, + gpe_flags, 0, 2, (int[]){x, y}); + OsReleaseSignals(); -#define GetScreenPrivate(s) ((miPointerScreenPtr)dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey)) - (*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen) - (&pScreen, &oldX, &oldY); - } + for (i = 0; i < nevents; i++) + mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL); - if (pScreen != oldScreen) - NewCurrentScreen(inputInfo.pointer, pScreen, oldX, oldY); - if (pScreen->SetCursorPosition) - (*pScreen->SetCursorPosition)(inputInfo.pointer, pScreen, oldX, oldY, TRUE); + FreeEventList(events, GetMaximumEventsNum()); } diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 2cdb6fcea..4c7bce2e4 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -479,7 +479,7 @@ int dx,dy; dx= xkbi->mouseKeysDX; dy= xkbi->mouseKeysDY; } - XkbDDXFakePointerMotion(xkbi->mouseKeysFlags,dx,dy); + XkbDDXFakePointerMotion(xkbi->device, xkbi->mouseKeysFlags,dx,dy); return xkbi->desc->ctrls->mk_interval; } @@ -507,7 +507,7 @@ Bool accel; accel= ((pAction->ptr.flags&XkbSA_NoAcceleration)==0); x= XkbPtrActionX(&pAction->ptr); y= XkbPtrActionY(&pAction->ptr); - XkbDDXFakePointerMotion(pAction->ptr.flags,x,y); + XkbDDXFakePointerMotion(xkbi->device, pAction->ptr.flags,x,y); AccessXCancelRepeatKey(xkbi,keycode); xkbi->mouseKeysAccel= accel&& (xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask); -- cgit v1.2.3