screen change mutex, fixes "HTTP requests are not buffered - screen changing is failing".

This commit is contained in:
Miroslav Šedivý 2021-01-04 19:39:21 +01:00
parent 245c3d9635
commit 4aa7da45e1

View File

@ -1,10 +1,14 @@
package desktop package desktop
import ( import (
"sync"
"demodesk/neko/internal/types" "demodesk/neko/internal/types"
"demodesk/neko/internal/desktop/xorg" "demodesk/neko/internal/desktop/xorg"
) )
var mu = sync.Mutex{}
func (manager *DesktopManagerCtx) Move(x, y int) { func (manager *DesktopManagerCtx) Move(x, y int) {
xorg.Move(x, y) xorg.Move(x, y)
} }
@ -42,10 +46,15 @@ func (manager *DesktopManagerCtx) GetScreenSize() *types.ScreenSize {
} }
func (manager *DesktopManagerCtx) ChangeScreenSize(width int, height int, rate int) error { func (manager *DesktopManagerCtx) ChangeScreenSize(width int, height int, rate int) error {
mu.Lock()
manager.emmiter.Emit("before_screen_size_change") manager.emmiter.Emit("before_screen_size_change")
err := xorg.ChangeScreenSize(width, height, rate)
manager.emmiter.Emit("after_screen_size_change") defer func() {
return err manager.emmiter.Emit("after_screen_size_change")
mu.Unlock()
}()
return xorg.ChangeScreenSize(width, height, rate)
} }
func (manager *DesktopManagerCtx) SetKeyboardLayout(layout string) { func (manager *DesktopManagerCtx) SetKeyboardLayout(layout string) {