Question about mouse coordinates in GDK images



I'm trying to do a fairly simple thing and I haven't been able to find any answers (that work) to my problem.

I just need to find the mouse (pointer) coordinates relative to a GDK image's origin (i.e. the pixel that would be set via a gdk_image_put_pixel() that corresponds to the pointer location).

the GDK Image I have is in a GtkImage, inside a GtkScrolledWindow (i.e. via gtk_scrolled_add_with_viewport()) and that's inside a GtkEventBox and that's inside a GtkWindow.

So basically....

GDKImage
GtkImage
GtkScrolledWindow
GtkEventBox
GtkWindow

Both gdk_window_get_pointer() and gtk_widget_get_pointer() always return coordinates relative to the base window. But if you resize the window to be larger than the image, it centers it in the window and the coordinates are wrong.

The only way I can think to deal with this is REALLY hacky, basically attempting to "predict" where the image is based on the assumption that it's centered in the main window's dimensions and doing some guesswork. But that seems like the wrong way to approach this.

Any thoughts or directions I should look at for doing this? I need to be able to deal with a scrolled view as well (i.e. you're looking at the bottom half of the image in a scrolled window).




Erik Walter
Embedded Systems Engineer
eBook Technologies, Inc.
858-551-4951
ejw ebooktechnologies com







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]