xserver: Branch 'server-1.12-branch' - 2 commits

Peter Hutterer whot at kemper.freedesktop.org
Sun Jul 1 16:15:37 PDT 2012


 dix/getevents.c |   40 ++++++++++++++++++++++++++++++++++------
 randr/randr.c   |    2 +-
 2 files changed, 35 insertions(+), 7 deletions(-)

New commits:
commit d21b6f0a2d767ca6fbd8f0ec387f83a50a38b486
Author: Andy Ritger <aritger at nvidia.com>
Date:   Thu Jun 14 09:15:37 2012 -0700

    randr: Don't recurse into mieqProcessInputEvents() from RRTellChanged().
    
    Call UpdateCurrentTimeIf(), not UpdateCurrentTime(), from RRTellChanged().
    The latter calls ProcessInputEvents(), which can trigger a recursion
    into mieqProcessInputEvents().  The former omits the call to
    ProcessInputEvents().
    
    Signed-off-by: Andy Ritger <aritger at nvidia.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit dae317e7265007b38012244722e3b3a06e904ed5)

diff --git a/randr/randr.c b/randr/randr.c
index 9f3df5f..5c1f70c 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -416,7 +416,7 @@ RRTellChanged(ScreenPtr pScreen)
     int i;
 
     if (pScrPriv->changed) {
-        UpdateCurrentTime();
+        UpdateCurrentTimeIf();
         if (pScrPriv->configChanged) {
             pScrPriv->lastConfigTime = currentTime;
             pScrPriv->configChanged = FALSE;
commit a6de3eac661ff6f23145cdaa49fc722381a1899e
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Jun 7 16:52:20 2012 +1000

    dix: if the scroll valuator reaches INT_MAX, reset to 0
    
    Too much scrolling down may eventually trigger an overflow of the valuator.
    If this happens, reset the valuator to 0 and skip this event for button
    emulation. Clients will have to figure out a way to deal with this, but a
    scroll event from (close to) INT_MAX to 0 is a hint of that it needs to be
    ignored.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>
    (cherry picked from commit 54476b5e4461ff523e935961affabcf0de12c556)

diff --git a/dix/getevents.c b/dix/getevents.c
index dc02611..b78d5ce 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -35,6 +35,7 @@
 #include <X11/keysym.h>
 #include <X11/Xproto.h>
 #include <math.h>
+#include <limits.h>
 
 #include "misc.h"
 #include "resource.h"
@@ -750,6 +751,29 @@ clipAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
     }
 }
 
+static void
+add_to_scroll_valuator(DeviceIntPtr dev, ValuatorMask *mask, int valuator, double value)
+{
+    double v;
+
+    if (!valuator_mask_fetch_double(mask, valuator, &v))
+        return;
+
+    /* protect against scrolling overflow. INT_MAX for double, because
+     * we'll eventually write this as 32.32 fixed point */
+    if ((value > 0 && v > INT_MAX - value) || (value < 0 && v < INT_MIN - value)) {
+        v = 0;
+
+        /* reset last.scroll to avoid a button storm */
+        valuator_mask_set_double(dev->last.scroll, valuator, 0);
+    }
+    else
+        v += value;
+
+    valuator_mask_set_double(mask, valuator, v);
+}
+
+
 /**
  * Move the device's pointer by the values given in @valuators.
  *
@@ -768,13 +792,17 @@ moveRelative(DeviceIntPtr dev, ValuatorMask *mask)
 
         if (!valuator_mask_isset(mask, i))
             continue;
-        val += valuator_mask_get_double(mask, i);
+
+        add_to_scroll_valuator(dev, mask, i, val);
+
         /* x & y need to go over the limits to cross screens if the SD
          * isn't currently attached; otherwise, clip to screen bounds. */
         if (valuator_get_mode(dev, i) == Absolute &&
-            ((i != 0 && i != 1) || clip_xy))
+            ((i != 0 && i != 1) || clip_xy)) {
+            val = valuator_mask_get_double(mask, i);
             clipAxis(dev, i, &val);
-        valuator_mask_set_double(mask, i, val);
+            valuator_mask_set_double(mask, i, val);
+        }
     }
 }
 
@@ -1491,6 +1519,7 @@ emulate_scroll_button_events(InternalEvent *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
@@ -1536,7 +1565,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
      * necessary. This only needs to cater for the XIScrollFlagPreferred
      * axis (if more than one scrolling axis is present) */
     if (type == ButtonPress) {
-        double val, adj;
+        double adj;
         int axis;
         int h_scroll_axis = -1;
         int v_scroll_axis = -1;
@@ -1572,8 +1601,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
 
         if (adj != 0.0 && axis != -1) {
             adj *= pDev->valuator->axes[axis].scroll.increment;
-            val = valuator_mask_get_double(&mask, axis) + adj;
-            valuator_mask_set_double(&mask, axis, val);
+            add_to_scroll_valuator(pDev, &mask, axis, adj);
             type = MotionNotify;
             buttons = 0;
             flags |= POINTER_EMULATED;


More information about the xorg-commit mailing list