haven/nexgb/examples/xinerama/main.go

41 lines
992 B
Go
Raw Normal View History

2012-05-07 10:09:19 +02:00
// Example xinerama shows how to query the geometry of all active heads.
package main
import (
"fmt"
"log"
2018-09-08 19:57:27 +02:00
xgb "janouch.name/haven/nexgb"
"janouch.name/haven/nexgb/xinerama"
2012-05-07 10:09:19 +02:00
)
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 = xinerama.Init(X)
2012-05-07 10:09:19 +02:00
if err != nil {
log.Fatal(err)
}
// Issue a request to get the screen information.
reply, err := xinerama.QueryScreens(X).Reply()
2012-05-07 10:09:19 +02:00
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)
}
}