3 local INDENT_PER_LEVEL
=2
8 function internatom(this
, name
)
9 this
[name
] = dpy
:intern_atom_reply(dpy
:intern_atom(false, string.len(name
), name
)).atom
13 setmetatable(atom
, { __index
= internatom
})
16 io
.output():write(string.format(...))
19 function DumpTree(id
, indent
)
20 -- Show the information for this window
23 local attrcookie
= dpy
:get_window_attributes(id
)
24 local geomcookie
= dpy
:get_geometry(id
)
25 local namecookie
= dpy
:get_property(false, id
, atom
.WM_NAME
, dpy
.GET_PROPERTY_TYPE
.ANY
, 0, 80)
26 local treecookie
= dpy
:query_tree(id
)
28 local xwa
= dpy
:get_window_attributes_reply(attrcookie
)
30 mapped
= (xwa
.map_state
== dpy
.MAP_STATE
.VIEWABLE
)
34 printf("%s0x%08X ", string.rep(" ", indent
), id
);
36 printf("%s(0x%08X)", string.rep(" ", indent
), id
);
39 local geom
= dpy
:get_geometry_reply(geomcookie
)
40 printf(" %d: %d,%d [%dx%d]", geom
.depth
, geom
.x
, geom
.y
, geom
.width
, geom
.height
)
43 local prop
= dpy
:get_property_reply(namecookie
)
48 printf(" %s\n", name
);
50 -- Recursively show the information for the rest of the tree
51 local tree
= dpy
:query_tree_reply(treecookie
)
52 for k
, v
in ipairs(tree
.children
) do
53 DumpTree(v
, indent
+ INDENT_PER_LEVEL
)
59 dpy
, screen
= lxcb
.connect("")
62 print("Error: Cannot open default display.")
67 root
= tonumber(arg
[1])
69 print("Usage: DumpTree [starting window]")
73 root
= dpy
:get_setup().roots
[screen
+1].root