I've been trying to process scroll-event
s from a GTK window. I have a custom scrollbar that handles smooth scrolling events and non-smooth scrolling events differently, and simulates smooth scrolling for non-smooth scrolling events. I learned from the docs that GDK sets GdkEventScroll::direction
to GDK_SCROLL_SMOOTH
for smooth scroll events. However, I noticed that when I scroll the middle mouse button (my mouse does not support smooth scrolling), GTK sends two separate events:
- one event with
direction
set toGDK_SCROLL_UP
orGDK_SCROLL_DOWN
anddelta_y
set to 0, and - one event with
direction
set toGDK_SCROLL_SMOOTH
anddelta_y
set to 1 or -1.
Before adding the special handing I relied solely on delta_y
which happened to work fine for me. Now that I've started treating smooth and non-smooth scrolling differently, I need a reliable way to distinguish between these kinds of events.
- Is there a flag that I can set to have GDK send only non-smooth scrolling events for non-smooth scrolling, and vice versa? That would be my preferred solution.
- If the previous one is not possible, is there any way I can tell that two scroll events are actually the same event? I see that there's a
time
field in the event structure, but I doubt it'll be reliable.
Thank you.