1 year ago
#367980
Filip Górny
XCB EWMH getting client list returns only Google Chrome windows
I am using XCB to write my own window manager. To create a taskbar I need to get list of all the windows. I could track them and keep it somewhere, but I can see on the github that many other solutions are using EWMH to do this.
However, no matter what are the circumstances, my code has only the Google Chrome windows. I am using Arch linus with Gnome 41. When using Xephyr, no windows are returned at all.
#include "tasks.h"
#include "log.h"
#include <stdio.h>
#include <stdlib.h>
#include <xcb/xcb.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xproto.h>
Task *tasks_get_all(xcb_connection_t *conn, xcb_ewmh_connection_t *ewmh,
int screen_number) {
xcb_get_property_reply_t *reply;
xcb_get_property_cookie_t cookie;
xcb_window_t *windows;
cookie = xcb_ewmh_get_client_list(ewmh, screen_number);
xcb_ewmh_get_windows_reply_t winlist;
if (!xcb_ewmh_get_client_list_reply(ewmh, cookie, &winlist, NULL)) {
log_error("Cannot get windows list");
return NULL;
}
Task *prev_task = NULL;
Task *tasks = NULL;
xcb_ewmh_get_utf8_strings_reply_t ewmh_txt_prop;
for (int i = 0; i < winlist.windows_len; i++) {
Task *task = malloc(sizeof(Task));
task->next = NULL;
task->name = "";
cookie = xcb_ewmh_get_wm_visible_name_unchecked(ewmh, winlist.windows[i]);
xcb_ewmh_get_wm_name_reply(ewmh,
xcb_ewmh_get_wm_name(ewmh, winlist.windows[i]),
&ewmh_txt_prop, NULL);
task->name = ewmh_txt_prop.strings;
ewmh_txt_prop.strings = NULL;
if (tasks == NULL) {
tasks = task;
}
if (prev_task != NULL) {
prev_task->next = task;
}
prev_task = task;
}
xcb_ewmh_get_windows_reply_wipe(&winlist);
return tasks;
}
c
x11
xcb
ewmh
0 Answers
Your Answer