[PATCH v4] dix: copy the valuators passed into GPE/GKVE/GProxE.
Peter Hutterer
peter.hutterer at who-t.net
Sun Aug 15 21:18:45 PDT 2010
GPE and friends modify the valuators array passed in. Which means any driver
using e.g. xf86PostButtonEventP(..., valuators) twice to emulate a button
click will provide garbage data on the second run.
This is currently affecting the wacom driver, xf86PostButtonEventP() with
valuators is required to have input events with device-specific axis values.
Passing the same valuators in twice, once with press, once with release,
will see the valuators modified in the first call and garbage submitted in
the next one.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to v3:
- use static size for array, not alloca()
dix/getevents.c | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/dix/getevents.c b/dix/getevents.c
index a9b6e82..b1014e1 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -912,17 +912,19 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type, int key_code)
int
GetKeyboardValuatorEvents(EventList *events, DeviceIntPtr pDev, int type,
int key_code, int first_valuator,
- int num_valuators, int *valuators) {
+ int num_valuators, int *valuators_in) {
int num_events = 0;
CARD32 ms = 0;
DeviceEvent *event;
RawDeviceEvent *raw;
+ int valuators[MAX_VALUATORS];
/* refuse events from disabled devices */
if (!pDev->enabled)
return 0;
if (!events ||!pDev->key || !pDev->focus || !pDev->kbdfeed ||
+ num_valuators > MAX_VALUATORS ||
(type != KeyPress && type != KeyRelease) ||
(key_code < 8 || key_code > 255))
return 0;
@@ -947,6 +949,8 @@ GetKeyboardValuatorEvents(EventList *events, DeviceIntPtr pDev, int type,
events++;
num_events++;
+ memcpy(valuators, valuators_in, num_valuators * sizeof(int));
+
init_raw(pDev, raw, ms, type, key_code);
set_raw_valuators(raw, first_valuator, num_valuators, valuators,
raw->valuators.data_raw);
@@ -1067,7 +1071,7 @@ transformAbsolute(DeviceIntPtr dev, int v[MAX_VALUATORS])
int
GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
int flags, int first_valuator, int num_valuators,
- int *valuators) {
+ int *valuators_in) {
int num_events = 1;
CARD32 ms;
DeviceEvent *event;
@@ -1076,6 +1080,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
cx, cy; /* only screen coordinates */
float x_frac = 0.0, y_frac = 0.0, cx_frac, cy_frac;
ScreenPtr scr = miPointerGetScreen(pDev);
+ int valuators[MAX_VALUATORS];
/* refuse events from disabled devices */
if (!pDev->enabled)
@@ -1084,6 +1089,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
ms = GetTimeInMillis(); /* before pointer update to help precision */
if (!scr || !pDev->valuator || first_valuator < 0 ||
+ num_valuators > MAX_VALUATORS ||
((num_valuators + first_valuator) > pDev->valuator->numAxes) ||
(type != MotionNotify && type != ButtonPress && type != ButtonRelease) ||
(type != MotionNotify && !pDev->button) ||
@@ -1097,6 +1103,8 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
events++;
num_events++;
+ memcpy(valuators, valuators_in, num_valuators * sizeof(int));
+
init_raw(pDev, raw, ms, type, buttons);
set_raw_valuators(raw, first_valuator, num_valuators, valuators,
raw->valuators.data_raw);
@@ -1183,10 +1191,11 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
*/
int
GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type,
- int first_valuator, int num_valuators, int *valuators)
+ int first_valuator, int num_valuators, int *valuators_in)
{
int num_events = 1;
DeviceEvent *event;
+ int valuators[MAX_VALUATORS];
/* refuse events from disabled devices */
if (!pDev->enabled)
@@ -1202,7 +1211,7 @@ GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type,
num_valuators = 0;
/* You fail. */
- if (first_valuator < 0 ||
+ if (first_valuator < 0 || num_valuators > MAX_VALUATORS ||
(num_valuators + first_valuator) > pDev->valuator->numAxes)
return 0;
@@ -1212,8 +1221,10 @@ GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type,
init_event(pDev, event, GetTimeInMillis());
event->type = (type == ProximityIn) ? ET_ProximityIn : ET_ProximityOut;
- if (num_valuators)
+ if (num_valuators) {
+ memcpy(valuators, valuators_in, num_valuators * sizeof(int));
clipValuators(pDev, first_valuator, num_valuators, valuators);
+ }
set_valuators(pDev, event, first_valuator, num_valuators, valuators);
--
1.7.2.1
More information about the xorg-devel
mailing list