aboutsummaryrefslogtreecommitdiff
path: root/nexgb/examples/randr.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-05 18:22:40 -0400
committerAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-05 18:22:40 -0400
commit99bc76de54729df5494faa944d4da96a8885d51e (patch)
treea855999db11daed23007aaab866e273ffd275b86 /nexgb/examples/randr.go
parent369ad0d33e51035a3e48436fc85f60130b201437 (diff)
downloadhaven-99bc76de54729df5494faa944d4da96a8885d51e.tar.gz
haven-99bc76de54729df5494faa944d4da96a8885d51e.tar.xz
haven-99bc76de54729df5494faa944d4da96a8885d51e.zip
examples. some should be tests
Diffstat (limited to 'nexgb/examples/randr.go')
-rw-r--r--nexgb/examples/randr.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/nexgb/examples/randr.go b/nexgb/examples/randr.go
new file mode 100644
index 0000000..064856d
--- /dev/null
+++ b/nexgb/examples/randr.go
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/BurntSushi/xgb"
+)
+
+func main() {
+ X, _ := xgb.NewConn()
+
+ err := X.RegisterExtension("randr")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ resources, err := X.RandrGetScreenResources(X.DefaultScreen().Root).Reply()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ for _, output := range resources.Outputs {
+ info, err := X.RandrGetOutputInfo(output, 0).Reply()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ bestMode := info.Modes[0]
+ for _, mode := range resources.Modes {
+ if mode.Id == uint32(bestMode) {
+ fmt.Printf("Width: %d, Height: %d\n", mode.Width, mode.Height)
+ }
+ }
+ }
+
+ fmt.Println("\n")
+
+ for _, crtc := range resources.Crtcs {
+ info, err := X.RandrGetCrtcInfo(crtc, 0).Reply()
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Printf("X: %d, Y: %d, Width: %d, Height: %d\n",
+ info.X, info.Y, info.Width, info.Height)
+ }
+}
+