dix: If POINTER_CORE_ONLY is set, GetPointerEvents() only creates a core event
mi: fix: Create motion event in miPointerMoved
This commit is contained in:
		
							parent
							
								
									a309c936bb
								
							
						
					
					
						commit
						7cd73b00a2
					
				| 
						 | 
					@ -481,6 +481,9 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
 | 
				
			||||||
 * events is not NULL-terminated; the return value is the number of events.
 | 
					 * events is not NULL-terminated; the return value is the number of events.
 | 
				
			||||||
 * The DDX is responsible for allocating the event structure in the first
 | 
					 * The DDX is responsible for allocating the event structure in the first
 | 
				
			||||||
 * place via GetMaximumEventsNum(), and for freeing it.
 | 
					 * place via GetMaximumEventsNum(), and for freeing it.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * If flag has POINTER_CORE_ONLY set, no XI or valuator event will be
 | 
				
			||||||
 | 
					 * generated.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
_X_EXPORT int
 | 
					_X_EXPORT int
 | 
				
			||||||
GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
 | 
					GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
 | 
				
			||||||
| 
						 | 
					@ -494,6 +497,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
 | 
				
			||||||
    Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
 | 
					    Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
 | 
				
			||||||
    DeviceIntPtr pointer = NULL;
 | 
					    DeviceIntPtr pointer = NULL;
 | 
				
			||||||
    int x = 0, y = 0;
 | 
					    int x = 0, y = 0;
 | 
				
			||||||
 | 
					    Bool coreOnly = (flags & POINTER_CORE_ONLY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Sanity checks. */
 | 
					    /* Sanity checks. */
 | 
				
			||||||
    if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
 | 
					    if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
 | 
				
			||||||
| 
						 | 
					@ -502,7 +506,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
 | 
				
			||||||
    if ((type == ButtonPress || type == ButtonRelease) && !pDev->button)
 | 
					    if ((type == ButtonPress || type == ButtonRelease) && !pDev->button)
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pDev->coreEvents || pDev->isMPDev)
 | 
					    if (!coreOnly && (pDev->coreEvents || pDev->isMPDev))
 | 
				
			||||||
        num_events = 2;
 | 
					        num_events = 2;
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        num_events = 1;
 | 
					        num_events = 1;
 | 
				
			||||||
| 
						 | 
					@ -512,7 +516,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Do we need to send a DeviceValuator event? */
 | 
					    /* Do we need to send a DeviceValuator event? */
 | 
				
			||||||
    if (sendValuators) {
 | 
					    if (!coreOnly & sendValuators) {
 | 
				
			||||||
        if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS)
 | 
					        if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS)
 | 
				
			||||||
            num_valuators = MAX_VALUATOR_EVENTS * 6;
 | 
					            num_valuators = MAX_VALUATOR_EVENTS * 6;
 | 
				
			||||||
        num_events += ((num_valuators - 1) / 6) + 1;
 | 
					        num_events += ((num_valuators - 1) / 6) + 1;
 | 
				
			||||||
| 
						 | 
					@ -608,16 +612,19 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
 | 
				
			||||||
    kbp->root_x = x;
 | 
					    kbp->root_x = x;
 | 
				
			||||||
    kbp->root_y = y;
 | 
					    kbp->root_y = y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    events++;
 | 
					    if (!coreOnly)
 | 
				
			||||||
    if (sendValuators) {
 | 
					    {
 | 
				
			||||||
        kbp->deviceid |= MORE_EVENTS;
 | 
					        events++;
 | 
				
			||||||
        clipValuators(pDev, first_valuator, num_valuators, valuators);
 | 
					        if (sendValuators) {
 | 
				
			||||||
        events = getValuatorEvents(events, pDev, first_valuator,
 | 
					            kbp->deviceid |= MORE_EVENTS;
 | 
				
			||||||
                                   num_valuators, valuators);
 | 
					            clipValuators(pDev, first_valuator, num_valuators, valuators);
 | 
				
			||||||
 | 
					            events = getValuatorEvents(events, pDev, first_valuator,
 | 
				
			||||||
 | 
					                    num_valuators, valuators);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* MPX devices always send core events */
 | 
					    /* MPX devices always send core events */
 | 
				
			||||||
    if (pDev->coreEvents || pDev->isMPDev) {
 | 
					    if (coreOnly || pDev->coreEvents || pDev->isMPDev) {
 | 
				
			||||||
        events->u.u.type = type;
 | 
					        events->u.u.type = type;
 | 
				
			||||||
        events->u.keyButtonPointer.time = ms;
 | 
					        events->u.keyButtonPointer.time = ms;
 | 
				
			||||||
        events->u.keyButtonPointer.rootX = x;
 | 
					        events->u.keyButtonPointer.rootX = x;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,6 +62,7 @@ SOFTWARE.
 | 
				
			||||||
#define POINTER_RELATIVE (1 << 1)
 | 
					#define POINTER_RELATIVE (1 << 1)
 | 
				
			||||||
#define POINTER_ABSOLUTE (1 << 2)
 | 
					#define POINTER_ABSOLUTE (1 << 2)
 | 
				
			||||||
#define POINTER_ACCELERATE (1 << 3)
 | 
					#define POINTER_ACCELERATE (1 << 3)
 | 
				
			||||||
 | 
					#define POINTER_CORE_ONLY (1 << 4) /* do not generate XI event */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MAP_LENGTH	256
 | 
					#define MAP_LENGTH	256
 | 
				
			||||||
#define DOWN_LENGTH	32	/* 256/8 => number of bytes to hold 256 bits */
 | 
					#define DOWN_LENGTH	32	/* 256/8 => number of bytes to hold 256 bits */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -540,6 +540,10 @@ void
 | 
				
			||||||
miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
 | 
					miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
 | 
				
			||||||
                     unsigned long time)
 | 
					                     unsigned long time)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    xEvent* events;
 | 
				
			||||||
 | 
					    int i, nevents;
 | 
				
			||||||
 | 
					    int valuators[2];
 | 
				
			||||||
 | 
					    int flags;
 | 
				
			||||||
    miPointerPtr pPointer = MIPOINTER(pDev);
 | 
					    miPointerPtr pPointer = MIPOINTER(pDev);
 | 
				
			||||||
    SetupScreen(pScreen);
 | 
					    SetupScreen(pScreen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -556,4 +560,29 @@ miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
 | 
				
			||||||
    pPointer->x = x;
 | 
					    pPointer->x = x;
 | 
				
			||||||
    pPointer->y = y;
 | 
					    pPointer->y = y;
 | 
				
			||||||
    pPointer->pScreen = pScreen;
 | 
					    pPointer->pScreen = pScreen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* generate event here */
 | 
				
			||||||
 | 
					    valuators[0] = x;
 | 
				
			||||||
 | 
					    valuators[1] = y;
 | 
				
			||||||
 | 
					    events = (xEvent*)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
 | 
				
			||||||
 | 
					    if (!events)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        FatalError("Could not allocate event store.\n");
 | 
				
			||||||
 | 
						return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    flags = POINTER_ABSOLUTE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* If called from ProcWarpCursor, pDev is the VCP and we must not generate
 | 
				
			||||||
 | 
					      an XI event. */
 | 
				
			||||||
 | 
					    if (pDev == inputInfo.pointer)
 | 
				
			||||||
 | 
					        flags |= POINTER_CORE_ONLY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    nevents = GetPointerEvents(events, pDev, MotionNotify, 0,
 | 
				
			||||||
 | 
					                               flags, 0, 2, valuators);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (i = 0; i < nevents; i++)
 | 
				
			||||||
 | 
					        mieqEnqueue(pDev, &events[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    xfree(events);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue