From e9cf941870b2d885fac5d757b233b92345b97de5 Mon Sep 17 00:00:00 2001 From: Craig Date: Tue, 11 Feb 2020 06:10:36 +0000 Subject: [PATCH] ValidScreenSize --- server/internal/xorg/xorg.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/server/internal/xorg/xorg.go b/server/internal/xorg/xorg.go index 3de6a8d8..5b7bbeaa 100644 --- a/server/internal/xorg/xorg.go +++ b/server/internal/xorg/xorg.go @@ -292,15 +292,29 @@ func CheckKeys(duration time.Duration) { } } +func ValidScreenSize(width int, height int, rate int) bool { + for _, size := range ScreenConfigurations { + if size.Width == width && size.Height == height { + for _, fps := range size.Rates { + if int16(rate) == fps { + return true + } + } + } + } + + return false +} + func ChangeScreenSize(width int, height int, rate int) error { mu.Lock() defer mu.Unlock() for index, size := range ScreenConfigurations { if size.Width == width && size.Height == height { - for _, srate := range size.Rates { - if int16(rate) == srate { - C.XSetScreenConfiguration(C.int(index), C.short(srate)) + for _, fps := range size.Rates { + if int16(rate) == fps { + C.XSetScreenConfiguration(C.int(index), C.short(fps)) return nil } }