GTK 4: GtkEventControllerScroll => how to access mouse coordinates?

I have successfully ported a GTK 3 code using the “scroll-event” in a GtkDrawingArea: my GTK4 GtkEventControllerScroll callback function receives the scroll x,y arguments (scrolling direction) .

But I also need to know where is pointing the mouse in my GtkDrawingArea. I don’t find how to do that. With a GtkGesture I can access those coordinates when I click. But how to access the coordinates when scrolling ?

You can use GtkEventControllerMotion to track pointer movements

Thank you for your help!
I have added a GtkEventControllerMotion. Its callback function stores the mouse coordinates in global variables, that I can access in the callback function of the GtkEventControllerScroll.
I am not sure it is elegant. But it works.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.