aboutsummaryrefslogtreecommitdiff
path: root/nexgb
diff options
context:
space:
mode:
authorsnyh <snyh@snyh.org>2013-12-30 16:58:14 +0800
committerPřemysl Janouch <p@janouch.name>2018-09-08 16:49:22 +0200
commit64c6e6170d86dd4b18d04c49888a6b8ac472c4d6 (patch)
treedbde0f1f2b58d060ca84f1c05fde2d9cc807f9f8 /nexgb
parent76f9adb5991081e27ebc6eec82db6bdba36c910f (diff)
downloadhaven-64c6e6170d86dd4b18d04c49888a6b8ac472c4d6.tar.gz
haven-64c6e6170d86dd4b18d04c49888a6b8ac472c4d6.tar.xz
haven-64c6e6170d86dd4b18d04c49888a6b8ac472c4d6.zip
example/randr: check the GetOutputInfo's mode length (virtual head can have zero mode)
Diffstat (limited to 'nexgb')
-rw-r--r--nexgb/examples/randr/main.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/nexgb/examples/randr/main.go b/nexgb/examples/randr/main.go
index ad575ee..427aed6 100644
--- a/nexgb/examples/randr/main.go
+++ b/nexgb/examples/randr/main.go
@@ -45,10 +45,12 @@ func main() {
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)
+ if len(info.Modes) > 0 {
+ 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)
+ }
}
}
}