mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
webrtc remote desktop from cursor pos.
This commit is contained in:
parent
d5c0c62675
commit
2068c0ee05
@ -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)
|
||||
|
@ -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)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user