From 2068c0ee05e68c907bfd752135860a13b1b08374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Thu, 21 Oct 2021 22:53:54 +0200 Subject: [PATCH] webrtc remote desktop from cursor pos. --- internal/webrtc/cursor/position.go | 10 +--------- internal/webrtc/manager.go | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/internal/webrtc/cursor/position.go b/internal/webrtc/cursor/position.go index de5994fd..81b65eed 100644 --- a/internal/webrtc/cursor/position.go +++ b/internal/webrtc/cursor/position.go @@ -6,21 +6,17 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" - - "demodesk/neko/internal/types" ) -func NewPosition(desktop types.DesktopManager) *PositionCtx { +func NewPosition() *PositionCtx { return &PositionCtx{ logger: log.With().Str("module", "webrtc").Str("submodule", "cursor-position").Logger(), - desktop: desktop, listeners: map[uintptr]*func(x, y int){}, } } type PositionCtx struct { logger zerolog.Logger - desktop types.DesktopManager emitMu sync.Mutex listeners map[uintptr]*func(x, y int) } @@ -35,10 +31,6 @@ func (manager *PositionCtx) Shutdown() { manager.emitMu.Unlock() } -func (manager *PositionCtx) Get() (x, y int) { - return manager.desktop.GetCursorPosition() -} - func (manager *PositionCtx) Set(x, y int) { for _, emit := range manager.listeners { (*emit)(x, y) diff --git a/internal/webrtc/manager.go b/internal/webrtc/manager.go index f71726f6..20407936 100644 --- a/internal/webrtc/manager.go +++ b/internal/webrtc/manager.go @@ -34,7 +34,7 @@ func New(desktop types.DesktopManager, capture types.CaptureManager, config *con desktop: desktop, capture: capture, curImage: cursor.NewImage(desktop), - curPosition: cursor.NewPosition(desktop), + curPosition: cursor.NewPosition(), } } @@ -198,7 +198,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin } // send initial cursor position - x, y := manager.curPosition.Get() + x, y := manager.desktop.GetCursorPosition() cursorPosition(x, y) })