On Wed, Sep 17, 2014 at 03:35:30PM +0200, Hans de Goede wrote: > Make it easier to hit the topbutton area when the touchpad is disabled, > normally we don't want to make the topbutton area too big, so as to not > interfere with normal touchpad operation, but when disabled we have no such > worries.
even though it may not seem like the scalable solution, I'd really prefer this to be two functions, "expand" and "normal" or so. We don't need a generic multiplier here (we don't plan to add more than 2 sizes) and something like tp_expand_softbuttons(tp, device) or tp_set_softbutton_size_large(tp, device) is easier to comprehend IMO than adding the raw numbers as multipliers of some magic size. Plus, we may end up having some magic number being the best size that's not a straightforward multiplier in which case the multiplier just adds to the confusion. So let's just use two sizes, normal and large and go with those. Cheers, Peter > > Signed-off-by: Hans de Goede <hdego...@redhat.com> > --- > src/evdev-mt-touchpad-buttons.c | 19 ++++++++++++------- > src/evdev-mt-touchpad.c | 4 ++++ > src/evdev-mt-touchpad.h | 4 +++- > 3 files changed, 19 insertions(+), 8 deletions(-) > > diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c > index 865346b..f0800d7 100644 > --- a/src/evdev-mt-touchpad-buttons.c > +++ b/src/evdev-mt-touchpad-buttons.c > @@ -496,7 +496,8 @@ tp_release_all_buttons(struct tp_dispatch *tp, > > void > tp_init_softbuttons(struct tp_dispatch *tp, > - struct evdev_device *device) > + struct evdev_device *device, > + double topbutton_size_mult) > { > int width, height; > const struct input_absinfo *absinfo_x, *absinfo_y; > @@ -524,14 +525,18 @@ tp_init_softbuttons(struct tp_dispatch *tp, > tp->buttons.bottom_area.rightbutton_left_edge = width/2 + xoffset; > > if (tp->buttons.has_topbuttons) { > - /* T440s has the top button line 5mm from the top, > - event analysis has shown events to start down to ~10mm > - from the top - which maps to 15% */ > + /* T440s has the top button line 5mm from the top, event > + analysis has shown events to start down to ~10mm from the > + 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 (yres > 1) { > tp->buttons.top_area.bottom_edge = > - yoffset + 10 * yres; > + yoffset + topsize_mm * yres; > } else { > - tp->buttons.top_area.bottom_edge = height * .15 + > yoffset; > + tp->buttons.top_area.bottom_edge = height * topsize_pct > + yoffset; > } > tp->buttons.top_area.rightbutton_left_edge = width * .58 + > xoffset; > tp->buttons.top_area.leftbutton_right_edge = width * .42 + > xoffset; > @@ -581,7 +586,7 @@ tp_init_buttons(struct tp_dispatch *tp, > tp->buttons.use_clickfinger = true; > > if (tp->buttons.is_clickpad && !tp->buttons.use_clickfinger) { > - tp_init_softbuttons(tp, device); > + tp_init_softbuttons(tp, device, 1.0); > } else { > tp->buttons.bottom_area.top_edge = INT_MAX; > tp->buttons.top_area.bottom_edge = INT_MIN; > diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c > index 9e568ad..1c32cc6 100644 > --- a/src/evdev-mt-touchpad.c > +++ b/src/evdev-mt-touchpad.c > @@ -645,6 +645,8 @@ tp_suspend(struct tp_dispatch *tp, struct evdev_device > *device) > */ > if (tp->buttons.has_topbuttons) { > evdev_notify_suspended_device(device); > + /* Enlarge topbutton area while suspended */ > + tp_init_softbuttons(tp, device, 1.5); > } else { > evdev_device_suspend(device); > } > @@ -656,6 +658,8 @@ tp_resume(struct tp_dispatch *tp, struct evdev_device > *device) > if (tp->buttons.has_topbuttons) { > /* tap state-machine is offline while suspended, reset state */ > tp_clear_state(tp, device); > + /* restore original topbutton area size */ > + tp_init_softbuttons(tp, device, 1.0); > evdev_notify_resumed_device(device); > } else { > evdev_device_resume(device); > diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h > index 15cca76..e0c8c47 100644 > --- a/src/evdev-mt-touchpad.h > +++ b/src/evdev-mt-touchpad.h > @@ -245,7 +245,9 @@ int > tp_init_buttons(struct tp_dispatch *tp, struct evdev_device *device); > > void > -tp_init_softbuttons(struct tp_dispatch *tp, struct evdev_device *device); > +tp_init_softbuttons(struct tp_dispatch *tp, > + struct evdev_device *device, > + double topbutton_size_mult); > > void > tp_destroy_buttons(struct tp_dispatch *tp); > -- > 2.1.0 > > _______________________________________________ > wayland-devel mailing list > wayland-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/wayland-devel > _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel