aboutsummaryrefslogtreecommitdiff
path: root/nexgb/examples/randr/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'nexgb/examples/randr/main.go')
-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)
+ }
}
}
}