diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2012-08-05 18:11:39 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2012-08-05 18:11:39 +0000 |
commit | 9366a4edcadcd46d8250f82e79f0925d2ebecac9 (patch) | |
tree | 28a840e0625fa988a866e9a78edce6c13e409790 /xserver/dix | |
parent | b4fa65f9703e9da8db366bfae869f6bcf90ac7f4 (diff) |
Update to xserver 1.12.3.
Diffstat (limited to 'xserver/dix')
-rw-r--r-- | xserver/dix/getevents.c | 67 | ||||
-rw-r--r-- | xserver/dix/touch.c | 7 |
2 files changed, 61 insertions, 13 deletions
diff --git a/xserver/dix/getevents.c b/xserver/dix/getevents.c index 9dc96174e..b78d5cec0 100644 --- a/xserver/dix/getevents.c +++ b/xserver/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); + } } } @@ -1151,16 +1179,33 @@ static void transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask) { double x, y, ox, oy; + int has_x, has_y; + + has_x = valuator_mask_fetch_double(mask, 0, &ox); + has_y = valuator_mask_fetch_double(mask, 1, &oy); + + if (!has_x && !has_y) + return; + + if (!has_x || !has_y) { + struct pixman_f_transform invert; + + /* undo transformation from last event */ + ox = dev->last.valuators[0]; + oy = dev->last.valuators[1]; + + pixman_f_transform_invert(&invert, &dev->transform); + transform(&invert, &ox, &oy); + + x = ox; + y = oy; + } if (valuator_mask_isset(mask, 0)) ox = x = valuator_mask_get_double(mask, 0); - else - ox = x = dev->last.valuators[0]; if (valuator_mask_isset(mask, 1)) oy = y = valuator_mask_get_double(mask, 1); - else - oy = y = dev->last.valuators[1]; transform(&dev->transform, &x, &y); @@ -1474,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 @@ -1519,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; @@ -1555,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; @@ -1574,7 +1619,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, /* Now turn the smooth-scrolling axes back into emulated button presses * for legacy clients, based on the integer delta between before and now */ for (i = 0; i < valuator_mask_size(&mask); i++) { - if (i >= pDev->valuator->numAxes) + if ( !pDev->valuator || (i >= pDev->valuator->numAxes)) break; if (!valuator_mask_isset(&mask, i)) diff --git a/xserver/dix/touch.c b/xserver/dix/touch.c index 401cb981a..04733ab35 100644 --- a/xserver/dix/touch.c +++ b/xserver/dix/touch.c @@ -460,14 +460,17 @@ TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev) void TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource) { - InternalEvent *tel = InitEventList(GetMaximumEventsNum()); - ValuatorMask *mask = valuator_mask_new(0); + InternalEvent *tel; + ValuatorMask *mask; int i, nev; int flags; if (!ti->history) return; + tel = InitEventList(GetMaximumEventsNum()); + mask = valuator_mask_new(0); + valuator_mask_set_double(mask, 0, ti->history[0].valuators.data[0]); valuator_mask_set_double(mask, 1, ti->history[0].valuators.data[1]); |