cursor image as WS event.

This commit is contained in:
Miroslav Šedivý 2021-01-10 12:37:32 +01:00
parent 9782b8391d
commit 589628f6ca
3 changed files with 24 additions and 8 deletions

View File

@ -44,6 +44,10 @@ const (
KEYBOARD_LAYOUT = "keyboard/layout"
)
const (
CURSOR_IMAGE = "cursor/image"
)
const (
BORADCAST_STATUS = "broadcast/status"
)

View File

@ -143,6 +143,19 @@ type KeyboardLayout struct {
Layout string `json:"layout"`
}
/////////////////////////////
// Cursor
/////////////////////////////
type CursorImage struct {
Event string `json:"event,omitempty"`
Uri string `json:"uri"`
Width uint16 `json:"width"`
Height uint16 `json:"height"`
X uint16 `json:"x"`
Y uint16 `json:"y"`
}
/////////////////////////////
// Broadcast
/////////////////////////////

View File

@ -118,15 +118,14 @@ func (ws *WebSocketManagerCtx) Start() {
if cursor != cur.Serial || cur.Serial == 0 {
cursor = cur.Serial
// TODO: Refactor.
uri, _ := utils.GetCursorImageURI(cur)
ws.sessions.Broadcast(message.Message{
Event: "cursor/image",
Payload: struct{
Xhot uint16
Yhot uint16
Uri string
}{ cur.Xhot, cur.Yhot, uri },
ws.sessions.Broadcast(message.CursorImage{
Event: event.CURSOR_IMAGE,
Uri: uri,
Width: cur.Width,
Height: cur.Height,
X: cur.Xhot,
Y: cur.Yhot,
}, nil)
}