forked from ziutek/mdtwm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.go
68 lines (58 loc) · 1.1 KB
/
test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"code.google.com/p/x-go-binding/xgb"
"fmt"
"log"
"os"
)
var (
conn *xgb.Conn
root Window
l = log.New(os.Stderr, "test: ", 0)
)
func createWindow() {
w := NewWindow(
root, Geometry{0, 0, 100, 30, 0},
xgb.WindowClassInputOutput,
xgb.CWOverrideRedirect, 1,
)
w.Map()
}
func main() {
var err error
display := os.Getenv("DISPLAY")
conn, err = xgb.Dial(display)
if err != nil {
l.Fatal(err)
}
setupAtoms()
root = Window(conn.DefaultScreen().Root)
createWindow()
tr, err := conn.QueryTree(root.Id())
for i, id := range append(tr.Children, root.Id()) {
w := Window(id)
inst, class := w.Class()
tr, err := conn.QueryTree(id)
if err != nil {
l.Fatal("QueryTree: ", err)
}
wmName := w.Prop(AtomNetWmName, 128)
info := struct {
id, root, parent xgb.Id
ch_num uint16
name, inst, class string
g Geometry
}{
id, tr.Root, tr.Parent,
tr.ChildrenLen,
string(wmName.Value), inst, class,
Geometry{},
}
var ok bool
info.g, ok = w.Geometry()
if !ok {
return
}
fmt.Printf("%d: %+v\n", i, info)
}
}