Duplicate scroll events on wxGLCanvas on wxGTK+X11 (Issue #25836)

23 views
Skip to first unread message

arch1t3cht

unread,
Sep 26, 2025, 1:35:01 PMSep 26
to wx-...@googlegroups.com, Subscribed
arch1t3cht created an issue (wxWidgets/wxWidgets#25836)

Description

Bug description:

When scrolling on a wxGLCanvas on wxGTK with X11 (I have not tested wayland/xwayland), the canvas gets duplicated scroll events:

  • When scrolling with an actual mouse wheel, every scroll event except for the first scroll seem to be sent twice.
  • When scrolling using a touch pad, lots of scroll events with small GetWheelRotation() values are sent (representing the smooth touchpad scroll), but occasionally (maybe twice a second when scrolling slowly) events with a full rotation of 120 are sent as well.

This makes it hard to implement smooth custom scrolling behavior on a wxGLCanvas.

This issue seems to be specific to wxGLCanvas, it does not seem to happen with other windows.

Patch or snippet allowing to reproduce the problem:

The following diff can be used to patch the example problems to log the events to stdout:

diff --git a/samples/opengl/pyramid/pyramid.cpp b/samples/opengl/pyramid/pyramid.cpp
index ae953eb474..5be419773b 100644
--- a/samples/opengl/pyramid/pyramid.cpp
+++ b/samples/opengl/pyramid/pyramid.cpp
@@ -379,6 +379,7 @@ wxBEGIN_EVENT_TABLE(MyGLCanvas, wxGLCanvas)
     EVT_PAINT(MyGLCanvas::OnPaint)
     EVT_SIZE(MyGLCanvas::OnSize)
     EVT_MOUSE_EVENTS(MyGLCanvas::OnMouse)
+    EVT_MOUSEWHEEL(MyGLCanvas::OnScroll)
 wxEND_EVENT_TABLE()

 //We create a wxGLContext in this constructor.
@@ -595,3 +596,8 @@ void MyGLCanvas::OnMouse(wxMouseEvent& event)
     }
 }

+void MyGLCanvas::OnScroll(wxMouseEvent &event)
+{
+    printf("Scroll by %d\n", event.GetWheelRotation());
+}
+
diff --git a/samples/opengl/pyramid/pyramid.h b/samples/opengl/pyramid/pyramid.h
index 7f84b22a79..13fff57368 100644
--- a/samples/opengl/pyramid/pyramid.h
+++ b/samples/opengl/pyramid/pyramid.h
@@ -64,6 +64,7 @@ public:
     void OnPaint(wxPaintEvent& event);
     void OnSize(wxSizeEvent& event);
     void OnMouse(wxMouseEvent& event);
+    void OnScroll(wxMouseEvent& event);

 private:
     // Members
diff --git a/samples/scroll/scroll.cpp b/samples/scroll/scroll.cpp
index c709332286..e8ab0505dc 100644
--- a/samples/scroll/scroll.cpp
+++ b/samples/scroll/scroll.cpp
@@ -704,11 +704,12 @@ void MyCanvas::OnMouseWheel( wxMouseEvent &event )
     wxPoint pt( event.GetPosition() );
     int x,y;
     CalcUnscrolledPosition( pt.x, pt.y, &x, &y );
-    wxLogMessage( "Mouse wheel event at: %d %d, scrolled: %d %d\n"
-                  "Rotation: %d, delta: %d, inverted: %d",
-                  pt.x, pt.y, x, y,
-                  event.GetWheelRotation(), event.GetWheelDelta(),
-                  event.IsWheelInverted() );
+    printf("Scroll by %d\n", event.GetWheelRotation());
+    // wxLogMessage( "Mouse wheel event at: %d %d, scrolled: %d %d\n"
+    //               "Rotation: %d, delta: %d, inverted: %d",
+    //               pt.x, pt.y, x, y,
+    //               event.GetWheelRotation(), event.GetWheelDelta(),
+    //               event.IsWheelInverted() );

     event.Skip();
 }

To Reproduce:

  1. Apply the diff above and compile the library and sample programs using wxGTK
  2. Run samples/scroll/scroll and open Test > Scrolled window with children
  3. Scroll on the opened window
    a) using a connected mouse
    b) slowly, using a touchpad
    and observe the program's stdout.
  4. Close samples/scroll/scroll and open samples/opengl/pyramid/pyramid
  5. Scroll on the canvas showing the pyramid
    a) using a connected mouse
    b) slowly, using a touchpad
    and observe the program's stdout.

For step 3), observe that scroll events are sent as normal:

3a):

[scroll the mouse wheel one discrete step]
Scroll by -120
[scroll the mouse wheel one discrete step]
Scroll by -120
[scroll the mouse wheel one discrete step]
Scroll by -120

3b):

Scroll by -9
Scroll by -17
Scroll by -17
Scroll by -25
Scroll by -29
Scroll by -34
[...]

For step 5), observe the duplicate scroll events:

5a):

[scroll the mouse wheel one discrete step]
Scroll by -120
[scroll the mouse wheel one discrete step]
Scroll by -120
Scroll by -120
[scroll the mouse wheel one discrete step]
Scroll by -120
Scroll by -120

5b):

Scroll by 3
Scroll by 3
Scroll by 3
Scroll by 3
Scroll by 3
Scroll by 3
Scroll by -3
Scroll by 1
Scroll by -4
Scroll by -4
Scroll by -6
Scroll by -3
Scroll by -4
Scroll by -3
Scroll by -6
Scroll by 1
Scroll by -3
Scroll by -6
Scroll by -3
Scroll by -6
Scroll by -3
Scroll by -6
Scroll by -6
Scroll by -3
Scroll by -6
Scroll by -3
Scroll by -1
Scroll by -1
Scroll by -1
Scroll by -3
Scroll by -1
Scroll by -1
Scroll by -1
Scroll by -1
Scroll by -120                     [  <----- note this extra event ]
Scroll by 1
Scroll by -3
Scroll by -1
Scroll by -4
Scroll by -3
Scroll by -6

Platform and version information

  • wxWidgets version you use: master
  • wxWidgets port you use: wxGTK
  • OS and its version: Arch Linux, last updated around a month ago
    • GTK version: 3.24.50
    • Which GDK backend is used: X11
    • Desktop environment : i3
    • Current theme: N/A

Analysis

It seems that wxGTK sends only GDK_SCROLL_SMOOTH events to normal windows, but sends both GDK_SCROLL_SMOOTH and GDK_SCROLL_{UP,DOWN,LEFT,RIGHT} events to wxGLCanvases. wxWidgets then converts both of these to the same scroll events (which, unfortunately, makes it hard to distinguish them and drop the duplicate ones).

I'm not yet sure if the bug is in wxWidgets or in gtk, or even in x11, and I also don't know why it's specific to wxGLCanvases, but I'm stopping to open this issue before investigating further.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25836@github.com>

VZ

unread,
Sep 27, 2025, 8:05:48 AMSep 27
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25836)

Thanks for the analysis! I guess we'll have to ignore either GDK_SCROLL_SMOOTH or all the other GDK scroll events in wxGLCanvas, right? And, if so, which ones are more "valuable"? Again, I'd guess it would be GDK_SCROLL_SMOOTH ones, but I haven't tested this yet.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25836/3341580682@github.com>

arch1t3cht

unread,
Oct 13, 2025, 5:54:15 AM (4 days ago) Oct 13
to wx-...@googlegroups.com, Subscribed
arch1t3cht left a comment (wxWidgets/wxWidgets#25836)

I had the chance to test on wayland now, and it does not seem to happen there (except with GDK_BACKEND=x11). So it looks like this indeed comes all the way from x11.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25836/3396707785@github.com>

Reply all
Reply to author
Forward
0 new messages