Re: [PATCH libinput v2 3/3] touchpad: Add edge-scrolling support

2014-11-24 Thread Hans de Goede

Hi,

On 11/21/2014 01:29 AM, Peter Hutterer wrote:

On Thu, Nov 20, 2014 at 10:34:51AM +0100, Hans de Goede wrote:
[...]

+int
+tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device)
+{
+   struct tp_touch *t;
+   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;
+
+   switch (tp-model) {
+   case MODEL_SYNAPTICS:
+   edge_width = width * .07;
+   edge_height = height * .07;
+   break;
+   case MODEL_ALPS:
+   edge_width = width * .15;
+   edge_height = height * .15;
+   break;
+   case MODEL_APPLETOUCH:
+   case MODEL_UNIBODY_MACBOOK:


unless there's one I didn't find in my quick search, the unibodies all had
clickpads so we should skip this here and maybe leave a comment for that.


But keep the APPLETOUCH ?


yes, from what I remember (and quick googling seems to confirm this), the
ones with appletouch were e.g. the Core 2 Duo macbooks. Which only had one
mouse button but weren't clickpads yet.


+   edge_width = width * .085;
+   edge_height = height * .085;
+   break;
+   default:
+   edge_width = width * .04;
+   edge_height = height * .054;


make MODEL_SYNAPTICS the same as default please


So use .04 and .054 for synaptics too, and drop the SYNAPTICS case ?


yes please.
It might be worth mentioning in a comment that for the *40 series, the edges
are the absolute edges (not the recommended edges), but since libinput
doesn't care about clickpad edges we ignore them here.


Ok, both fixed for v3, including adding the suggested comments.

Regards,

Hans
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH libinput v2 3/3] touchpad: Add edge-scrolling support

2014-11-20 Thread Hans de Goede
Hi,

On 11/20/2014 07:21 AM, Peter Hutterer wrote:
 On Wed, Nov 19, 2014 at 01:45:35PM +0100, Hans de Goede wrote:
 Add edge-scrolling support for non multi-touch touchpads as well as for
 users who prefer edge-scrolling (as long as they don't have a clickpad).

 Note the percentage to use of the width / height as scroll-edge differs from
 one manufacturer to the next, the various per model percentages were taken
 from xf86-input-synaptics.

 BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=85635
 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
  doc/touchpad-edge-scrolling-state-machine.svg | 262 ++
  src/Makefile.am   |   1 +
  src/evdev-mt-touchpad-edge-scroll.c   | 373 
 ++
  src/evdev-mt-touchpad.c   |  93 ++-
  src/evdev-mt-touchpad.h   |  46 
  5 files changed, 763 insertions(+), 12 deletions(-)
  create mode 100644 doc/touchpad-edge-scrolling-state-machine.svg
  create mode 100644 src/evdev-mt-touchpad-edge-scroll.c

 diff --git a/doc/touchpad-edge-scrolling-state-machine.svg 
 b/doc/touchpad-edge-scrolling-state-machine.svg
 new file mode 100644
 index 000..7a82d88
 [...]
 diff --git a/src/Makefile.am b/src/Makefile.am
 index 5cc52a6..027e08c 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -15,6 +15,7 @@ libinput_la_SOURCES =  \
  evdev-mt-touchpad.h \
  evdev-mt-touchpad-tap.c \
  evdev-mt-touchpad-buttons.c \
 +evdev-mt-touchpad-edge-scroll.c \
  filter.c\
  filter.h\
  filter-private.h\
 diff --git a/src/evdev-mt-touchpad-edge-scroll.c 
 b/src/evdev-mt-touchpad-edge-scroll.c
 new file mode 100644
 index 000..3647546
 --- /dev/null
 +++ b/src/evdev-mt-touchpad-edge-scroll.c
 @@ -0,0 +1,373 @@
 +/*
 + * Copyright © 2014 Red Hat, Inc.
 + *
 + * Permission to use, copy, modify, distribute, and sell this software and
 + * its documentation for any purpose is hereby granted without fee, provided
 + * that the above copyright notice appear in all copies and that both that
 + * copyright notice and this permission notice appear in supporting
 + * documentation, and that the name of the copyright holders not be used in
 + * advertising or publicity pertaining to distribution of the software
 + * without specific, written prior permission.  The copyright holders make
 + * no representations about the suitability of this software for any
 + * purpose.  It is provided as is without express or implied warranty.
 + *
 + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
 + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
 + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
 + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
 + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
 + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 + */
 +
 +#include errno.h
 +#include limits.h
 +#include math.h
 +#include string.h
 +#include unistd.h
 +#include linux/input.h
 +
 +#include evdev-mt-touchpad.h
 +
 +#define DEFAULT_SCROLL_LOCK_TIMEOUT 300 /* ms */
 +/* Use a reasonably large threshold until locked into scrolling mode, to
 +   avoid accidentally locking in scrolling mode when trying to use the 
 entire
 +   touchpad to move the pointer. The user can wait for the timeout to 
 trigger
 +   to do a small scroll. */
 +#define DEFAULT_SCROLL_THRESHOLD 10.0
 
 what's the unit of this? should be mentioned

Ok, will fix.

 
 +
 +enum scroll_event {
 +SCROLL_EVENT_TOUCH,
 +SCROLL_EVENT_MOTION,
 +SCROLL_EVENT_RELEASE,
 +SCROLL_EVENT_TIMEOUT,
 +SCROLL_EVENT_POSTED,
 +};
 +
 +static uint32_t
 +tp_touch_get_edge(struct tp_dispatch *tp, struct tp_touch *touch)
 +{
 +uint32_t edge = EDGE_NONE;
 +
 +if (tp-scroll.mode != LIBINPUT_CONFIG_SCROLL_EDGE)
 +return 0;
 +
 
 could just return edge (or EDGE_NONE if you want to be specific)

Good catch, will fix.

 
 +if (touch-x  tp-scroll.right_edge)
 +edge |= EDGE_RIGHT;
 +
 +if (touch-y  tp-scroll.bottom_edge)
 +edge |= EDGE_BOTTOM;
 +
 +return edge;
 +}
 +
 +static void
 +tp_edge_scroll_set_state(struct tp_dispatch *tp,
 + struct tp_touch *t,
 + enum tp_edge_scroll_touch_state state)
 +{
 +libinput_timer_cancel(t-scroll.timer);
 +
 +t-scroll.state = state;
 +
 +switch (state) {
 +case EDGE_SCROLL_TOUCH_STATE_NONE:
 +t-scroll.edge = EDGE_NONE;
 +t-scroll.threshold = DEFAULT_SCROLL_THRESHOLD;
 +break;
 +case EDGE_SCROLL_TOUCH_STATE_EDGE_NEW:
 +t-scroll.edge = tp_touch_get_edge(tp, t);
 +libinput_timer_set(t-scroll.timer,
 +

Re: [PATCH libinput v2 3/3] touchpad: Add edge-scrolling support

2014-11-20 Thread Peter Hutterer
On Thu, Nov 20, 2014 at 10:34:51AM +0100, Hans de Goede wrote:
[...]
  +int
  +tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device)
  +{
  +  struct tp_touch *t;
  +  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;
  +
  +  switch (tp-model) {
  +  case MODEL_SYNAPTICS:
  +  edge_width = width * .07;
  +  edge_height = height * .07;
  +  break;
  +  case MODEL_ALPS:
  +  edge_width = width * .15;
  +  edge_height = height * .15;
  +  break;
  +  case MODEL_APPLETOUCH:
  +  case MODEL_UNIBODY_MACBOOK:
  
  unless there's one I didn't find in my quick search, the unibodies all had
  clickpads so we should skip this here and maybe leave a comment for that.
 
 But keep the APPLETOUCH ?

yes, from what I remember (and quick googling seems to confirm this), the
ones with appletouch were e.g. the Core 2 Duo macbooks. Which only had one
mouse button but weren't clickpads yet.

  +  edge_width = width * .085;
  +  edge_height = height * .085;
  +  break;
  +  default:
  +  edge_width = width * .04;
  +  edge_height = height * .054;
  
  make MODEL_SYNAPTICS the same as default please
 
 So use .04 and .054 for synaptics too, and drop the SYNAPTICS case ?

yes please.
It might be worth mentioning in a comment that for the *40 series, the edges
are the absolute edges (not the recommended edges), but since libinput
doesn't care about clickpad edges we ignore them here.

Cheers,
   Peter
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput v2 3/3] touchpad: Add edge-scrolling support

2014-11-19 Thread Hans de Goede
Add edge-scrolling support for non multi-touch touchpads as well as for
users who prefer edge-scrolling (as long as they don't have a clickpad).

Note the percentage to use of the width / height as scroll-edge differs from
one manufacturer to the next, the various per model percentages were taken
from xf86-input-synaptics.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=85635
Signed-off-by: Hans de Goede hdego...@redhat.com
---
 doc/touchpad-edge-scrolling-state-machine.svg | 262 ++
 src/Makefile.am   |   1 +
 src/evdev-mt-touchpad-edge-scroll.c   | 373 ++
 src/evdev-mt-touchpad.c   |  93 ++-
 src/evdev-mt-touchpad.h   |  46 
 5 files changed, 763 insertions(+), 12 deletions(-)
 create mode 100644 doc/touchpad-edge-scrolling-state-machine.svg
 create mode 100644 src/evdev-mt-touchpad-edge-scroll.c

diff --git a/doc/touchpad-edge-scrolling-state-machine.svg 
b/doc/touchpad-edge-scrolling-state-machine.svg
new file mode 100644
index 000..7a82d88
--- /dev/null
+++ b/doc/touchpad-edge-scrolling-state-machine.svg
@@ -0,0 +1,262 @@
+?xml version=1.0?
+svg xmlns=http://www.w3.org/2000/svg; 
xmlns:xlink=http://www.w3.org/1999/xlink; width=1490px height=1399px 
version=1.1
+  defs/
+  g transform=translate(0.5,0.5)
+ellipse cx=261 cy=143 rx=63 ry=45.5 fill=#ff 
stroke=#00 stroke-width=2 pointer-events=none/
+g fill=#00 font-family=Helvetica text-anchor=middle 
font-size=12px
+  text x=261 y=126NONE/text
+  text x=261 y=140on-entry:/text
+  text x=261 y=154edge = none/text
+  text x=261 y=168threshold = def/text
+/g
+rect x=30 y=386 width=150 height=101 rx=6 ry=6 fill=#ccffcc 
stroke=#00 stroke-width=2 pointer-events=none/
+g fill=#00 font-family=Helvetica text-anchor=middle 
font-size=12px
+  text x=105 y=419EDGE_NEW/text
+  text x=105 y=433on-entry:/text
+  text x=105 y=447edge = get_edge()/text
+  text x=105 y=461set_timer()/text
+/g
+rect x=348 y=386 width=130 height=100 rx=6 ry=6 
fill=#ccffcc stroke=#00 stroke-width=2 pointer-events=none/
+g fill=#00 font-family=Helvetica text-anchor=middle 
font-size=12px
+  text x=413 y=419AREA/text
+  text x=413 y=433on-entry:/text
+  text x=413 y=447edge = none/text
+  text x=413 y=461set_pointer()/text
+/g
+path d=M 237 7 C 239 4 243 2 246 2 L 275 2 C 278 2 282 4 284 7 L 301 30 
C 301 31 301 33 301 34 L 284 57 C 282 60 278 62 275 62 L 246 62 C 243 62 239 60 
237 57 L 220 34 C 220 33 220 31 220 30 L 237 7 Z fill=#ffd966 
stroke=#00 stroke-width=2 stroke-miterlimit=10 pointer-events=none/
+g fill=#00 font-family=Helvetica text-anchor=middle 
font-size=12px
+  text x=261 y=36release/text
+/g
+path d=M 237 222 C 239 219 243 217 246 217 L 276 217 C 279 217 283 219 
285 222 L 303 245 C 303 246 303 248 303 249 L 285 272 C 283 275 279 277 276 277 
L 246 277 C 243 277 239 275 237 272 L 219 249 C 219 248 219 246 219 245 L 237 
222 Z fill=#ffd966 stroke=#00 stroke-width=2 stroke-miterlimit=10 
pointer-events=none/
+g fill=#00 font-family=Helvetica text-anchor=middle 
font-size=12px
+  text x=261 y=251touch/text
+/g
+path d=M 261 188 L 261 211 fill=none stroke=#00 
stroke-miterlimit=10 pointer-events=none/
+path d=M 261 216 L 258 209 L 261 211 L 265 209 Z fill=#00 
stroke=#00 stroke-miterlimit=10 pointer-events=none/
+path d=M 218 535 C 223 531 229 528 235 528 L 285 528 C 291 528 297 531 
302 535 L 331 570 C 332 571 332 574 331 575 L 302 610 C 297 614 291 617 285 617 
L 235 617 C 229 617 223 614 218 610 L 189 575 C 188 574 188 571 189 570 L 218 
535 Z fill=#ffd966 stroke=#00 stroke-width=2 stroke-miterlimit=10 
pointer-events=none/
+g fill=#00 font-family=Helvetica text-anchor=middle 
font-size=12px
+  text x=260 y=563touch,/text
+  text x=260 y=577edge amp;= get_edge()/text
+/g
+path d=M 220 526 L 158 487 fill=none stroke=#00 
stroke-miterlimit=10 pointer-events=none/
+path d=M 224 529 L 217 528 L 220 526 L 220 522 Z fill=#00 
stroke=#00 stroke-miterlimit=10 pointer-events=none/
+path d=M 105 617 L 105 650 fill=none stroke=#00 
stroke-miterlimit=10 pointer-events=none/
+path d=M 105 656 L 101 649 L 105 650 L 108 649 Z fill=#00 
stroke=#00 stroke-miterlimit=10 pointer-events=none/
+path d=M 478 436 L 498 436 Q 508 436 508 426 L 508 42 Q 508 32 498 32 L 
307 32 fill=none stroke=#00 stroke-miterlimit=10 
pointer-events=none/
+path d=M 302 32 L 309 29 L 307 32 L 309 36 Z fill=#00 
stroke=#00 stroke-miterlimit=10 pointer-events=none/
+path d=M 261 62 L 261 71 Q 261 80 261 85 L 261 91 fill=none 
stroke=#00 stroke-miterlimit=10 pointer-events=none/
+path d=M 261 96 L 257 89 L 261 91 L 264 89 Z fill=#00 
stroke=#00 stroke-miterlimit=10 pointer-events=none/
+ellipse 

Re: [PATCH libinput v2 3/3] touchpad: Add edge-scrolling support

2014-11-19 Thread Peter Hutterer
On Wed, Nov 19, 2014 at 01:45:35PM +0100, Hans de Goede wrote:
 Add edge-scrolling support for non multi-touch touchpads as well as for
 users who prefer edge-scrolling (as long as they don't have a clickpad).
 
 Note the percentage to use of the width / height as scroll-edge differs from
 one manufacturer to the next, the various per model percentages were taken
 from xf86-input-synaptics.
 
 BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=85635
 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
  doc/touchpad-edge-scrolling-state-machine.svg | 262 ++
  src/Makefile.am   |   1 +
  src/evdev-mt-touchpad-edge-scroll.c   | 373 
 ++
  src/evdev-mt-touchpad.c   |  93 ++-
  src/evdev-mt-touchpad.h   |  46 
  5 files changed, 763 insertions(+), 12 deletions(-)
  create mode 100644 doc/touchpad-edge-scrolling-state-machine.svg
  create mode 100644 src/evdev-mt-touchpad-edge-scroll.c
 
 diff --git a/doc/touchpad-edge-scrolling-state-machine.svg 
 b/doc/touchpad-edge-scrolling-state-machine.svg
 new file mode 100644
 index 000..7a82d88
[...]
 diff --git a/src/Makefile.am b/src/Makefile.am
 index 5cc52a6..027e08c 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -15,6 +15,7 @@ libinput_la_SOURCES =   \
   evdev-mt-touchpad.h \
   evdev-mt-touchpad-tap.c \
   evdev-mt-touchpad-buttons.c \
 + evdev-mt-touchpad-edge-scroll.c \
   filter.c\
   filter.h\
   filter-private.h\
 diff --git a/src/evdev-mt-touchpad-edge-scroll.c 
 b/src/evdev-mt-touchpad-edge-scroll.c
 new file mode 100644
 index 000..3647546
 --- /dev/null
 +++ b/src/evdev-mt-touchpad-edge-scroll.c
 @@ -0,0 +1,373 @@
 +/*
 + * Copyright © 2014 Red Hat, Inc.
 + *
 + * Permission to use, copy, modify, distribute, and sell this software and
 + * its documentation for any purpose is hereby granted without fee, provided
 + * that the above copyright notice appear in all copies and that both that
 + * copyright notice and this permission notice appear in supporting
 + * documentation, and that the name of the copyright holders not be used in
 + * advertising or publicity pertaining to distribution of the software
 + * without specific, written prior permission.  The copyright holders make
 + * no representations about the suitability of this software for any
 + * purpose.  It is provided as is without express or implied warranty.
 + *
 + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
 + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
 + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
 + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
 + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
 + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 + */
 +
 +#include errno.h
 +#include limits.h
 +#include math.h
 +#include string.h
 +#include unistd.h
 +#include linux/input.h
 +
 +#include evdev-mt-touchpad.h
 +
 +#define DEFAULT_SCROLL_LOCK_TIMEOUT 300 /* ms */
 +/* Use a reasonably large threshold until locked into scrolling mode, to
 +   avoid accidentally locking in scrolling mode when trying to use the entire
 +   touchpad to move the pointer. The user can wait for the timeout to trigger
 +   to do a small scroll. */
 +#define DEFAULT_SCROLL_THRESHOLD 10.0

what's the unit of this? should be mentioned

 +
 +enum scroll_event {
 + SCROLL_EVENT_TOUCH,
 + SCROLL_EVENT_MOTION,
 + SCROLL_EVENT_RELEASE,
 + SCROLL_EVENT_TIMEOUT,
 + SCROLL_EVENT_POSTED,
 +};
 +
 +static uint32_t
 +tp_touch_get_edge(struct tp_dispatch *tp, struct tp_touch *touch)
 +{
 + uint32_t edge = EDGE_NONE;
 +
 + if (tp-scroll.mode != LIBINPUT_CONFIG_SCROLL_EDGE)
 + return 0;
 +

could just return edge (or EDGE_NONE if you want to be specific)

 + if (touch-x  tp-scroll.right_edge)
 + edge |= EDGE_RIGHT;
 +
 + if (touch-y  tp-scroll.bottom_edge)
 + edge |= EDGE_BOTTOM;
 +
 + return edge;
 +}
 +
 +static void
 +tp_edge_scroll_set_state(struct tp_dispatch *tp,
 +  struct tp_touch *t,
 +  enum tp_edge_scroll_touch_state state)
 +{
 + libinput_timer_cancel(t-scroll.timer);
 +
 + t-scroll.state = state;
 +
 + switch (state) {
 + case EDGE_SCROLL_TOUCH_STATE_NONE:
 + t-scroll.edge = EDGE_NONE;
 + t-scroll.threshold = DEFAULT_SCROLL_THRESHOLD;
 + break;
 + case EDGE_SCROLL_TOUCH_STATE_EDGE_NEW:
 + t-scroll.edge = tp_touch_get_edge(tp, t);
 + libinput_timer_set(t-scroll.timer,
 +t-millis + DEFAULT_SCROLL_LOCK_TIMEOUT);
 +