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

Victor Toso victortoso at redhat.com
Fri Sep 14 12:25:39 UTC 2018


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
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.

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.

Resolve: https://bugzilla.redhat.com/show_bug.cgi?id=1627823
Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 src/spice-widget-priv.h |  1 -
 src/spice-widget.c      | 16 +++++++---------
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
index 96f6c1d..30a59d8 100644
--- a/src/spice-widget-priv.h
+++ b/src/spice-widget-priv.h
@@ -148,7 +148,6 @@ struct _SpiceDisplayPrivate {
         SpiceGlScanout      scanout;
     } egl;
 #endif // HAVE_EGL
-    double scroll_delta_y;
 };
 
 int      spice_cairo_image_create                 (SpiceDisplay *display);
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) {
-            if (d->scroll_delta_y < 0) {
-                press_and_release(display, SPICE_MOUSE_BUTTON_UP, button_state);
-                d->scroll_delta_y += 1;
-            } else {
-                press_and_release(display, SPICE_MOUSE_BUTTON_DOWN, button_state);
-                d->scroll_delta_y -= 1;
-            }
+        if (scroll->delta_y == 0) {
+            /* Ignore zero delta */
+            return true;
+        } else if (scroll->delta_y < 0) {
+            press_and_release(display, SPICE_MOUSE_BUTTON_UP, button_state);
+        } else {
+            press_and_release(display, SPICE_MOUSE_BUTTON_DOWN, button_state);
         }
         break;
     default:
-- 
2.17.1



More information about the Spice-devel mailing list