diff options
Diffstat (limited to 'src/evdev.c')
-rw-r--r-- | src/evdev.c | 81 |
1 files changed, 67 insertions, 14 deletions
diff --git a/src/evdev.c b/src/evdev.c index 812b177..c2ce29d 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -140,6 +140,7 @@ static Atom prop_axis_label; static Atom prop_btn_label; static Atom prop_device; static Atom prop_virtual; +static Atom prop_scroll_dist; /* All devices the evdev driver has allocated and knows about. * MAXDEVICES is safe as null-terminated array, as two devices (VCP and VCK) @@ -1620,6 +1621,42 @@ out: } static int +EvdevSetScrollValuators(DeviceIntPtr device) +{ +#ifdef HAVE_SMOOTH_SCROLLING + InputInfoPtr pInfo; + EvdevPtr pEvdev; + int axnum; + + pInfo = device->public.devicePrivate; + pEvdev = pInfo->private; + + axnum = pEvdev->rel_axis_map[REL_WHEEL]; + if (axnum != -1) { + SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, + -pEvdev->smoothScroll.vert_delta, + SCROLL_FLAG_PREFERRED); + } + + axnum = pEvdev->rel_axis_map[REL_DIAL]; + if (axnum != -1) { + SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, + -pEvdev->smoothScroll.dial_delta, + SCROLL_FLAG_NONE); + } + + axnum = pEvdev->rel_axis_map[REL_HWHEEL]; + if (axnum != -1) { + SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL, + pEvdev->smoothScroll.horiz_delta, + SCROLL_FLAG_NONE); + } +#endif + + return Success; +} + +static int EvdevAddRelValuatorClass(DeviceIntPtr device) { InputInfoPtr pInfo; @@ -1703,22 +1740,10 @@ EvdevAddRelValuatorClass(DeviceIntPtr device) xf86InitValuatorAxisStruct(device, axnum, atoms[axnum], -1, -1, 1, 0, 1, Relative); xf86InitValuatorDefaults(device, axnum); -#ifdef HAVE_SMOOTH_SCROLLING - if (axis == REL_WHEEL) - SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, - -pEvdev->smoothScroll.vert_delta, - SCROLL_FLAG_PREFERRED); - else if (axis == REL_DIAL) - SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, - -pEvdev->smoothScroll.dial_delta, - SCROLL_FLAG_NONE); - else if (axis == REL_HWHEEL) - SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL, - pEvdev->smoothScroll.horiz_delta, - SCROLL_FLAG_NONE); -#endif } + EvdevSetScrollValuators(device); + free(atoms); return Success; @@ -2917,6 +2942,22 @@ EvdevInitProperty(DeviceIntPtr dev) PropModeReplace, pEvdev->num_buttons, atoms, FALSE); XISetDevicePropertyDeletable(dev, prop_btn_label, FALSE); } + +#ifdef HAVE_SMOOTH_SCROLLING + { + int smooth_scroll_values[3] = { + pEvdev->smoothScroll.vert_delta, + pEvdev->smoothScroll.horiz_delta, + pEvdev->smoothScroll.dial_delta + }; + prop_scroll_dist = MakeAtom(EVDEV_PROP_SCROLL_DISTANCE, + strlen(EVDEV_PROP_SCROLL_DISTANCE), TRUE); + XIChangeDeviceProperty(dev, prop_scroll_dist, XA_INTEGER, 32, + PropModeReplace, 3, smooth_scroll_values, FALSE); + XISetDevicePropertyDeletable(dev, prop_scroll_dist, FALSE); + } +#endif + } } @@ -2956,6 +2997,18 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, if (!checkonly) pEvdev->swap_axes = *((BOOL*)val->data); + } else if (atom == prop_scroll_dist) + { + if (val->format != 32 || val->type != XA_INTEGER || val->size != 3) + return BadMatch; + + if (!checkonly) { + int *data = (int *)val->data; + pEvdev->smoothScroll.vert_delta = data[0]; + pEvdev->smoothScroll.horiz_delta = data[1]; + pEvdev->smoothScroll.dial_delta = data[2]; + EvdevSetScrollValuators(dev); + } } else if (atom == prop_axis_label || atom == prop_btn_label || atom == prop_product_id || atom == prop_device || atom == prop_virtual) |