GTK: Get pointer position on scroll-event AFTER scrolled_window has scrolled

StackOverflow https://stackoverflow.com/questions/8632822

  •  30-03-2021
  •  | 
  •  

سؤال

I've got a drawing area inside a scrolled window (with convenience viewport), and this drawing area updates itself according to incoming motion-notify-events. When I scroll the area though obviously no motion events are emitted, but I wanted to work around this, and so tried to connect the drawing area's "scroll-event" signal to the same motion-notify callback.

The problem I'm facing here is that this signal is emitted before the scrolled window has update its viewport, so in the callback, I end up with pointer coordinates that were true just before scrolling, making it look like the drawing area is always "lagging a step behind" the actual pointer when scrolling while not moving the pointer itself. I thought I could compensate for this by manually extracting the coordinates with gdk_window_get_pointer, but then I realized this cannot work as the pointer is technically still at its old position when the callback is commencing. I also tried using g_signal_connect_after in hopes it would have the callback get called after the viewport was scrolled, but it didn't help.

My last hope would be to start a timer on scroll-events, and have the callback fire after a minimal amount of time, but this sounds realllly ugly, and I'd like to avoid that at any cost.

Any ideas as to how this could be realized? Thanks in advance!

هل كانت مفيدة؟

المحلول

A solution would be to connect to the "value-changed" signal of the GtkScrolledWindow adjustments.

Source: https://mail.gnome.org/archives/gtk-app-devel-list/2011-September/msg00014.html

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top