diff options
author | marha <marha@users.sourceforge.net> | 2012-06-29 16:09:45 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-06-29 16:09:45 +0200 |
commit | 8e69b2fa996acf8fa1d218b67a203eb67e280899 (patch) | |
tree | 1caebab7024f5b62dc57e49a69a20ef10cb8210f /xorg-server/dix/getevents.c | |
parent | cd103d3f4d59ac4f09cfcf126e572ddb0b9d4628 (diff) | |
parent | f6d1847eef027266daa0f75ee92ceb09698b2761 (diff) | |
download | vcxsrv-8e69b2fa996acf8fa1d218b67a203eb67e280899.tar.gz vcxsrv-8e69b2fa996acf8fa1d218b67a203eb67e280899.tar.bz2 vcxsrv-8e69b2fa996acf8fa1d218b67a203eb67e280899.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
xorg-server/hw/xwin/glx/gen_gl_wrappers.py
xorg-server/hw/xwin/glx/indirect.c
Diffstat (limited to 'xorg-server/dix/getevents.c')
-rw-r--r-- | xorg-server/dix/getevents.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c index e1b26783f..9d9214b6d 100644 --- a/xorg-server/dix/getevents.c +++ b/xorg-server/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" @@ -771,6 +772,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. * @@ -789,13 +813,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); + } } } @@ -1527,6 +1555,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 @@ -1581,7 +1610,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; @@ -1617,8 +1646,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; |