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.
This commit is contained in:
committed by
Robert Ancell
parent
7be59e7571
commit
7436af8647
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user