aboutsummaryrefslogtreecommitdiff
path: root/nexgb/examples/get-active-window
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-10 17:01:42 -0400
committerAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-10 17:01:42 -0400
commit0c50dc6241fa21712e041cfa2bfb9db4ccaef10a (patch)
tree90a3200414c8ad6df8e7983a8e73fedfbe2b324e /nexgb/examples/get-active-window
parente239bb3c68a4981a3916534203c2fbd6b96f593c (diff)
downloadhaven-0c50dc6241fa21712e041cfa2bfb9db4ccaef10a.tar.gz
haven-0c50dc6241fa21712e041cfa2bfb9db4ccaef10a.tar.xz
haven-0c50dc6241fa21712e041cfa2bfb9db4ccaef10a.zip
a huge commit. splitting extensions into their own sub-packages.
Diffstat (limited to 'nexgb/examples/get-active-window')
-rw-r--r--nexgb/examples/get-active-window/main.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/nexgb/examples/get-active-window/main.go b/nexgb/examples/get-active-window/main.go
index e90563c..48e020c 100644
--- a/nexgb/examples/get-active-window/main.go
+++ b/nexgb/examples/get-active-window/main.go
@@ -7,6 +7,7 @@ import (
"log"
"github.com/BurntSushi/xgb"
+ "github.com/BurntSushi/xgb/xproto"
)
func main() {
@@ -16,18 +17,21 @@ func main() {
}
// Get the window id of the root window.
- root := X.DefaultScreen().Root
+ setup := xproto.Setup(X)
+ root := setup.DefaultScreen(X).Root
// Get the atom id (i.e., intern an atom) of "_NET_ACTIVE_WINDOW".
aname := "_NET_ACTIVE_WINDOW"
- activeAtom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply()
+ activeAtom, err := xproto.InternAtom(X, true, uint16(len(aname)),
+ aname).Reply()
if err != nil {
log.Fatal(err)
}
// Get the atom id (i.e., intern an atom) of "_NET_WM_NAME".
aname = "_NET_WM_NAME"
- nameAtom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply()
+ nameAtom, err := xproto.InternAtom(X, true, uint16(len(aname)),
+ aname).Reply()
if err != nil {
log.Fatal(err)
}
@@ -37,19 +41,19 @@ func main() {
// XGB helper function, 'Get32', to pull an unsigned 32-bit integer out
// of the byte slice. We then convert it to an X resource id so it can
// be used to get the name of the window in the next GetProperty request.
- reply, err := X.GetProperty(false, root, activeAtom.Atom,
- xgb.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
+ reply, err := xproto.GetProperty(X, false, root, activeAtom.Atom,
+ xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
if err != nil {
log.Fatal(err)
}
- windowId := xgb.Id(xgb.Get32(reply.Value))
+ windowId := xproto.Window(xgb.Get32(reply.Value))
fmt.Printf("Active window id: %X\n", windowId)
// Now get the value of _NET_WM_NAME for the active window.
// Note that this time, we simply convert the resulting byte slice,
// reply.Value, to a string.
- reply, err = X.GetProperty(false, windowId, nameAtom.Atom,
- xgb.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
+ reply, err = xproto.GetProperty(X, false, windowId, nameAtom.Atom,
+ xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
if err != nil {
log.Fatal(err)
}