tablet: always initialize the pressure thresholds

When the tool is moved in proximity of a new tablet but the pressure
range hasn't changed since the last proximity, the new tablet was left
with a threshold range of 0:0.

For some reason this requires tightening up the check for the test too,
with our default episolon 0.091 fails the test of being > 0.9

Closes #1109

Fixes: 48cd4c7287 ("tablet: track pressure ranges per tablet")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1165>
This commit is contained in:
Peter Hutterer 2025-03-31 12:16:52 +10:00
parent be679889e5
commit fc4e806e0b
2 changed files with 11 additions and 9 deletions

View file

@ -1202,12 +1202,14 @@ tablet_get_quirked_pressure_thresholds(struct tablet_dispatch *tablet,
static void
apply_pressure_range_configuration(struct tablet_dispatch *tablet,
struct libinput_tablet_tool *tool)
struct libinput_tablet_tool *tool,
bool force_update)
{
struct evdev_device *device = tablet->device;
if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_PRESSURE) ||
(tool->pressure.range.min == tool->pressure.wanted_range.min &&
(!force_update &&
tool->pressure.range.min == tool->pressure.wanted_range.min &&
tool->pressure.range.max == tool->pressure.wanted_range.max))
return;
@ -1258,13 +1260,13 @@ tool_init_pressure_thresholds(struct tablet_dispatch *tablet,
threshold->tablet_id = tablet->tablet_id;
threshold->offset = 0;
threshold->has_offset = false;
threshold->threshold.upper = 1;
threshold->threshold.lower = 0;
pressure = libevdev_get_abs_info(device->evdev, ABS_PRESSURE);
if (!pressure) {
threshold->threshold.upper = 1;
threshold->threshold.lower = 0;
if (!pressure)
return;
}
threshold->abs_pressure = *pressure;
distance = libevdev_get_abs_info(device->evdev, ABS_DISTANCE);
@ -1276,7 +1278,7 @@ tool_init_pressure_thresholds(struct tablet_dispatch *tablet,
threshold->heuristic_state = PRESSURE_HEURISTIC_STATE_PROXIN1;
}
apply_pressure_range_configuration(tablet, tool);
apply_pressure_range_configuration(tablet, tool, true);
}
static int
@ -2211,7 +2213,7 @@ reprocess:
tablet_set_status(tablet, TABLET_BUTTONS_RELEASED);
if (tablet_has_status(tablet, TABLET_TOOL_IN_CONTACT))
tablet_set_status(tablet, TABLET_TOOL_LEAVING_CONTACT);
apply_pressure_range_configuration(tablet, tool);
apply_pressure_range_configuration(tablet, tool, false);
} else if (!tablet_has_status(tablet, TABLET_TOOL_OUTSIDE_AREA)) {
if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY)) {
/* If we get into proximity outside the tablet area, we ignore

View file

@ -5131,7 +5131,7 @@ START_TEST(tablet_pressure_across_multiple_tablets)
double pressure = libinput_event_tablet_tool_get_pressure(tev);
/* We start at device range 10% but we always have a small threshold */
litest_assert_double_gt(pressure, 0.09);
litest_assert_double_gt_epsilon(pressure, 0.09, 0);
litest_assert_double_le(pressure, 0.7);
libinput_event_destroy(ev);