aboutsummaryrefslogtreecommitdiff
path: root/nexgb/examples/xinerama
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-07 04:09:19 -0400
committerAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-07 04:09:19 -0400
commitdc48249e1acea54b391f53b95f16e515dead7c97 (patch)
tree3467fee8294f8800977de0df3030d82e69bb7528 /nexgb/examples/xinerama
parent3bf376bd6648e011de9131c1d90a39c6d3890d65 (diff)
downloadhaven-dc48249e1acea54b391f53b95f16e515dead7c97.tar.gz
haven-dc48249e1acea54b391f53b95f16e515dead7c97.tar.xz
haven-dc48249e1acea54b391f53b95f16e515dead7c97.zip
lots of docs and examples
Diffstat (limited to 'nexgb/examples/xinerama')
-rw-r--r--nexgb/examples/xinerama/main.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/nexgb/examples/xinerama/main.go b/nexgb/examples/xinerama/main.go
new file mode 100644
index 0000000..ec7f46a
--- /dev/null
+++ b/nexgb/examples/xinerama/main.go
@@ -0,0 +1,39 @@
+// Example xinerama shows how to query the geometry of all active heads.
+package main
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/BurntSushi/xgb"
+)
+
+func main() {
+ X, err := xgb.NewConn()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // Initialize the Xinerama extension.
+ // The appropriate 'Init' function must be run for *every*
+ // extension before any of its requests can be used.
+ err = X.XineramaInit()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // Issue a request to get the screen information.
+ reply, err := X.XineramaQueryScreens().Reply()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ // reply.Number is the number of active heads, while reply.ScreenInfo
+ // is a slice of XineramaScreenInfo containing the rectangle geometry
+ // of each head.
+ fmt.Printf("Number of heads: %d\n", reply.Number)
+ for i, screen := range reply.ScreenInfo {
+ fmt.Printf("%d :: X: %d, Y: %d, Width: %d, Height: %d\n",
+ i, screen.XOrg, screen.YOrg, screen.Width, screen.Height)
+ }
+}