[Spice-devel] [spice-gtk] widget: Send all smooth-scroll events to the guest

Victor Toso victortoso at redhat.com
Tue Sep 18 05:10:45 UTC 2018


Hi,

On Mon, Sep 17, 2018 at 06:37:08PM +0200, Christophe Fergeau wrote:
> On Fri, Sep 14, 2018 at 02:25:39PM +0200, Victor Toso wrote:
> > From: Victor Toso <me at victortoso.com>
> > 
> > Introduced in 2212f05145c5f1d5, smooth-scroll events were taking
> > inconsideration that the delta_y value received by GdkEventScroll was

s/inconsideration/in consideration/ too

> > 1.0 but that can be different for other input devices.
> > 
> > That can trigger the bug rhbz#1627823 where scroll->delta_y is too
> > small, not triggering the while(ABS(d->scroll_delta_y) > 1) loop
> > leading to scroll meetings being missed in the guest.
> 
> s/meetings/events/ I guess.

Thanks

> > 
> > Instead, let's send every event to the guest besides delta_y of 0.0
> > value that is sent in my machine after several events at once, related
> > to usage of 2-fingers on trackpad.
> 
> On my laptop with a USB mouse plugged, I get fractional delta_y when I
> use the touchpad, but I get a 1/-1 when I use the wheel of the
> mouse.

Same here, yes.

> Sending a scroll event every time we get a smooth scroll event
> is likely to result in too fast scrolling in the VM I would
> think?

Not necessarily, it could slow down the scrolling too.

With this patch, a delta-y of 10+ would send a single button-down
while that, before, we would send 10 button-downs:

current:
    (spicy:6759): GSpice-DEBUG: 06:58:38.028: ../src/spice-widget.c:1984 0:0 scroll:10.792969
    (spicy:6759): GSpice-DEBUG: 06:58:38.028: ../src/spice-widget.c:1989 0:0 BUTTON DOWN

before:
    (spicy:6890): GSpice-DEBUG: 07:02:08.286: ../src/spice-widget.c:1983 0:0 scroll:10.523438
    (spicy:6890): GSpice-DEBUG: 07:02:08.286: ../src/spice-widget.c:1990 0:0 BUTTON DOWN
    (spicy:6890): GSpice-DEBUG: 07:02:08.286: ../src/spice-widget.c:1990 0:0 BUTTON DOWN
    (spicy:6890): GSpice-DEBUG: 07:02:08.287: ../src/spice-widget.c:1990 0:0 BUTTON DOWN
    (spicy:6890): GSpice-DEBUG: 07:02:08.287: ../src/spice-widget.c:1990 0:0 BUTTON DOWN
    (spicy:6890): GSpice-DEBUG: 07:02:08.287: ../src/spice-widget.c:1990 0:0 BUTTON DOWN
    (spicy:6890): GSpice-DEBUG: 07:02:08.287: ../src/spice-widget.c:1990 0:0 BUTTON DOWN
    (spicy:6890): GSpice-DEBUG: 07:02:08.287: ../src/spice-widget.c:1990 0:0 BUTTON DOWN
    (spicy:6890): GSpice-DEBUG: 07:02:08.287: ../src/spice-widget.c:1990 0:0 BUTTON DOWN
    (spicy:6890): GSpice-DEBUG: 07:02:08.287: ../src/spice-widget.c:1990 0:0 BUTTON DOWN
    (spicy:6890): GSpice-DEBUG: 07:02:08.287: ../src/spice-widget.c:1990 0:0 BUTTON DOWN

> > ---
> >  src/spice-widget-priv.h |  1 -
> >  src/spice-widget.c      | 16 +++++++---------
> >  2 files changed, 7 insertions(+), 10 deletions(-)
> > 
> > diff --git a/src/spice-widget.c b/src/spice-widget.c
> > index 853c9df..83d264f 100644
> > --- a/src/spice-widget.c
> > +++ b/src/spice-widget.c
> > @@ -1978,15 +1978,13 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *scroll)
> >          press_and_release(display, SPICE_MOUSE_BUTTON_DOWN, button_state);
> >          break;
> >      case GDK_SCROLL_SMOOTH:
> > -        d->scroll_delta_y += scroll->delta_y;
> > -        while (ABS(d->scroll_delta_y) > 1) {
> 
> Actually, we should be checking for >= 1 here, not >, otherwise we'll
> indeed be delaying the emission of the button up/down event.

Indeed, that would be enough to fix for a user that uses mouse's
wheel and probably for 2-finger scrolling in the touchpad.

At the time I wrote this patch, I got a bit concern with
scrolling with trackpoint which is very sensitivity with small
delta-y between 0.1 to 0.3 and highest I can see around 3.5.

I'm not sure what is a good solution around this as all of it is
a bit of workaround as we don't send the delta-y to the guest.
I'll send a new patch in the meanwhile to fix the while above.

Thanks for reviewing,
Victor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180918/8e88dd9a/attachment.sig>


More information about the Spice-devel mailing list