Compare commits

..

7 Commits

Author SHA1 Message Date
Peter Hutterer
56e9a7a248 evdev 2.7.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-24 14:05:09 +10:00
Peter Hutterer
7df6523774 Close the fd when mtdev open fails
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 8251d7a8ec)
2012-07-04 08:21:54 +10:00
Peter Hutterer
f4e76a4c53 Release mtdev data whenever we close the fd
Add a new EvdevCloseDevice() function to unify this.
We used to leak data
- PreInit allocates mtdev, but nothing except one error path released it.
- each DEVICE_ON re-allocates mtdev but it is never released

Reported-by: Zdenek Kabelac <zdenek.kabelac@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit ac5173163d)
2012-07-04 08:21:11 +10:00
Chase Douglas
ac772cde94 Fix buffer overrun when populating axis label property array
The axis label property array currently only has enough elements for the
non-multitouch axes. This change allocates enough space for all axes,
which prevents an array overrun write. This may manifest as stack
corruption on some platforms.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 4145fe1c08)
2012-07-04 08:21:03 +10:00
Chase Douglas
7749159241 Report the correct number of touches for MT protocol B devices
Protocol B devices report the number of touches by giving a maximum and
minimum slot value. The current code ignores the minimum value, which is
usually 0, and underreports the number of touches by 1.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 9ce068e760)
2012-07-04 08:20:55 +10:00
Peter Hutterer
833fc517d7 Devices configured as mice need REL_X/Y
Some keyboards export scroll axes and any absolute axis possible in 11
dimensions. All these axes are mute, except possibly for the scroll wheels.

So if a device has a scroll axis, and we're configuring it as mouse, force
the x/y axes into existence. This stops the logspam complaining about not
enough axes on pointer movement after a xrandr change.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit f28507e8ce)
2012-07-04 08:20:50 +10:00
Peter Hutterer
4d698d8ece Fix inverted horizontal scroll (#46205)
REL_HWHEEL has a positive increment, not a negative one like REL_WHEEL.

X.Org Bug 46205 <http://bugs.freedesktop.org/show_bug.cgi?id=46205>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 99340147b9)
2012-07-04 08:20:43 +10:00
3 changed files with 41 additions and 21 deletions

View File

@@ -23,7 +23,7 @@
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xf86-input-evdev],
[2.7.0],
[2.7.1],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
[xf86-input-evdev])
AC_CONFIG_SRCDIR([Makefile.am])

View File

@@ -119,6 +119,7 @@ static int EvdevSwitchMode(ClientPtr client, DeviceIntPtr device, int mode);
static BOOL EvdevGrabDevice(InputInfoPtr pInfo, int grab, int ungrab);
static void EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4]);
static int EvdevOpenDevice(InputInfoPtr pInfo);
static void EvdevCloseDevice(InputInfoPtr pInfo);
static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms);
static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms);
@@ -1108,8 +1109,7 @@ EvdevReadInput(InputInfoPtr pInfo)
EvdevMBEmuFinalize(pInfo);
Evdev3BEmuFinalize(pInfo);
xf86RemoveEnabledDevice(pInfo);
close(pInfo->fd);
pInfo->fd = -1;
EvdevCloseDevice(pInfo);
} else if (errno != EAGAIN)
{
/* We use X_NONE here because it doesn't alloc */
@@ -1304,6 +1304,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
}
#ifdef MULTITOUCH
if (num_mt_axes_total > 0) {
pEvdev->num_mt_vals = num_mt_axes_total;
pEvdev->mt_mask = valuator_mask_new(num_mt_axes_total);
if (!pEvdev->mt_mask) {
xf86Msg(X_ERROR, "%s: failed to allocate MT valuator mask.\n",
@@ -1384,7 +1385,8 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
XIDependentTouch : XIDirectTouch;
if (pEvdev->mtdev->caps.slot.maximum > 0)
num_touches = pEvdev->mtdev->caps.slot.maximum;
num_touches = pEvdev->mtdev->caps.slot.maximum -
pEvdev->mtdev->caps.slot.minimum + 1;
if (!InitTouchClassDeviceStruct(device, num_touches, mode,
num_mt_axes_total)) {
@@ -1600,7 +1602,7 @@ EvdevAddRelValuatorClass(DeviceIntPtr device)
else if (axis == REL_DIAL)
SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, -1.0, SCROLL_FLAG_NONE);
else if (axis == REL_HWHEEL)
SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL, -1.0, SCROLL_FLAG_NONE);
SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE);
#endif
}
@@ -1864,8 +1866,7 @@ EvdevProc(DeviceIntPtr device, int what)
{
EvdevGrabDevice(pInfo, 0, 1);
xf86RemoveEnabledDevice(pInfo);
close(pInfo->fd);
pInfo->fd = -1;
EvdevCloseDevice(pInfo);
}
pEvdev->min_maj = 0;
pEvdev->flags &= ~EVDEV_INITIALIZED;
@@ -1874,10 +1875,7 @@ EvdevProc(DeviceIntPtr device, int what)
case DEVICE_CLOSE:
xf86IDrvMsg(pInfo, X_INFO, "Close\n");
if (pInfo->fd != -1) {
close(pInfo->fd);
pInfo->fd = -1;
}
EvdevCloseDevice(pInfo);
EvdevFreeMasks(pEvdev);
EvdevRemoveDevice(pInfo);
pEvdev->min_maj = 0;
@@ -2271,6 +2269,9 @@ EvdevProbe(InputInfoPtr pInfo)
xf86IDrvMsg(pInfo, X_INFO, "Configuring as touchscreen\n");
pInfo->type_name = XI_TOUCHSCREEN;
} else {
if (!EvdevBitIsSet(pEvdev->rel_bitmask, REL_X) ||
!EvdevBitIsSet(pEvdev->rel_bitmask, REL_Y))
EvdevForceXY(pInfo, Relative);
xf86IDrvMsg(pInfo, X_INFO, "Configuring as mouse\n");
pInfo->type_name = XI_MOUSE;
}
@@ -2354,6 +2355,7 @@ EvdevOpenDevice(InputInfoPtr pInfo)
pEvdev->cur_slot = pEvdev->mtdev->caps.slot.value;
else {
xf86Msg(X_ERROR, "%s: Couldn't open mtdev device\n", pInfo->name);
EvdevCloseDevice(pInfo);
return FALSE;
}
#endif
@@ -2363,17 +2365,34 @@ EvdevOpenDevice(InputInfoPtr pInfo)
if (EvdevIsDuplicate(pInfo))
{
xf86IDrvMsg(pInfo, X_WARNING, "device file is duplicate. Ignoring.\n");
close(pInfo->fd);
#ifdef MULTITOUCH
mtdev_close_delete(pEvdev->mtdev);
pEvdev->mtdev = NULL;
#endif
EvdevCloseDevice(pInfo);
return BadMatch;
}
return Success;
}
static void
EvdevCloseDevice(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = pInfo->private;
if (pInfo->fd >= 0)
{
close(pInfo->fd);
pInfo->fd = -1;
}
#ifdef MULTITOUCH
if (pEvdev->mtdev)
{
mtdev_close_delete(pEvdev->mtdev);
pEvdev->mtdev = NULL;
}
#endif
}
static void
EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
{
@@ -2454,8 +2473,7 @@ EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
return Success;
error:
if (pInfo->fd >= 0)
close(pInfo->fd);
EvdevCloseDevice(pInfo);
return rc;
}
@@ -2875,7 +2893,8 @@ EvdevInitProperty(DeviceIntPtr dev)
if ((pEvdev->num_vals > 0) && (prop_axis_label = XIGetKnownProperty(AXIS_LABEL_PROP)))
{
int mode;
Atom atoms[pEvdev->num_vals];
int num_axes = pEvdev->num_vals + pEvdev->num_mt_vals;
Atom atoms[num_axes];
if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)
mode = Absolute;
@@ -2886,9 +2905,9 @@ EvdevInitProperty(DeviceIntPtr dev)
mode = Absolute;
}
EvdevInitAxesLabels(pEvdev, mode, pEvdev->num_vals, atoms);
EvdevInitAxesLabels(pEvdev, mode, num_axes, atoms);
XIChangeDeviceProperty(dev, prop_axis_label, XA_ATOM, 32,
PropModeReplace, pEvdev->num_vals, atoms, FALSE);
PropModeReplace, num_axes, atoms, FALSE);
XISetDevicePropertyDeletable(dev, prop_axis_label, FALSE);
}
/* Button labelling */

View File

@@ -153,6 +153,7 @@ typedef struct {
int grabDevice; /* grab the event device? */
int num_vals; /* number of valuators */
int num_mt_vals; /* number of multitouch valuators */
int axis_map[max(ABS_CNT, REL_CNT)]; /* Map evdev <axis> to index */
ValuatorMask *vals; /* new values coming in */
ValuatorMask *old_vals; /* old values for calculating relative motion */