LINUX.ORG.RU

В http://developer.gnome.org/libwnck/stable/getting-started.html написано:

At its creation, a WnckScreen object will not have fetched information from the X server. If queried immediately after its creation (via wnck_screen_get_windows() or wnck_screen_get_workspaces(), for example), the WnckScreen object will look like there are no workspaces nor windows on the screen. This information is fetched in the main event loop with an idle source, to avoid an expensive synchronous operation on startup. If no main event loop is used, or if the information is needed as soon as possible after the creation of the object, wnck_screen_force_update() can be used to explicitly fetch the information.

Internally, libwnck uses GDK. This means that before any call to libwnck API, GDK needs to be initialized. This can be achieved with gdk_init(), or indirectly via gtk_init().

Так что:

    gdk_init(&argc, &argv);

    WnckScreen *screen = wnck_screen_get_default();
    wnck_screen_force_update(screen);
    GList *windows = wnck_screen_get_windows(screen);

Вообще список окон можно спросить у X-ов (man XQueryTree).

quasimoto ★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.