Hi,

On 01-07-15 08:08, Peter Hutterer wrote:
Now that we have all devices init a fixed resolution we don't need code to
handle custom cases anymore.

Signed-off-by: Peter Hutterer <[email protected]>

LGTM: Reviewed-by: Hans de Goede <[email protected]>

Regards,

Hans


---
  src/evdev-mt-touchpad-buttons.c | 65 ++++++++++-------------------------------
  src/evdev-mt-touchpad.c         | 30 +++++--------------
  2 files changed, 23 insertions(+), 72 deletions(-)

diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index 9c1c096..5f589c5 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -525,20 +525,19 @@ tp_init_softbuttons(struct tp_dispatch *tp,
        absinfo_y = device->abs.absinfo_y;

        xoffset = absinfo_x->minimum,
-       yoffset = absinfo_y->minimum;
+       yoffset = absinfo_y->minimum,
        yres = absinfo_y->resolution;
        width = device->abs.dimensions.x;
        height = device->abs.dimensions.y;

-       /* button height: 10mm or 15% of the touchpad height,
+       /* button height: 10mm or 15% orf the touchpad height,
           whichever is smaller */
-       if (!device->abs.fake_resolution && (height * 0.15/yres) > 10) {
+       if ((height * 0.15)/yres > 10) {
                tp->buttons.bottom_area.top_edge =
-               absinfo_y->maximum - 10 * yres;
+                       absinfo_y->maximum - 10 * yres;
        } else {
                tp->buttons.bottom_area.top_edge = height * .85 + yoffset;
        }
-
        tp->buttons.bottom_area.rightbutton_left_edge = width/2 + xoffset;
  }

@@ -547,7 +546,7 @@ tp_init_top_softbuttons(struct tp_dispatch *tp,
                        struct evdev_device *device,
                        double topbutton_size_mult)
  {
-       int width, height;
+       int width;
        const struct input_absinfo *absinfo_x, *absinfo_y;
        int xoffset, yoffset;
        int yres;
@@ -559,7 +558,6 @@ tp_init_top_softbuttons(struct tp_dispatch *tp,
        yoffset = absinfo_y->minimum;
        yres = absinfo_y->resolution;
        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
@@ -567,14 +565,8 @@ tp_init_top_softbuttons(struct tp_dispatch *tp,
                   top - which maps to 15%.  We allow the caller to enlarge the
                   area using a multiplier for the touchpad disabled case. */
                double topsize_mm = 10 * topbutton_size_mult;
-               double topsize_pct = .15 * topbutton_size_mult;

-               if (!device->abs.fake_resolution) {
-                       tp->buttons.top_area.bottom_edge =
-                       yoffset + topsize_mm * yres;
-               } else {
-                       tp->buttons.top_area.bottom_edge = height * topsize_pct 
+ yoffset;
-               }
+               tp->buttons.top_area.bottom_edge = yoffset + topsize_mm * yres;
                tp->buttons.top_area.rightbutton_left_edge = width * .58 + 
xoffset;
                tp->buttons.top_area.leftbutton_right_edge = width * .42 + 
xoffset;
        } else {
@@ -713,8 +705,6 @@ tp_init_buttons(struct tp_dispatch *tp,
  {
        struct libinput *libinput = tp_libinput_context(tp);
        struct tp_touch *t;
-       int width, height;
-       double diagonal;
        const struct input_absinfo *absinfo_x, *absinfo_y;

        tp->buttons.is_clickpad = libevdev_has_property(device->evdev,
@@ -738,19 +728,9 @@ tp_init_buttons(struct tp_dispatch *tp,
        absinfo_x = device->abs.absinfo_x;
        absinfo_y = device->abs.absinfo_y;

-       /* pinned-finger motion threshold, see tp_unpin_finger.
-          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 = 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;
-       } else {
-               tp->buttons.motion_dist.x_scale_coeff = 
1.0/absinfo_x->resolution;
-               tp->buttons.motion_dist.y_scale_coeff = 
1.0/absinfo_y->resolution;
-       }
+       /* pinned-finger motion threshold, see tp_unpin_finger. */
+       tp->buttons.motion_dist.x_scale_coeff = 1.0/absinfo_x->resolution;
+       tp->buttons.motion_dist.y_scale_coeff = 1.0/absinfo_y->resolution;

        tp->buttons.config_method.get_methods = 
tp_button_config_click_get_methods;
        tp->buttons.config_method.set_method = 
tp_button_config_click_set_method;
@@ -832,28 +812,15 @@ tp_check_clickfinger_distance(struct tp_dispatch *tp,
        x = abs(t1->point.x - t2->point.x);
        y = abs(t1->point.y - t2->point.y);

-       /* no resolution, so let's assume they're close enough together */
-       if (tp->device->abs.fake_resolution) {
-               int w, h;
+       /* maximum spread is 40mm horiz, 20mm vert. Anything wider than that
+        * is probably a gesture. The y spread is small so we ignore clicks
+        * with thumbs at the bottom of the touchpad while the pointer
+        * moving finger is still on the pad */

-               /* Use a maximum of 30% of the touchpad width or height if
-                * we dont' have resolution. */
-               w = tp->device->abs.dimensions.x;
-               h = tp->device->abs.dimensions.y;
-
-               return (x < w * 0.3 && y < h * 0.3) ? 1 : 0;
-       } else {
-               /* maximum spread is 40mm horiz, 20mm vert. Anything wider than 
that
-                * is probably a gesture. The y spread is small so we ignore 
clicks
-                * with thumbs at the bottom of the touchpad while the pointer
-                * moving finger is still on the pad */
-
-               x /= tp->device->abs.absinfo_x->resolution;
-               y /= tp->device->abs.absinfo_y->resolution;
-
-               return (x < 40 && y < 20) ? 1 : 0;
-       }
+       x /= tp->device->abs.absinfo_x->resolution;
+       y /= tp->device->abs.absinfo_y->resolution;

+       return (x < 40 && y < 20) ? 1 : 0;
  }

  static uint32_t
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 8692612..a39cf19 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -1318,17 +1318,8 @@ tp_init_accel(struct tp_dispatch *tp, double diagonal)
         * and y resolution, so that a circle on the
         * touchpad does not turn into an elipse on the screen.
         */
-       if (!tp->device->abs.fake_resolution) {
-               tp->accel.x_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_x;
-               tp->accel.y_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_y;
-       } else {
-       /*
-        * For touchpads where the driver does not provide resolution, fall
-        * back to scaling motion events based on the diagonal size in units.
-        */
-               tp->accel.x_scale_coeff = DEFAULT_ACCEL_NUMERATOR / diagonal;
-               tp->accel.y_scale_coeff = DEFAULT_ACCEL_NUMERATOR / diagonal;
-       }
+       tp->accel.x_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_x;
+       tp->accel.y_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_y;

        switch (tp->device->model) {
        case EVDEV_MODEL_LENOVO_X230:
@@ -1547,6 +1538,7 @@ tp_init(struct tp_dispatch *tp,
  {
        int width, height;
        double diagonal;
+       int res_x, res_y;

        tp->base.interface = &tp_interface;
        tp->device = device;
@@ -1560,6 +1552,8 @@ tp_init(struct tp_dispatch *tp,
        if (tp_init_slots(tp, device) != 0)
                return -1;

+       res_x = tp->device->abs.absinfo_x->resolution;
+       res_y = tp->device->abs.absinfo_y->resolution;
        width = device->abs.dimensions.x;
        height = device->abs.dimensions.y;
        diagonal = sqrt(width*width + height*height);
@@ -1568,18 +1562,8 @@ tp_init(struct tp_dispatch *tp,
                                                       EV_ABS,
                                                       ABS_MT_DISTANCE);

-       if (device->abs.fake_resolution) {
-               tp->hysteresis_margin.x =
-                       diagonal / DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR;
-               tp->hysteresis_margin.y =
-                       diagonal / DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR;
-       } else {
-               int res_x = tp->device->abs.absinfo_x->resolution,
-                   res_y = tp->device->abs.absinfo_y->resolution;
-
-               tp->hysteresis_margin.x = res_x/2;
-               tp->hysteresis_margin.y = res_y/2;
-       }
+       tp->hysteresis_margin.x = res_x/2;
+       tp->hysteresis_margin.y = res_y/2;

        if (tp_init_accel(tp, diagonal) != 0)
                return -1;

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to