[PATCH 26/27] Input: Split GetPointerEvents body into a helper function

Daniel Stone daniel at fooishbar.org
Fri Jun 3 08:00:02 PDT 2011


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 at fooishbar.org>
---
 dix/getevents.c |   59 ++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/dix/getevents.c b/dix/getevents.c
index ad99cae..c1ebbb2 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1065,24 +1065,18 @@ QueuePointerEvents(DeviceIntPtr device, int type,
  *
  * @return the number of events written into events.
  */
-int
-GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons,
-                 int flags, const ValuatorMask *mask_in) {
+static int
+_GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
+                  int buttons, CARD32 ms, int flags,
+                  const ValuatorMask *mask_in)
+{
     int num_events = 1, i;
-    CARD32 ms;
     DeviceEvent *event;
-    RawDeviceEvent    *raw;
+    RawDeviceEvent *raw;
     double screenx = 0.0, screeny = 0.0;
     ScreenPtr scr = miPointerGetScreen(pDev);
     ValuatorMask mask;
 
-    /* refuse events from disabled devices */
-    if (!pDev->enabled)
-        return 0;
-
-    if (!scr)
-        return 0;
-
     switch (type)
     {
         case MotionNotify:
@@ -1098,10 +1092,6 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
             return 0;
     }
 
-    ms = GetTimeInMillis(); /* before pointer update to help precision */
-
-    events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
-
     raw = &events->raw_event;
     events++;
     num_events++;
@@ -1189,6 +1179,43 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
 }
 
 /**
+ * Generate a series of InternalEvents (filled into the EventList)
+ * representing pointer motion, or button presses.
+ *
+ * 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 += _GetPointerEvents(events, pDev, type, buttons, ms, flags,
+                                    mask_in);
+    return num_events;
+}
+
+/**
  * Generate internal events representing this proximity event and enqueue
  * them on the event queue.
  *
-- 
1.7.5.3



More information about the xorg-devel mailing list