ValidScreenSize

This commit is contained in:
Craig 2020-02-11 06:10:36 +00:00
parent 9e995233af
commit e9cf941870

View File

@ -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 { func ChangeScreenSize(width int, height int, rate int) error {
mu.Lock() mu.Lock()
defer mu.Unlock() defer mu.Unlock()
for index, size := range ScreenConfigurations { for index, size := range ScreenConfigurations {
if size.Width == width && size.Height == height { if size.Width == width && size.Height == height {
for _, srate := range size.Rates { for _, fps := range size.Rates {
if int16(rate) == srate { if int16(rate) == fps {
C.XSetScreenConfiguration(C.int(index), C.short(srate)) C.XSetScreenConfiguration(C.int(index), C.short(fps))
return nil return nil
} }
} }