3 local INDENT_PER_LEVEL
=2
9 if (WM_NAME
== nil) then
10 local name
= 'WM_NAME'
11 WM_NAME
= dpy
:intern_atom_reply(dpy
:intern_atom(false, string.len(name
), name
)).atom
14 propreq
= dpy
:get_property(false, id
, WM_NAME
, dpy
.GET_PROPERTY_TYPE
.ANY
, 0, 80)
15 prop
= dpy
:get_property_reply(propreq
)
17 return string.char(unpack(prop
.value
))
24 io
.output():write(string.format(...))
27 function DumpTree(id
, indent
)
28 local root
, parent
, children
30 -- Show the information for this window
34 local xwa
= dpy
:get_window_attributes_reply(dpy
:get_window_attributes(id
))
36 mapped
= (xwa
.map_state
== dpy
.MAP_STATE
.VIEWABLE
)
39 local tp
= GetWMName(id
)
43 printf("%s0x%08X ", string.rep(" ", indent
), id
);
45 printf("%s(0x%08X)", string.rep(" ", indent
), id
);
48 local geom
= dpy
:get_geometry_reply(dpy
:get_geometry(id
))
49 printf(" %d: %d,%d [%dx%d]", geom
.depth
, geom
.x
, geom
.y
, geom
.width
, geom
.height
)
51 printf(" %s\n", name
);
53 -- Recursively show the information for the rest of the tree
54 local tree
= dpy
:query_tree_reply(dpy
:query_tree(id
))
55 for k
, v
in ipairs(tree
.children
) do
56 DumpTree(v
, indent
+ INDENT_PER_LEVEL
)
62 dpy
, screen
= lxcb
.connect("")
65 print("Error: Cannot open default display.")
70 root
= tonumber(arg
[1])
72 print("Usage: DumpTree [starting window]")
76 root
= dpy
:get_setup().roots
[screen
+1].root