Haoshu
Haoshu

Reputation: 914

How to get the location of the component of a window in Linux?

In Linux, one can use xwininfo to get the location of a window. Is that possible to get the location of it's component, e.g. the content area of a browser, the button of a window? -children option of xwininfo can only get the location of children windows, not components.

Upvotes: 2

Views: 531

Answers (1)

Jon Lund Steffensen
Jon Lund Steffensen

Reputation: 630

My understanding is that modern toolkits (like GTK+, Qt) do not necessarily back every component with an X11 window, but I find it hard to find a definite source for this claim. If the components, or widgets, are not backed by X11 windows, xwininfo will not be able to determine their location.

For example, GTK+ used to interpret the environment variable GDK_NATIVE_WINDOWS to mean that every GdkWindow (corresponding to every widget) should have a native window, but this was only for compatability with some applications that would not work otherwise. This feature has since been removed (https://mail.gnome.org/archives/commits-list/2011-March/msg03590.html). Gtk+/Gdk now has gtk_ensure_native_window(), but if not enabled explicitly by the programmer, it seems that Gdk will not back the widgets by X11 windows and therefore xwininfo will not be able to pick up the location of these.

It seems that there may be alternatives for specific toolkits though. For example, GTK+ has gtkparasite which might be able to give you the information on specific components, but this will only work for GTK+ applications.

Upvotes: 2

Related Questions