Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to identify top-level X11 windows using xlib?
    text
    copied!<p>I'm trying to get a list of all top level desktop windows in an X11 session. Basically, I want to get a list of all windows that are shown in the window managers application-switching UI (commonly opened when the user presses ALT+TAB).</p> <p>I've never done any X11 programming before, but so far I've managed to enumerate through the entire window list, with code that looks something like this:</p> <pre><code>void CSoftwareInfoLinux::enumerateWindows(Display *display, Window rootWindow) { Window parent; Window *children; Window *child; quint32 nNumChildren; XTextProperty wmName; XTextProperty wmCommand; int status = XGetWMName(display, rootWindow, &amp;wmName); if (status &amp;&amp; wmName.value &amp;&amp; wmName.nitems) { int i; char **list; status = XmbTextPropertyToTextList(display, &amp;wmName, &amp;list, &amp;i); if (status &gt;= Success &amp;&amp; i &amp;&amp; *list) { qDebug() &lt;&lt; "Found window with name:" &lt;&lt; (char*) *list; } status = XGetCommand(display, rootWindow, &amp;list, &amp;i); if (status &gt;= Success &amp;&amp; i &amp;&amp; *list) { qDebug() &lt;&lt; "... and Command:" &lt;&lt; i &lt;&lt; (char*) *list; } Window tf; status = XGetTransientForHint(display, rootWindow, &amp;tf); if (status &gt;= Success &amp;&amp; tf) { qDebug() &lt;&lt; "TF set!"; } XWMHints *pHints = XGetWMHints(display, rootWindow); if (pHints) { qDebug() &lt;&lt; "Flags:" &lt;&lt; pHints-&gt;flags &lt;&lt; "Window group:" &lt;&lt; pHints-&gt;window_group; } } status = XQueryTree(display, rootWindow, &amp;rootWindow, &amp;parent, &amp;children, &amp;nNumChildren); if (status == 0) { // Could not query window tree further, aborting return; } if (nNumChildren == 0) { // No more children found. Aborting return; } for (int i = 0; i &lt; nNumChildren; i++) { enumerateWindows(display, children[i]); } XFree((char*) children); } </code></pre> <p><code>enumerateWindows()</code> is called initially with the root window.</p> <p>This works, in so far as it prints out information about hundreds of windows - what I need, is to work out which property I can interrogate to determine if a given <code>Window</code> is a top-level Desktop application window (not sure what the official terminology is), or not.</p> <p>Can anyone shed some light on this? All the reference documentation I've found for X11 programming has been terribly dry and hard to understand. Perhaps someone could point be to a better resource?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload