<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Linux Forum &mdash; Xlib: получение списка окон и их имен]]></title>
		<link>https://linuxforum.ru/viewtopic.php?id=11560</link>
		<atom:link href="https://linuxforum.ru/extern.php?action=feed&amp;tid=11560&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Xlib: получение списка окон и их имен».]]></description>
		<lastBuildDate>Thu, 21 Apr 2011 10:16:38 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Xlib: получение списка окон и их имен]]></title>
			<link>https://linuxforum.ru/viewtopic.php?pid=170685#p170685</link>
			<description><![CDATA[<p>Скорее всего название окна на русском языке. У меня в этом случае XFetchName тоже возвращает NULL. Для имен на английском все отрабатывает корректно.</p>]]></description>
			<author><![CDATA[null@example.com (j5ew9)]]></author>
			<pubDate>Thu, 21 Apr 2011 10:16:38 +0000</pubDate>
			<guid>https://linuxforum.ru/viewtopic.php?pid=170685#p170685</guid>
		</item>
		<item>
			<title><![CDATA[Xlib: получение списка окон и их имен]]></title>
			<link>https://linuxforum.ru/viewtopic.php?pid=152459#p152459</link>
			<description><![CDATA[<p>Пытаюсь получить список окон и их имена<br /></p><div class="codebox"><pre><code>#include &lt;stdio.h&gt;
#include &lt;X11/Xlib.h&gt;
#include &lt;X11/Xatom.h&gt;

#include &lt;assert.h&gt;

static void* x11property(Display *dpy, Window win, Atom prop, Atom type, int *nitems) {
   Atom type_ret;
   int format_ret;
   unsigned long items_ret;
   unsigned long after_ret;
   unsigned char *prop_data = 0;

   if (XGetWindowProperty(dpy, win, prop, 0, 0x7fffffff, False, type,
         &amp;type_ret, &amp;format_ret, &amp;items_ret, &amp;after_ret, &amp;prop_data) != Success)
      return 0;

   if (nitems)
      *nitems = items_ret;

   return prop_data;
}

int main() {
    Atom atom_client_list;
    Atom atom_netwmname;
    Atom atom_utf8;
    Display *dpy;
    Window root, *winlist, activewin;
    int num;

    dpy = XOpenDisplay(NULL);
    assert(dpy != NULL);

    root = DefaultRootWindow(dpy);

    atom_client_list = XInternAtom(dpy, &quot;_NET_CLIENT_LIST&quot;, False);

    atom_netwmname = XInternAtom(dpy, &quot;_NET_WM_NAME&quot;, False);
    atom_utf8 = XInternAtom(dpy, &quot;UTF8_STRING&quot;, False);

    winlist = (Window*)x11property(dpy, root, atom_client_list, XA_WINDOW, &amp;num);
    if (winlist) {
        int i;
        for (i = 0; i &lt; num; ++i) {
            /*
            char *name = NULL;
            XFetchName(dpy, winlist[i], &amp;name);
            printf(&quot;%c %#lx %s\n&quot;, winlist[i] == activewin ? &#039;*&#039; : &#039; &#039;, (unsigned long) winlist[i], name);
            XFree(name);*/
            unsigned char *name = NULL;
            name = (unsigned char *)x11property(dpy, winlist[i], atom_netwmname, atom_utf8, NULL);
            printf(&quot;name == NULL - %s\n&quot;, name == NULL ? &quot;True&quot; : &quot;False&quot;);
            printf(&quot;%s\n&quot;, name);
            XFree(name);
        }
        XFree(winlist);
    }

    XCloseDisplay(dpy);

    return 0;
}</code></pre></div><p>но переменная name всегда == NULL. Не подскажите рабочий код?</p>]]></description>
			<author><![CDATA[null@example.com (unk)]]></author>
			<pubDate>Fri, 04 Mar 2011 09:57:34 +0000</pubDate>
			<guid>https://linuxforum.ru/viewtopic.php?pid=152459#p152459</guid>
		</item>
	</channel>
</rss>
