Re: [PATCH libinput 2/6] touchpad: Fix sending of scroll stop events

2014-05-26 Thread Hans de Goede
Hi,

On 05/25/2014 02:13 PM, Jonas Ådahl wrote:
 On Fri, May 23, 2014 at 04:06:23PM +0200, Hans de Goede wrote:
 Setting tp-scroll.direction = 0 before checking tp-scroll.direction
 to see if we need to send stop scroll events for vert / horz scrolling does
 not really work well.

 Also we need to check direction with an axis mask, not the axis number.

 While at it also add a tp_stop_scroll_events() helper function for this.

 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
  src/evdev-mt-touchpad.c | 39 +++
  1 file changed, 23 insertions(+), 16 deletions(-)

 diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
 index 040939b..2455c36 100644
 --- a/src/evdev-mt-touchpad.c
 +++ b/src/evdev-mt-touchpad.c
 @@ -500,6 +500,28 @@ tp_post_twofinger_scroll(struct tp_dispatch *tp, 
 uint64_t time)
  }
  }
  
 +static void
 +tp_stop_scroll_events(struct tp_dispatch *tp, uint64_t time)
 +{
 +if (tp-scroll.state == SCROLL_STATE_NONE)
 +return;
 +
 +/* terminate scrolling with a zero scroll event */
 +if (tp-scroll.direction  (1  LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL))
 +pointer_notify_axis(tp-device-base,
 +time,
 +LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL,
 +0);
 +if (tp-scroll.direction  (1  
 LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL))
 +pointer_notify_axis(tp-device-base,
 +time,
 +LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL,
 +0);
 
 I can see that you didn't introduce sending 0-valued axis events in this
 patch, but why do we do so? weston will ignore it anyway, and if it
 wouldn't or other compositor wouldn't, it might confuse clients assuming
 that a scroll event will always have a direction.

Another one where I'm going to let the answer up to Peter I'm afraid.

Regards,

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


Re: [PATCH libinput 2/6] touchpad: Fix sending of scroll stop events

2014-05-26 Thread Peter Hutterer

On 26/05/2014 16:33 , Hans de Goede wrote:

Hi,

On 05/25/2014 02:13 PM, Jonas Ådahl wrote:

On Fri, May 23, 2014 at 04:06:23PM +0200, Hans de Goede wrote:

Setting tp-scroll.direction = 0 before checking tp-scroll.direction
to see if we need to send stop scroll events for vert / horz scrolling does
not really work well.

Also we need to check direction with an axis mask, not the axis number.

While at it also add a tp_stop_scroll_events() helper function for this.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
  src/evdev-mt-touchpad.c | 39 +++
  1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 040939b..2455c36 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -500,6 +500,28 @@ tp_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t 
time)
}
  }

+static void
+tp_stop_scroll_events(struct tp_dispatch *tp, uint64_t time)
+{
+   if (tp-scroll.state == SCROLL_STATE_NONE)
+   return;
+
+   /* terminate scrolling with a zero scroll event */
+   if (tp-scroll.direction  (1  LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL))
+   pointer_notify_axis(tp-device-base,
+   time,
+   LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL,
+   0);
+   if (tp-scroll.direction  (1  
LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL))
+   pointer_notify_axis(tp-device-base,
+   time,
+   LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL,
+   0);


I can see that you didn't introduce sending 0-valued axis events in this
patch, but why do we do so? weston will ignore it anyway, and if it
wouldn't or other compositor wouldn't, it might confuse clients assuming
that a scroll event will always have a direction.


Another one where I'm going to let the answer up to Peter I'm afraid.


The idea is to terminate the scroll events series with a 0 event as a 
signal of it's finished now. Especially for touch-based scrolling this 
helps with extra UI effects. if you have a physics-based scrolling, 
getting the terminating event means you can calculate v0 for the 
friction without further delay. In the user-interface you can stay in 
scrolling mode even when you don't receive events because you know the 
user still has two fingers on the pad.


I understand this isn't currently used, I think it's still a good 
addition. And yes, it needs some extra code so scroll wheels are handled 
sensibly too.


Cheers,
  Peter

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


Re: [PATCH libinput 2/6] touchpad: Fix sending of scroll stop events

2014-05-25 Thread Jonas Ådahl
On Fri, May 23, 2014 at 04:06:23PM +0200, Hans de Goede wrote:
 Setting tp-scroll.direction = 0 before checking tp-scroll.direction
 to see if we need to send stop scroll events for vert / horz scrolling does
 not really work well.
 
 Also we need to check direction with an axis mask, not the axis number.
 
 While at it also add a tp_stop_scroll_events() helper function for this.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
  src/evdev-mt-touchpad.c | 39 +++
  1 file changed, 23 insertions(+), 16 deletions(-)
 
 diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
 index 040939b..2455c36 100644
 --- a/src/evdev-mt-touchpad.c
 +++ b/src/evdev-mt-touchpad.c
 @@ -500,6 +500,28 @@ tp_post_twofinger_scroll(struct tp_dispatch *tp, 
 uint64_t time)
   }
  }
  
 +static void
 +tp_stop_scroll_events(struct tp_dispatch *tp, uint64_t time)
 +{
 + if (tp-scroll.state == SCROLL_STATE_NONE)
 + return;
 +
 + /* terminate scrolling with a zero scroll event */
 + if (tp-scroll.direction  (1  LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL))
 + pointer_notify_axis(tp-device-base,
 + time,
 + LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL,
 + 0);
 + if (tp-scroll.direction  (1  
 LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL))
 + pointer_notify_axis(tp-device-base,
 + time,
 + LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL,
 + 0);

I can see that you didn't introduce sending 0-valued axis events in this
patch, but why do we do so? weston will ignore it anyway, and if it
wouldn't or other compositor wouldn't, it might confuse clients assuming
that a scroll event will always have a direction.

Jonas

 +
 + tp-scroll.state = SCROLL_STATE_NONE;
 + tp-scroll.direction = 0;
 +}
 +
  static int
  tp_post_scroll_events(struct tp_dispatch *tp, uint64_t time)
  {
 @@ -513,22 +535,7 @@ tp_post_scroll_events(struct tp_dispatch *tp, uint64_t 
 time)
   }
  
   if (nfingers_down != 2) {
 - /* terminate scrolling with a zero scroll event to notify
 -  * caller that it really ended now */
 - if (tp-scroll.state != SCROLL_STATE_NONE) {
 - tp-scroll.state = SCROLL_STATE_NONE;
 - tp-scroll.direction = 0;
 - if (tp-scroll.direction  
 LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL)
 - pointer_notify_axis(tp-device-base,
 - time,
 - 
 LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL,
 - 0);
 - if (tp-scroll.direction  
 LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL)
 - pointer_notify_axis(tp-device-base,
 - time,
 - 
 LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL,
 - 0);
 - }
 + tp_stop_scroll_events(tp, time);
   } else {
   tp_post_twofinger_scroll(tp, time);
   return 1;
 -- 
 1.9.3
 
 ___
 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


[PATCH libinput 2/6] touchpad: Fix sending of scroll stop events

2014-05-23 Thread Hans de Goede
Setting tp-scroll.direction = 0 before checking tp-scroll.direction
to see if we need to send stop scroll events for vert / horz scrolling does
not really work well.

Also we need to check direction with an axis mask, not the axis number.

While at it also add a tp_stop_scroll_events() helper function for this.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 src/evdev-mt-touchpad.c | 39 +++
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 040939b..2455c36 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -500,6 +500,28 @@ tp_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t 
time)
}
 }
 
+static void
+tp_stop_scroll_events(struct tp_dispatch *tp, uint64_t time)
+{
+   if (tp-scroll.state == SCROLL_STATE_NONE)
+   return;
+
+   /* terminate scrolling with a zero scroll event */
+   if (tp-scroll.direction  (1  LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL))
+   pointer_notify_axis(tp-device-base,
+   time,
+   LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL,
+   0);
+   if (tp-scroll.direction  (1  
LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL))
+   pointer_notify_axis(tp-device-base,
+   time,
+   LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL,
+   0);
+
+   tp-scroll.state = SCROLL_STATE_NONE;
+   tp-scroll.direction = 0;
+}
+
 static int
 tp_post_scroll_events(struct tp_dispatch *tp, uint64_t time)
 {
@@ -513,22 +535,7 @@ tp_post_scroll_events(struct tp_dispatch *tp, uint64_t 
time)
}
 
if (nfingers_down != 2) {
-   /* terminate scrolling with a zero scroll event to notify
-* caller that it really ended now */
-   if (tp-scroll.state != SCROLL_STATE_NONE) {
-   tp-scroll.state = SCROLL_STATE_NONE;
-   tp-scroll.direction = 0;
-   if (tp-scroll.direction  
LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL)
-   pointer_notify_axis(tp-device-base,
-   time,
-   
LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL,
-   0);
-   if (tp-scroll.direction  
LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL)
-   pointer_notify_axis(tp-device-base,
-   time,
-   
LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL,
-   0);
-   }
+   tp_stop_scroll_events(tp, time);
} else {
tp_post_twofinger_scroll(tp, time);
return 1;
-- 
1.9.3

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