Input: Split GetPointerEvents body into a helper function

For smooth-scrolling support, we want GetPointerEvents to generate
multiple events, so split the body of the function out into a helper
function in order to call it multiple times.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Daniel Stone 2011-02-15 18:54:14 +00:00 committed by Peter Hutterer
parent bc8aad2376
commit d8e42decba

View File

@ -1043,40 +1043,25 @@ QueuePointerEvents(DeviceIntPtr device, int type,
} }
/** /**
* Generate a series of InternalEvents representing pointer motion, or * Helper function for GetPointerEvents, which only generates motion and
* button presses. * raw motion events for the slave device: does not update the master device.
* *
* The DDX is responsible for allocating the events in the first * Should not be called by anyone other than GetPointerEvents.
* place via InitEventList() and GetMaximumEventsNum(), and for freeing it.
*
* In the generated events rootX/Y will be in absolute screen coords and
* the valuator information in the absolute or relative device coords.
*
* last.valuators[x] of the device is always in absolute device coords.
* last.valuators[x] of the master device is in absolute screen coords.
*
* master->last.valuators[x] for x > 2 is undefined.
* *
* @return the number of events written into events. * @return the number of events written into events.
*/ */
int static int
GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons, fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
int flags, const ValuatorMask *mask_in) { int buttons, CARD32 ms, int flags,
const ValuatorMask *mask_in)
{
int num_events = 1, i; int num_events = 1, i;
CARD32 ms;
DeviceEvent *event; DeviceEvent *event;
RawDeviceEvent *raw; RawDeviceEvent *raw;
double screenx = 0.0, screeny = 0.0; double screenx = 0.0, screeny = 0.0;
ScreenPtr scr = miPointerGetScreen(pDev); ScreenPtr scr = miPointerGetScreen(pDev);
ValuatorMask mask; ValuatorMask mask;
/* refuse events from disabled devices */
if (!pDev->enabled)
return 0;
if (!scr)
return 0;
switch (type) switch (type)
{ {
case MotionNotify: case MotionNotify:
@ -1092,10 +1077,6 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
return 0; return 0;
} }
ms = GetTimeInMillis(); /* before pointer update to help precision */
events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
valuator_mask_copy(&mask, mask_in); valuator_mask_copy(&mask, mask_in);
if ((flags & POINTER_NORAW) == 0) if ((flags & POINTER_NORAW) == 0)
@ -1183,6 +1164,45 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
return num_events; return num_events;
} }
/**
* Generate a complete series of InternalEvents (filled into the EventList)
* representing pointer motion, or button presses. If the device is a slave
* device, also potentially generate a DeviceClassesChangedEvent to update
* the master device.
*
* 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
* place via InitEventList() and GetMaximumEventsNum(), and for freeing it.
*
* In the generated events rootX/Y will be in absolute screen coords and
* the valuator information in the absolute or relative device coords.
*
* last.valuators[x] of the device is always in absolute device coords.
* last.valuators[x] of the master device is in absolute screen coords.
*
* master->last.valuators[x] for x > 2 is undefined.
*/
int
GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
int buttons, int flags, const ValuatorMask *mask_in)
{
CARD32 ms = GetTimeInMillis();
int num_events = 0;
/* refuse events from disabled devices */
if (!pDev->enabled)
return 0;
if (!miPointerGetScreen(pDev))
return 0;
events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT,
&num_events);
num_events += fill_pointer_events(events, pDev, type, buttons, ms, flags,
mask_in);
return num_events;
}
/** /**
* Generate internal events representing this proximity event and enqueue * Generate internal events representing this proximity event and enqueue
* them on the event queue. * them on the event queue.