I just ported a C program from GTK2 to GTK3. The program uses a GtkDrawingArea
on which the mouse scroll wheel is used. After the switch to GTK3 I am not able to detect the scroll wheel usage properly anymore. Here is what I do and get:
GTK2 (2.24.10)
- I set the event mask of the
GtkDrawingArea
toGDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK
. - I connect a signal handler to
scroll-event
of theGtkDrawingArea
. - Once I use the scroll wheel, the signal handler is called and the property
direction
of theGdkEventScroll
is eitherGDK_SCROLL_UP
orGDK_SCROLL_DOWN
.
GTK3 (3.4.2)
- In addition to the above, I include
GDK_SMOOTH_SCROLL_MASK
in the event mask of theGtkDrawingArea
. Without that, my signal handler is never called. - I use the same signal handler as described above.
- Once I use the scroll wheel, the signal handler is called and the property
direction
of theGdkEventScroll
isGDK_SCROLL_SMOOTH
. Callinggdk_event_get_scroll_deltas()
gives me always 0 for bothdelta_x
anddelta_y
. I never see any other directions thanGDK_SCROLL_SMOOTH
.
I can live with receiving smooth scroll events although my mouse itself only delivers "discrete" button4/5 events, but how do I figure out the direction of the scroll event?
BTW: I am using Ubuntu 12.04 on amd64.
GDK_SCROLL_{UP|DOWN}
toGDK_SCROLL_SMOOTH
but the problem with delta_x and delta_y being 0 is not mentioned there.GDK_SCROLL_MASK
(see 1. under GTK3). Without this flag my signal handler is never called under GTK3.GDK_SCROLL_MASK
but it does not make any difference. I still only getGDK_SCROLL_SMOOTH
events.