... |
... |
@@ -52,6 +52,9 @@ |
52
|
52
|
#define TABLET_NUM_BUTTONS 7 /* we need scroll buttons */
|
53
|
53
|
#define TOUCH_MAX_SLOTS 15
|
54
|
54
|
#define XORG_KEYCODE_OFFSET 8
|
|
55
|
+#define SCROLL_INCREMENT 15
|
|
56
|
+#define TOUCHPAD_SCROLL_DIST_MIN 10 /* in libinput pixels */
|
|
57
|
+#define TOUCHPAD_SCROLL_DIST_MAX 50 /* in libinput pixels */
|
55
|
58
|
|
56
|
59
|
#define streq(a, b) (strcmp(a, b) == 0)
|
57
|
60
|
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
|
... |
... |
@@ -146,6 +149,7 @@ struct xf86libinput { |
146
|
149
|
CARD32 sendevents;
|
147
|
150
|
CARD32 scroll_button; /* xorg button number */
|
148
|
151
|
BOOL scroll_buttonlock;
|
|
152
|
+ uint32_t scroll_pixel_distance;
|
149
|
153
|
float speed;
|
150
|
154
|
float matrix[9];
|
151
|
155
|
enum libinput_config_scroll_method scroll_method;
|
... |
... |
@@ -1621,7 +1625,17 @@ calculate_axis_value(struct xf86libinput *driver_data, |
1621
|
1625
|
if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) {
|
1622
|
1626
|
value = get_wheel_scroll_value(driver_data, event, axis);
|
1623
|
1627
|
} else {
|
|
1628
|
+ double dist = driver_data->options.scroll_pixel_distance;
|
|
1629
|
+ assert(dist != 0.0);
|
|
1630
|
+
|
1624
|
1631
|
value = libinput_event_pointer_get_axis_value(event, axis);
|
|
1632
|
+ /* We need to scale this value into our scroll increment range
|
|
1633
|
+ * because that one is constant for the lifetime of the
|
|
1634
|
+ * device. The user may change the ScrollPixelDistance
|
|
1635
|
+ * though, so where we have a dist of 10 but an increment of
|
|
1636
|
+ * 15, we need to scale from 0..10 into 0..15.
|
|
1637
|
+ */
|
|
1638
|
+ value = value/dist * SCROLL_INCREMENT;
|
1625
|
1639
|
}
|
1626
|
1640
|
|
1627
|
1641
|
*value_out = value;
|
... |
... |
@@ -2826,6 +2840,39 @@ xf86libinput_parse_scrollbuttonlock_option(InputInfoPtr pInfo, |
2826
|
2840
|
return buttonlock;
|
2827
|
2841
|
}
|
2828
|
2842
|
|
|
2843
|
+static inline bool
|
|
2844
|
+xf86libinput_want_scroll_distance_option(struct libinput_device *device)
|
|
2845
|
+{
|
|
2846
|
+ uint32_t methods =
|
|
2847
|
+ LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN |
|
|
2848
|
+ LIBINPUT_CONFIG_SCROLL_2FG |
|
|
2849
|
+ LIBINPUT_CONFIG_SCROLL_EDGE;
|
|
2850
|
+
|
|
2851
|
+ if ((libinput_device_config_scroll_get_methods(device) & methods) == 0)
|
|
2852
|
+ return false;
|
|
2853
|
+
|
|
2854
|
+ return true;
|
|
2855
|
+}
|
|
2856
|
+
|
|
2857
|
+static inline uint32_t
|
|
2858
|
+xf86libinput_parse_scroll_pixel_distance_option(InputInfoPtr pInfo,
|
|
2859
|
+ struct libinput_device *device)
|
|
2860
|
+{
|
|
2861
|
+ uint32_t dflt = SCROLL_INCREMENT;
|
|
2862
|
+ uint32_t dist;
|
|
2863
|
+
|
|
2864
|
+ if (!xf86libinput_want_scroll_distance_option(device))
|
|
2865
|
+ return dflt;
|
|
2866
|
+
|
|
2867
|
+ dist = xf86SetIntOption(pInfo->options, "ScrollPixelDistance", dflt);
|
|
2868
|
+ if (dist < TOUCHPAD_SCROLL_DIST_MIN || dist > TOUCHPAD_SCROLL_DIST_MAX) {
|
|
2869
|
+ xf86IDrvMsg(pInfo, X_ERROR,
|
|
2870
|
+ "Invalid ScrollPixelDistance %d\n", dist);
|
|
2871
|
+ dist = dflt;
|
|
2872
|
+ }
|
|
2873
|
+ return dist;
|
|
2874
|
+}
|
|
2875
|
+
|
2829
|
2876
|
static inline unsigned int
|
2830
|
2877
|
xf86libinput_parse_clickmethod_option(InputInfoPtr pInfo,
|
2831
|
2878
|
struct libinput_device *device)
|
... |
... |
@@ -3107,6 +3154,7 @@ xf86libinput_parse_options(InputInfoPtr pInfo, |
3107
|
3154
|
options->scroll_method = xf86libinput_parse_scroll_option(pInfo, device);
|
3108
|
3155
|
options->scroll_button = xf86libinput_parse_scrollbutton_option(pInfo, device);
|
3109
|
3156
|
options->scroll_buttonlock = xf86libinput_parse_scrollbuttonlock_option(pInfo, device);
|
|
3157
|
+ options->scroll_pixel_distance = xf86libinput_parse_scroll_pixel_distance_option(pInfo, device);
|
3110
|
3158
|
options->click_method = xf86libinput_parse_clickmethod_option(pInfo, device);
|
3111
|
3159
|
options->middle_emulation = xf86libinput_parse_middleemulation_option(pInfo, device);
|
3112
|
3160
|
options->disable_while_typing = xf86libinput_parse_disablewhiletyping_option(pInfo, device);
|
... |
... |
@@ -3420,8 +3468,8 @@ xf86libinput_pre_init(InputDriverPtr drv, |
3420
|
3468
|
* affect touchpad scroll speed. For wheels it doesn't matter as
|
3421
|
3469
|
* we're using the discrete value only.
|
3422
|
3470
|
*/
|
3423
|
|
- driver_data->scroll.v.dist = 15;
|
3424
|
|
- driver_data->scroll.h.dist = 15;
|
|
3471
|
+ driver_data->scroll.v.dist = SCROLL_INCREMENT;
|
|
3472
|
+ driver_data->scroll.h.dist = SCROLL_INCREMENT;
|
3425
|
3473
|
|
3426
|
3474
|
if (!is_subdevice) {
|
3427
|
3475
|
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
|
... |
... |
@@ -3563,6 +3611,8 @@ static Atom prop_scroll_button; |
3563
|
3611
|
static Atom prop_scroll_button_default;
|
3564
|
3612
|
static Atom prop_scroll_buttonlock;
|
3565
|
3613
|
static Atom prop_scroll_buttonlock_default;
|
|
3614
|
+static Atom prop_scroll_pixel_distance;
|
|
3615
|
+static Atom prop_scroll_pixel_distance_default;
|
3566
|
3616
|
static Atom prop_click_methods_available;
|
3567
|
3617
|
static Atom prop_click_method_enabled;
|
3568
|
3618
|
static Atom prop_click_method_default;
|
... |
... |
@@ -3684,7 +3734,7 @@ update_mode_prop(InputInfoPtr pInfo, |
3684
|
3734
|
}
|
3685
|
3735
|
|
3686
|
3736
|
static inline BOOL
|
3687
|
|
-xf86libinput_check_device (DeviceIntPtr dev,
|
|
3737
|
+xf86libinput_check_device(DeviceIntPtr dev,
|
3688
|
3738
|
Atom atom)
|
3689
|
3739
|
{
|
3690
|
3740
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
... |
... |
@@ -3722,7 +3772,7 @@ LibinputSetPropertyTap(DeviceIntPtr dev, |
3722
|
3772
|
if (*data != 0 && *data != 1)
|
3723
|
3773
|
return BadValue;
|
3724
|
3774
|
|
3725
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
3775
|
+ if (!xf86libinput_check_device(dev, atom))
|
3726
|
3776
|
return BadMatch;
|
3727
|
3777
|
|
3728
|
3778
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
... |
... |
@@ -3816,7 +3866,7 @@ LibinputSetPropertyTapButtonmap(DeviceIntPtr dev, |
3816
|
3866
|
if ((data[0] && data[1]) || (!data[0] && !data[1]))
|
3817
|
3867
|
return BadValue;
|
3818
|
3868
|
|
3819
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
3869
|
+ if (!xf86libinput_check_device(dev, atom))
|
3820
|
3870
|
return BadMatch;
|
3821
|
3871
|
}
|
3822
|
3872
|
|
... |
... |
@@ -3855,7 +3905,7 @@ LibinputSetPropertyCalibration(DeviceIntPtr dev, |
3855
|
3905
|
data[8] != 1.0)
|
3856
|
3906
|
return BadValue;
|
3857
|
3907
|
|
3858
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
3908
|
+ if (!xf86libinput_check_device(dev, atom))
|
3859
|
3909
|
return BadMatch;
|
3860
|
3910
|
|
3861
|
3911
|
if (!libinput_device_config_calibration_has_matrix(device))
|
... |
... |
@@ -3889,7 +3939,7 @@ LibinputSetPropertyAccel(DeviceIntPtr dev, |
3889
|
3939
|
if (*data < -1.0 || *data > 1.0)
|
3890
|
3940
|
return BadValue;
|
3891
|
3941
|
|
3892
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
3942
|
+ if (!xf86libinput_check_device(dev, atom))
|
3893
|
3943
|
return BadMatch;
|
3894
|
3944
|
|
3895
|
3945
|
if (libinput_device_config_accel_is_available(device) == 0)
|
... |
... |
@@ -3929,7 +3979,7 @@ LibinputSetPropertyAccelProfile(DeviceIntPtr dev, |
3929
|
3979
|
if (__builtin_popcount(profiles) > 1)
|
3930
|
3980
|
return BadValue;
|
3931
|
3981
|
|
3932
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
3982
|
+ if (!xf86libinput_check_device(dev, atom))
|
3933
|
3983
|
return BadMatch;
|
3934
|
3984
|
|
3935
|
3985
|
supported = libinput_device_config_accel_get_profiles(device);
|
... |
... |
@@ -3962,7 +4012,7 @@ LibinputSetPropertyNaturalScroll(DeviceIntPtr dev, |
3962
|
4012
|
if (*data != 0 && *data != 1)
|
3963
|
4013
|
return BadValue;
|
3964
|
4014
|
|
3965
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
4015
|
+ if (!xf86libinput_check_device(dev, atom))
|
3966
|
4016
|
return BadMatch;
|
3967
|
4017
|
|
3968
|
4018
|
if (libinput_device_config_scroll_has_natural_scroll(device) == 0)
|
... |
... |
@@ -3999,7 +4049,7 @@ LibinputSetPropertySendEvents(DeviceIntPtr dev, |
3999
|
4049
|
if (checkonly) {
|
4000
|
4050
|
uint32_t supported;
|
4001
|
4051
|
|
4002
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
4052
|
+ if (!xf86libinput_check_device(dev, atom))
|
4003
|
4053
|
return BadMatch;
|
4004
|
4054
|
|
4005
|
4055
|
supported = libinput_device_config_send_events_get_modes(device);
|
... |
... |
@@ -4033,7 +4083,7 @@ LibinputSetPropertyLeftHanded(DeviceIntPtr dev, |
4033
|
4083
|
int supported;
|
4034
|
4084
|
int left_handed = *data;
|
4035
|
4085
|
|
4036
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
4086
|
+ if (!xf86libinput_check_device(dev, atom))
|
4037
|
4087
|
return BadMatch;
|
4038
|
4088
|
|
4039
|
4089
|
supported = libinput_device_config_left_handed_is_available(device);
|
... |
... |
@@ -4097,7 +4147,7 @@ LibinputSetPropertyScrollMethods(DeviceIntPtr dev, |
4097
|
4147
|
if (__builtin_popcount(modes) > 1)
|
4098
|
4148
|
return BadValue;
|
4099
|
4149
|
|
4100
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
4150
|
+ if (!xf86libinput_check_device(dev, atom))
|
4101
|
4151
|
return BadMatch;
|
4102
|
4152
|
|
4103
|
4153
|
supported = libinput_device_config_scroll_get_methods(device);
|
... |
... |
@@ -4130,7 +4180,7 @@ LibinputSetPropertyScrollButton(DeviceIntPtr dev, |
4130
|
4180
|
uint32_t button = *data;
|
4131
|
4181
|
uint32_t supported;
|
4132
|
4182
|
|
4133
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
4183
|
+ if (!xf86libinput_check_device(dev, atom))
|
4134
|
4184
|
return BadMatch;
|
4135
|
4185
|
|
4136
|
4186
|
supported = libinput_device_pointer_has_button(device,
|
... |
... |
@@ -4162,7 +4212,7 @@ LibinputSetPropertyScrollButtonLock(DeviceIntPtr dev, |
4162
|
4212
|
if (enabled != 0 && enabled != 1)
|
4163
|
4213
|
return BadValue;
|
4164
|
4214
|
|
4165
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
4215
|
+ if (!xf86libinput_check_device(dev, atom))
|
4166
|
4216
|
return BadMatch;
|
4167
|
4217
|
} else {
|
4168
|
4218
|
driver_data->options.scroll_buttonlock = enabled;
|
... |
... |
@@ -4371,7 +4421,7 @@ LibinputSetPropertyHorizScroll(DeviceIntPtr dev, |
4371
|
4421
|
if (enabled != 0 && enabled != 1)
|
4372
|
4422
|
return BadValue;
|
4373
|
4423
|
|
4374
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
4424
|
+ if (!xf86libinput_check_device(dev, atom))
|
4375
|
4425
|
return BadMatch;
|
4376
|
4426
|
} else {
|
4377
|
4427
|
driver_data->options.horiz_scrolling_enabled = enabled;
|
... |
... |
@@ -4380,6 +4430,34 @@ LibinputSetPropertyHorizScroll(DeviceIntPtr dev, |
4380
|
4430
|
return Success;
|
4381
|
4431
|
}
|
4382
|
4432
|
|
|
4433
|
+static inline int
|
|
4434
|
+LibinputSetPropertyScrollPixelDistance(DeviceIntPtr dev,
|
|
4435
|
+ Atom atom,
|
|
4436
|
+ XIPropertyValuePtr val,
|
|
4437
|
+ BOOL checkonly)
|
|
4438
|
+{
|
|
4439
|
+ InputInfoPtr pInfo = dev->public.devicePrivate;
|
|
4440
|
+ struct xf86libinput *driver_data = pInfo->private;
|
|
4441
|
+ uint32_t dist;
|
|
4442
|
+
|
|
4443
|
+ if (val->format != 32 || val->type != XA_CARDINAL || val->size != 1)
|
|
4444
|
+ return BadMatch;
|
|
4445
|
+
|
|
4446
|
+ dist = *(BOOL*)val->data;
|
|
4447
|
+ if (checkonly) {
|
|
4448
|
+ if (dist < TOUCHPAD_SCROLL_DIST_MIN ||
|
|
4449
|
+ dist > TOUCHPAD_SCROLL_DIST_MAX)
|
|
4450
|
+ return BadValue;
|
|
4451
|
+
|
|
4452
|
+ if (!xf86libinput_check_device(dev, atom))
|
|
4453
|
+ return BadMatch;
|
|
4454
|
+ } else {
|
|
4455
|
+ driver_data->options.scroll_pixel_distance = dist;
|
|
4456
|
+ }
|
|
4457
|
+
|
|
4458
|
+ return Success;
|
|
4459
|
+}
|
|
4460
|
+
|
4383
|
4461
|
static inline int
|
4384
|
4462
|
LibinputSetPropertyRotationAngle(DeviceIntPtr dev,
|
4385
|
4463
|
Atom atom,
|
... |
... |
@@ -4400,7 +4478,7 @@ LibinputSetPropertyRotationAngle(DeviceIntPtr dev, |
4400
|
4478
|
if (*angle < 0.0 || *angle >= 360.0)
|
4401
|
4479
|
return BadValue;
|
4402
|
4480
|
|
4403
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
4481
|
+ if (!xf86libinput_check_device(dev, atom))
|
4404
|
4482
|
return BadMatch;
|
4405
|
4483
|
|
4406
|
4484
|
if (libinput_device_config_rotation_is_available(device) == 0)
|
... |
... |
@@ -4444,7 +4522,7 @@ LibinputSetPropertyPressureCurve(DeviceIntPtr dev, |
4444
|
4522
|
return BadValue;
|
4445
|
4523
|
}
|
4446
|
4524
|
|
4447
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
4525
|
+ if (!xf86libinput_check_device(dev, atom))
|
4448
|
4526
|
return BadMatch;
|
4449
|
4527
|
|
4450
|
4528
|
if (!cubic_bezier(controls, test_bezier, ARRAY_SIZE(test_bezier)))
|
... |
... |
@@ -4484,7 +4562,7 @@ LibinputSetPropertyAreaRatio(DeviceIntPtr dev, |
4484
|
4562
|
(area.x == 0 && area.y != 0))
|
4485
|
4563
|
return BadValue;
|
4486
|
4564
|
|
4487
|
|
- if (!xf86libinput_check_device (dev, atom))
|
|
4565
|
+ if (!xf86libinput_check_device(dev, atom))
|
4488
|
4566
|
return BadMatch;
|
4489
|
4567
|
} else {
|
4490
|
4568
|
struct xf86libinput *other;
|
... |
... |
@@ -4557,6 +4635,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, |
4557
|
4635
|
rc = LibinputSetPropertyDragLockButtons(dev, atom, val, checkonly);
|
4558
|
4636
|
else if (atom == prop_horiz_scroll)
|
4559
|
4637
|
rc = LibinputSetPropertyHorizScroll(dev, atom, val, checkonly);
|
|
4638
|
+ else if (atom == prop_scroll_pixel_distance)
|
|
4639
|
+ rc = LibinputSetPropertyScrollPixelDistance(dev, atom, val, checkonly);
|
4560
|
4640
|
else if (atom == prop_mode_groups) {
|
4561
|
4641
|
InputInfoPtr pInfo = dev->public.devicePrivate;
|
4562
|
4642
|
struct xf86libinput *driver_data = pInfo->private;
|
... |
... |
@@ -4588,6 +4668,7 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, |
4588
|
4668
|
atom == prop_scroll_methods_available ||
|
4589
|
4669
|
atom == prop_scroll_button_default ||
|
4590
|
4670
|
atom == prop_scroll_buttonlock_default ||
|
|
4671
|
+ atom == prop_scroll_pixel_distance_default ||
|
4591
|
4672
|
atom == prop_click_method_default ||
|
4592
|
4673
|
atom == prop_click_methods_available ||
|
4593
|
4674
|
atom == prop_middle_emulation_default ||
|
... |
... |
@@ -5114,6 +5195,32 @@ LibinputInitScrollMethodsProperty(DeviceIntPtr dev, |
5114
|
5195
|
}
|
5115
|
5196
|
}
|
5116
|
5197
|
|
|
5198
|
+static void
|
|
5199
|
+LibinputInitScrollPixelDistanceProperty(DeviceIntPtr dev,
|
|
5200
|
+ struct xf86libinput *driver_data,
|
|
5201
|
+ struct libinput_device *device)
|
|
5202
|
+{
|
|
5203
|
+ CARD32 dist = driver_data->options.scroll_pixel_distance;
|
|
5204
|
+
|
|
5205
|
+ if (!subdevice_has_capabilities(dev, CAP_POINTER))
|
|
5206
|
+ return;
|
|
5207
|
+
|
|
5208
|
+ if (!xf86libinput_want_scroll_distance_option(device))
|
|
5209
|
+ return;
|
|
5210
|
+
|
|
5211
|
+ prop_scroll_pixel_distance = LibinputMakeProperty(dev,
|
|
5212
|
+ LIBINPUT_PROP_SCROLL_PIXEL_DISTANCE,
|
|
5213
|
+ XA_CARDINAL, 32,
|
|
5214
|
+ 1, &dist);
|
|
5215
|
+ if (!prop_scroll_pixel_distance)
|
|
5216
|
+ return;
|
|
5217
|
+
|
|
5218
|
+ prop_scroll_pixel_distance_default = LibinputMakeProperty(dev,
|
|
5219
|
+ LIBINPUT_PROP_SCROLL_PIXEL_DISTANCE_DEFAULT,
|
|
5220
|
+ XA_CARDINAL, 32,
|
|
5221
|
+ 1, &dist);
|
|
5222
|
+}
|
|
5223
|
+
|
5117
|
5224
|
static void
|
5118
|
5225
|
LibinputInitClickMethodsProperty(DeviceIntPtr dev,
|
5119
|
5226
|
struct xf86libinput *driver_data,
|
... |
... |
@@ -5555,6 +5662,7 @@ LibinputInitProperty(DeviceIntPtr dev) |
5555
|
5662
|
|
5556
|
5663
|
LibinputInitDragLockProperty(dev, driver_data);
|
5557
|
5664
|
LibinputInitHorizScrollProperty(dev, driver_data);
|
|
5665
|
+ LibinputInitScrollPixelDistanceProperty(dev, driver_data, device);
|
5558
|
5666
|
LibinputInitPressureCurveProperty(dev, driver_data);
|
5559
|
5667
|
LibinputInitTabletAreaRatioProperty(dev, driver_data);
|
5560
|
5668
|
}
|