From 7436af86475293f7587cdce3b56b755fecd74d11 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Thu, 17 Dec 2020 16:18:05 +1300 Subject: [PATCH] Only handle smooth scroll events. On X11 scroll events are being directly sent to the FlView X window. This is causing them to bypass the normal scroll handling and means this widget received both smooth and non-smooth scroll events. I haven't been able to find a solution to the root cause of the problem, so only smooth scroll event are being processed. This could cause issues on older versions of the X server that don't send smooth scroll events, but fixes the problem for the common modern case. This issue doesn't occur in Wayland. --- .../flutter/shell/platform/linux/fl_renderer.cc | 4 ++-- .../src/flutter/shell/platform/linux/fl_view.cc | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/engine/src/flutter/shell/platform/linux/fl_renderer.cc b/engine/src/flutter/shell/platform/linux/fl_renderer.cc index 69dc440bf1..f44bd7b527 100644 --- a/engine/src/flutter/shell/platform/linux/fl_renderer.cc +++ b/engine/src/flutter/shell/platform/linux/fl_renderer.cc @@ -116,8 +116,8 @@ static gboolean setup_gdk_window(FlRenderer* self, window_attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK | - GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK; + GDK_BUTTON_RELEASE_MASK | GDK_SMOOTH_SCROLL_MASK | GDK_KEY_PRESS_MASK | + GDK_KEY_RELEASE_MASK; gint window_attributes_mask = GDK_WA_X | GDK_WA_Y; diff --git a/engine/src/flutter/shell/platform/linux/fl_view.cc b/engine/src/flutter/shell/platform/linux/fl_view.cc index 6fa6fbaacc..f6cd10b13d 100644 --- a/engine/src/flutter/shell/platform/linux/fl_view.cc +++ b/engine/src/flutter/shell/platform/linux/fl_view.cc @@ -322,14 +322,14 @@ static gboolean fl_view_scroll_event(GtkWidget* widget, GdkEventScroll* event) { if (event->direction == GDK_SCROLL_SMOOTH) { scroll_delta_x = event->delta_x; scroll_delta_y = event->delta_y; - } else if (event->direction == GDK_SCROLL_UP) { - scroll_delta_y = -1; - } else if (event->direction == GDK_SCROLL_DOWN) { - scroll_delta_y = 1; - } else if (event->direction == GDK_SCROLL_LEFT) { - scroll_delta_x = -1; - } else if (event->direction == GDK_SCROLL_RIGHT) { - scroll_delta_x = 1; + } else { + // We currently skip non-smooth scroll events due to the X11 events being + // delivered directly to the FlView X window and bypassing the GtkWindow + // handling. + // This causes both smooth and non-smooth events to be received (i.e. + // duplication). + // https://github.com/flutter/flutter/issues/73823 + return FALSE; } // TODO(robert-ancell): See if this can be queried from the OS; this value is