Re: How to get Widgets absolute X/Y co-ordinates.



Olexiy Avramchenko wrote:
[snip]
Absolute screen coordinates is much harder. Here's what we have:
1) Widget's real size and position inside the *parent window* stored
in GtkWidget::allocation field.
2) gtk_widget_get_parent_window() function can give us a pointer to
the parent window. 3) Parent window coordinates in *root window* (screen coordinates) accessible via gdk_window_get_root_origin(). Looks simple ? Yep, but there's a window manager application that runs somewhere on your box and decorates your windows with nice titlebars and frames. Your widgets will be packed in decorated window with some offset, known by window manager.
So also we have:
4) gdk_window_get_frame_extents() function can talk to window manager and ask it about decorated window coordinates.

The function gdk_window_get_origin() gives you the root window coordinates without the window manager frame. This simplifies things somewhat.

--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/



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