From 4aa7da45e1a2e1bb87559aee1082c734948660dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Mon, 4 Jan 2021 19:39:21 +0100 Subject: [PATCH] screen change mutex, fixes "HTTP requests are not buffered - screen changing is failing". --- internal/desktop/xorg.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/desktop/xorg.go b/internal/desktop/xorg.go index c0f20d65..e4564624 100644 --- a/internal/desktop/xorg.go +++ b/internal/desktop/xorg.go @@ -1,10 +1,14 @@ package desktop import ( + "sync" + "demodesk/neko/internal/types" "demodesk/neko/internal/desktop/xorg" ) +var mu = sync.Mutex{} + func (manager *DesktopManagerCtx) Move(x, y int) { 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 { + mu.Lock() manager.emmiter.Emit("before_screen_size_change") - err := xorg.ChangeScreenSize(width, height, rate) - manager.emmiter.Emit("after_screen_size_change") - return err + + defer func() { + manager.emmiter.Emit("after_screen_size_change") + mu.Unlock() + }() + + return xorg.ChangeScreenSize(width, height, rate) } func (manager *DesktopManagerCtx) SetKeyboardLayout(layout string) {