set screen size using struct.

This commit is contained in:
Miroslav Šedivý
2021-01-15 17:30:19 +01:00
parent 0e09609c67
commit 3bbe3781c8
8 changed files with 30 additions and 21 deletions

View File

@ -40,11 +40,7 @@ func (manager *DesktopManagerCtx) ScreenConfigurations() map[int]types.ScreenCon
return xorg.ScreenConfigurations
}
func (manager *DesktopManagerCtx) GetScreenSize() *types.ScreenSize {
return xorg.GetScreenSize()
}
func (manager *DesktopManagerCtx) ChangeScreenSize(width int, height int, rate int) error {
func (manager *DesktopManagerCtx) SetScreenSize(size types.ScreenSize) error {
mu.Lock()
manager.emmiter.Emit("before_screen_size_change")
@ -53,7 +49,11 @@ func (manager *DesktopManagerCtx) ChangeScreenSize(width int, height int, rate i
mu.Unlock()
}()
return xorg.ChangeScreenSize(width, height, rate)
return xorg.ChangeScreenSize(size.Width, size.Height, size.Rate)
}
func (manager *DesktopManagerCtx) GetScreenSize() *types.ScreenSize {
return xorg.GetScreenSize()
}
func (manager *DesktopManagerCtx) SetKeyboardMap(kbd types.KeyboardMap) error {

View File

@ -167,14 +167,14 @@ func CheckKeys(duration time.Duration) {
}
}
func ChangeScreenSize(width int, height int, rate int) error {
func ChangeScreenSize(width int, height int, rate int16) error {
mu.Lock()
defer mu.Unlock()
for index, size := range ScreenConfigurations {
if size.Width == width && size.Height == height {
for _, fps := range size.Rates {
if int16(rate) == fps {
if rate == fps {
C.XSetScreenConfiguration(C.int(index), C.short(fps))
return nil
}