Re: translating coordinate from client to screen



Jim Crafton wrote:

Hi
Is there a way to translate client coordinates of a given widget to
screen (or the default root widnow) coordindates?
in xlib I can call XTranslateCoordinates(). Is this what I should use in
gtk or is there a gtk api call that handles this?

Thanks

Jim

1. There's a function gdk_window_get_root_origin() which returns the position of the GdkWindow relative to root window. 2. In case of widgets that dont have windows (you can use GTK_WIDGET_NO_WINDOW macro to check this) you should: 2.1 Get coordinates of widget (widget->allocation), relative to its parent window.
   2.2 Use gdk_widget_get_parent_window() to get it's parent window.
2.3 Use gdk_window_get_root_origin() to get the parent window position relative to root.
   2.4 Calculate your widget position in root window.

See gtk reference for more info about these functions and macroces.

By the way, you always can use XTranslateCoordinates with XIDs obtained by macro GDK_DRAWABLE_XID.

Olexiy





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