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 <peter.hutterer@who-t.net> Reviewed-by: Simon Thum <simon.thum@gmx.de> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
		
							parent
							
								
									6c42c8c356
								
							
						
					
					
						commit
						f4106c0231
					
				| 
						 | 
					@ -769,6 +769,7 @@ extern _X_EXPORT void XkbDDXUpdateDeviceIndicators(
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern _X_EXPORT void XkbDDXFakePointerMotion(
 | 
					extern _X_EXPORT void XkbDDXFakePointerMotion(
 | 
				
			||||||
 | 
						DeviceIntPtr	/* dev */,
 | 
				
			||||||
 	unsigned int	/* flags */,
 | 
					 	unsigned int	/* flags */,
 | 
				
			||||||
	int		/* x */,
 | 
						int		/* x */,
 | 
				
			||||||
	int		/* y */
 | 
						int		/* y */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										102
									
								
								xkb/ddxFakeMtn.c
								
								
								
								
							
							
						
						
									
										102
									
								
								xkb/ddxFakeMtn.c
								
								
								
								
							| 
						 | 
					@ -28,91 +28,37 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 | 
				
			||||||
#include <dix-config.h>
 | 
					#include <dix-config.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <X11/X.h>
 | 
					 | 
				
			||||||
#include <X11/Xproto.h>
 | 
					 | 
				
			||||||
#include <X11/keysym.h>
 | 
					 | 
				
			||||||
#include "inputstr.h"
 | 
					#include "inputstr.h"
 | 
				
			||||||
#include "scrnintstr.h"
 | 
					 | 
				
			||||||
#include "windowstr.h"
 | 
					 | 
				
			||||||
#include <xkbsrv.h>
 | 
					#include <xkbsrv.h>
 | 
				
			||||||
#include <X11/extensions/XI.h>
 | 
					#include "mi.h"
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef PANORAMIX
 | 
					 | 
				
			||||||
#include "panoramiX.h"
 | 
					 | 
				
			||||||
#include "panoramiXsrv.h"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "mipointer.h"
 | 
					 | 
				
			||||||
#include "mipointrst.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
XkbDDXFakePointerMotion(unsigned flags,int x,int y)
 | 
					XkbDDXFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
int 		   oldX,oldY;
 | 
					    EventListPtr        events;
 | 
				
			||||||
ScreenPtr	   pScreen, oldScreen;
 | 
					    int                 nevents, i;
 | 
				
			||||||
 | 
					    DeviceIntPtr        ptr;
 | 
				
			||||||
 | 
					    int                 gpe_flags = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    GetSpritePosition(inputInfo.pointer, &oldX, &oldY);
 | 
					    if (!dev->u.master)
 | 
				
			||||||
    pScreen = oldScreen = GetSpriteWindow(inputInfo.pointer)->drawable.pScreen;
 | 
					        ptr = dev;
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef PANORAMIX
 | 
					 | 
				
			||||||
    if (!noPanoramiXExtension) {
 | 
					 | 
				
			||||||
	BoxRec box;
 | 
					 | 
				
			||||||
	int i;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	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(!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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
#endif
 | 
					        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
	if (flags&XkbSA_MoveAbsoluteX)
 | 
					 | 
				
			||||||
	     oldX=  x;
 | 
					 | 
				
			||||||
	else oldX+= x;
 | 
					 | 
				
			||||||
	if (flags&XkbSA_MoveAbsoluteY)
 | 
					 | 
				
			||||||
	     oldY=  y;
 | 
					 | 
				
			||||||
	else oldY+= y;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define GetScreenPrivate(s) ((miPointerScreenPtr)dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey))
 | 
					    if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
 | 
				
			||||||
	(*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen)
 | 
					        gpe_flags = POINTER_ABSOLUTE;
 | 
				
			||||||
	    (&pScreen, &oldX, &oldY);
 | 
					    else
 | 
				
			||||||
    }
 | 
					        gpe_flags = POINTER_RELATIVE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pScreen != oldScreen)
 | 
					    events = InitEventList(GetMaximumEventsNum());
 | 
				
			||||||
	NewCurrentScreen(inputInfo.pointer, pScreen, oldX, oldY);
 | 
					    OsBlockSignals();
 | 
				
			||||||
    if (pScreen->SetCursorPosition)
 | 
					    nevents = GetPointerEvents(events, ptr,
 | 
				
			||||||
	(*pScreen->SetCursorPosition)(inputInfo.pointer, pScreen, oldX, oldY, TRUE);
 | 
					                               MotionNotify, 0,
 | 
				
			||||||
 | 
					                               gpe_flags, 0, 2, (int[]){x, y});
 | 
				
			||||||
 | 
					    OsReleaseSignals();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (i = 0; i < nevents; i++)
 | 
				
			||||||
 | 
					        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    FreeEventList(events, GetMaximumEventsNum());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -479,7 +479,7 @@ int		dx,dy;
 | 
				
			||||||
	dx= xkbi->mouseKeysDX;
 | 
						dx= xkbi->mouseKeysDX;
 | 
				
			||||||
	dy= xkbi->mouseKeysDY;
 | 
						dy= xkbi->mouseKeysDY;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    XkbDDXFakePointerMotion(xkbi->mouseKeysFlags,dx,dy);
 | 
					    XkbDDXFakePointerMotion(xkbi->device, xkbi->mouseKeysFlags,dx,dy);
 | 
				
			||||||
    return xkbi->desc->ctrls->mk_interval;
 | 
					    return xkbi->desc->ctrls->mk_interval;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -507,7 +507,7 @@ Bool	accel;
 | 
				
			||||||
	accel= ((pAction->ptr.flags&XkbSA_NoAcceleration)==0);
 | 
						accel= ((pAction->ptr.flags&XkbSA_NoAcceleration)==0);
 | 
				
			||||||
	x= XkbPtrActionX(&pAction->ptr);
 | 
						x= XkbPtrActionX(&pAction->ptr);
 | 
				
			||||||
	y= XkbPtrActionY(&pAction->ptr);
 | 
						y= XkbPtrActionY(&pAction->ptr);
 | 
				
			||||||
	XkbDDXFakePointerMotion(pAction->ptr.flags,x,y);
 | 
						XkbDDXFakePointerMotion(xkbi->device, pAction->ptr.flags,x,y);
 | 
				
			||||||
	AccessXCancelRepeatKey(xkbi,keycode);
 | 
						AccessXCancelRepeatKey(xkbi,keycode);
 | 
				
			||||||
	xkbi->mouseKeysAccel= accel&&
 | 
						xkbi->mouseKeysAccel= accel&&
 | 
				
			||||||
		(xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask);
 | 
							(xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue