diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index 6abf9d5f..9c1c096c 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -527,8 +527,8 @@ tp_init_softbuttons(struct tp_dispatch *tp, xoffset = absinfo_x->minimum, yoffset = absinfo_y->minimum; yres = absinfo_y->resolution; - width = abs(absinfo_x->maximum - absinfo_x->minimum); - height = abs(absinfo_y->maximum - absinfo_y->minimum); + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; /* button height: 10mm or 15% of the touchpad height, whichever is smaller */ @@ -558,8 +558,8 @@ tp_init_top_softbuttons(struct tp_dispatch *tp, xoffset = absinfo_x->minimum, yoffset = absinfo_y->minimum; yres = absinfo_y->resolution; - width = abs(absinfo_x->maximum - absinfo_x->minimum); - height = abs(absinfo_y->maximum - absinfo_y->minimum); + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; if (tp->buttons.has_topbuttons) { /* T440s has the top button line 5mm from the top, event @@ -742,8 +742,8 @@ tp_init_buttons(struct tp_dispatch *tp, The MAGIC for resolution-less touchpads ends up as 2% of the diagonal */ if (device->abs.fake_resolution) { const double BUTTON_MOTION_MAGIC = 0.007; - width = abs(absinfo_x->maximum - absinfo_x->minimum); - height = abs(absinfo_y->maximum - absinfo_y->minimum); + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; diagonal = sqrt(width*width + height*height); tp->buttons.motion_dist.x_scale_coeff = diagonal * BUTTON_MOTION_MAGIC; tp->buttons.motion_dist.y_scale_coeff = diagonal * BUTTON_MOTION_MAGIC; @@ -838,10 +838,8 @@ tp_check_clickfinger_distance(struct tp_dispatch *tp, /* Use a maximum of 30% of the touchpad width or height if * we dont' have resolution. */ - w = tp->device->abs.absinfo_x->maximum - - tp->device->abs.absinfo_x->minimum; - h = tp->device->abs.absinfo_y->maximum - - tp->device->abs.absinfo_y->minimum; + w = tp->device->abs.dimensions.x; + h = tp->device->abs.dimensions.y; return (x < w * 0.3 && y < h * 0.3) ? 1 : 0; } else { diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index 6bfef904..9a9d3b84 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -275,8 +275,8 @@ tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device) int width, height; int edge_width, edge_height; - width = device->abs.absinfo_x->maximum - device->abs.absinfo_x->minimum; - height = device->abs.absinfo_y->maximum - device->abs.absinfo_y->minimum; + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; switch (tp->model) { case MODEL_ALPS: diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 4666870b..c70d28e6 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -1402,10 +1402,8 @@ tp_init_palmdetect(struct tp_dispatch *tp, tp->palm.left_edge = INT_MIN; tp->palm.vert_center = INT_MIN; - width = abs(device->abs.absinfo_x->maximum - - device->abs.absinfo_x->minimum); - height = abs(device->abs.absinfo_y->maximum - - device->abs.absinfo_y->minimum); + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; /* Wacom doesn't have internal touchpads, * Apple touchpads are always big enough to warrant palm detection */ @@ -1484,10 +1482,8 @@ tp_init(struct tp_dispatch *tp, if (tp_init_slots(tp, device) != 0) return -1; - width = abs(device->abs.absinfo_x->maximum - - device->abs.absinfo_x->minimum); - height = abs(device->abs.absinfo_y->maximum - - device->abs.absinfo_y->minimum); + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; diagonal = sqrt(width*width + height*height); tp->reports_distance = libevdev_has_event_code(device->evdev, diff --git a/src/evdev.c b/src/evdev.c index cfcdc349..627e185b 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1762,6 +1762,10 @@ evdev_configure_mt_device(struct evdev_device *device) device->abs.absinfo_x = libevdev_get_abs_info(evdev, ABS_MT_POSITION_X); device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_MT_POSITION_Y); + device->abs.dimensions.x = abs(device->abs.absinfo_x->maximum - + device->abs.absinfo_x->minimum); + device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum - + device->abs.absinfo_y->minimum); device->is_mt = 1; /* We only handle the slotted Protocol B in libinput. @@ -1874,6 +1878,10 @@ evdev_configure_device(struct evdev_device *device) device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_Y); device->abs.point.x = device->abs.absinfo_x->value; device->abs.point.y = device->abs.absinfo_y->value; + device->abs.dimensions.x = abs(device->abs.absinfo_x->maximum - + device->abs.absinfo_x->minimum); + device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum - + device->abs.absinfo_y->minimum); if (evdev_is_fake_mt_device(device)) { udev_tags &= ~EVDEV_UDEV_TAG_TOUCHSCREEN; diff --git a/src/evdev.h b/src/evdev.h index 566b0a44..0485894d 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -137,6 +137,8 @@ struct evdev_device { struct matrix calibration; struct matrix default_calibration; /* from LIBINPUT_CALIBRATION_MATRIX */ struct matrix usermatrix; /* as supplied by the caller */ + + struct device_coords dimensions; } abs; struct {