Search code examples
cxlibwindow-managers

Get window's input elements


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.


Solution

  • 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.