I am trying to get the number of top level windows aka children of the root window in Xlib using XQuerytree.
It is just working fine when only experimenting with basic X utilities such as Xterm or Xeyes but the num_top_level_windows
contains a completely wrong number for apps using GTK or QT frameworks (e.g. with only KeepassXC open, i apparently have 5 top level windows).
Here is the relevant code snippet
Window returned_root, returned_parent;
Window* top_level_windows;
unsigned int num_top_level_windows;
XQueryTree(
display_,
root_,
&returned_root,
&returned_parent,
&top_level_windows,
&num_top_level_windows);
printf("\n\n N: %d\n", num_top_level_windows);
root_
and display_
are references to the root window and the display (obtained via XOpenDisplay and DefaultRootWindow(display_) and should be working fine.
I am using a nested Xephyr X server session on gentoo linux. I really wonder why this "error" occurs and how can i get the true number of children windows.
Thank you in advance!