1

I'm writting an application using C and Xlib and I'd like to know if it's possible to fetch a list of a window's input elements widgets (textboxes, buttons, etc).

I'm retrieving the list of windows using the XQueryTree function. What i'd like to accomplish is to be able to set focus to a certain textbox or button within a given window.

I know this is handled by the toolkit (GTK, QT, ..) but I'm wondering if theres any chance this information is made available to the Xserver.

Igor Azevedo
  • 1,145
  • 1
  • 10
  • 17
  • 1
    You want to get the list of widgets in some other processes window that are "input" elements? – Etan Reisner Oct 01 '14 at 17:40
  • I guess widgets would have been a better way to name them. Yeah, that's basicly it. I have no idea how to accomplish this or if it's even possible. Maybe I have to use other libraries? – Igor Azevedo Oct 01 '14 at 17:50
  • 1
    You can find out if the windows in question can even accept focus but I'm not sure if that's enough of a test for what you want. I don't know that you can find out what you want (but it has been a while since I've played with this stuff). I don't even know that using the toolkit involved directly is going to let you do this (they may not be set up to let you play with other application's windows/widgets this way). – Etan Reisner Oct 01 '14 at 17:52
  • 1
    No. for server it's just list of windows with some properties attached to it. The only way this is possible is if toolkit in use can communicate data you need via window properties/selections. X Server has no knowledge of buttons/textboxes/etc - this belongs to the client – Andrey Sidorov Oct 02 '14 at 05:41
  • Do you know if GTK provides any way to do this? I've looked into ATK, which seems to provide a way to know what's in the application window, but I dont think it allows me to set focus to a certain widget. – Igor Azevedo Oct 02 '14 at 10:23

1 Answers1

1

So, I've been looking into ATK and it seems to do what I need.

For anyone else wondering, the Accessibility Toolkit (ATK) developed by GNOME exposes a lot of information regarding running applications via dbus.

It allows you to traverse a tree of accessibles (parts of the application's GUI) and fetch information regarding them such as the name, states (e.g. "enabled", "visible", "editable", "focusable", ...) and role (e.g. "application", "frame", "panel", "button", "menu bar", ...). It also allows for manipulating the focus and even triggering actions (e.g. simulate a click in a button).

For development in C, I've been using the libatspi library.

Igor Azevedo
  • 1,145
  • 1
  • 10
  • 17