inactive cursors enabled from server.

This commit is contained in:
Miroslav Šedivý 2021-11-01 20:49:59 +01:00
parent 077105332f
commit ec477f619b
5 changed files with 25 additions and 9 deletions

View File

@ -16,7 +16,7 @@
<script lang="ts"> <script lang="ts">
import { Vue, Component, Ref, Prop, Watch } from 'vue-property-decorator' import { Vue, Component, Ref, Prop, Watch } from 'vue-property-decorator'
import { SessionCursor } from './types/state' import { Cursor } from './types/state'
import { CursorDrawFunction, Dimension } from './types/cursors' import { CursorDrawFunction, Dimension } from './types/cursors'
const CANVAS_SCALE = 2 const CANVAS_SCALE = 2
@ -38,7 +38,7 @@
private readonly canvasSize!: Dimension private readonly canvasSize!: Dimension
@Prop() @Prop()
private readonly cursors!: SessionCursor[] private readonly cursors!: Cursor[]
@Prop() @Prop()
private readonly cursorDraw!: CursorDrawFunction | null private readonly cursorDraw!: CursorDrawFunction | null

View File

@ -83,6 +83,7 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
this._localLog.debug(`EVENT.SYSTEM_INIT`) this._localLog.debug(`EVENT.SYSTEM_INIT`)
Vue.set(this._state, 'session_id', conf.session_id) Vue.set(this._state, 'session_id', conf.session_id)
Vue.set(this._state.control, 'implicit_hosting', conf.implicit_hosting) Vue.set(this._state.control, 'implicit_hosting', conf.implicit_hosting)
Vue.set(this._state.cursors, 'enabled', conf.inactive_cursors)
Vue.set(this._state.connection, 'screencast', conf.screencast_enabled) Vue.set(this._state.connection, 'screencast', conf.screencast_enabled)
Vue.set(this._state.connection.webrtc, 'videos', conf.webrtc.videos) Vue.set(this._state.connection.webrtc, 'videos', conf.webrtc.videos)
@ -189,8 +190,7 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
} }
protected [EVENT.SESSION_CURSORS](cursors: message.SessionCursor[]) { protected [EVENT.SESSION_CURSORS](cursors: message.SessionCursor[]) {
// TODO: State retention logic. Vue.set(this._state.cursors, 'list', cursors)
Vue.set(this._state, 'cursors', cursors)
} }
///////////////////////////// /////////////////////////////

View File

@ -4,10 +4,11 @@
<video v-show="!screencast" ref="video" :autoplay="autoplay" :muted="autoplay" playsinline /> <video v-show="!screencast" ref="video" :autoplay="autoplay" :muted="autoplay" playsinline />
<neko-screencast v-show="screencast" :enabled="screencast" :api="api.room" /> <neko-screencast v-show="screencast" :enabled="screencast" :api="api.room" />
<neko-cursors <neko-cursors
v-if="state.cursors.enabled"
:sessionId="state.session_id" :sessionId="state.session_id"
:screenSize="state.screen.size" :screenSize="state.screen.size"
:canvasSize="canvasSize" :canvasSize="canvasSize"
:cursors="state.cursors" :cursors="state.cursors.list"
/> />
<neko-overlay <neko-overlay
:webrtc="connection.webrtc" :webrtc="connection.webrtc"
@ -22,7 +23,7 @@
" "
:cursorDraw="cursorDrawFunction" :cursorDraw="cursorDrawFunction"
:implicitControl="state.control.implicit_hosting && state.sessions[state.session_id].profile.can_host" :implicitControl="state.control.implicit_hosting && state.sessions[state.session_id].profile.can_host"
:inactiveCursors="true" :inactiveCursors="state.cursors.enabled"
@implicitControlRequest="connection.websocket.send('control/request')" @implicitControlRequest="connection.websocket.send('control/request')"
@implicitControlRelease="connection.websocket.send('control/release')" @implicitControlRelease="connection.websocket.send('control/release')"
@updateKeyboardModifiers="updateKeyboardModifiers($event)" @updateKeyboardModifiers="updateKeyboardModifiers($event)"
@ -168,7 +169,10 @@
}, },
session_id: null, session_id: null,
sessions: {}, sessions: {},
cursors: [], cursors: {
enabled: false,
list: [],
},
} as NekoState } as NekoState
///////////////////////////// /////////////////////////////
@ -545,6 +549,8 @@
Vue.set(this.state.screen, 'configurations', []) Vue.set(this.state.screen, 'configurations', [])
Vue.set(this.state, 'session_id', null) Vue.set(this.state, 'session_id', null)
Vue.set(this.state, 'sessions', {}) Vue.set(this.state, 'sessions', {})
Vue.set(this.state.cursors, 'enabled', false)
Vue.set(this.state.cursors, 'list', [])
// webrtc // webrtc
Vue.set(this.state.connection.webrtc, 'stats', null) Vue.set(this.state.connection.webrtc, 'stats', null)

View File

@ -14,6 +14,7 @@ export interface SystemInit {
screen_size: ScreenSize screen_size: ScreenSize
sessions: Record<string, SessionData> sessions: Record<string, SessionData>
implicit_hosting: boolean implicit_hosting: boolean
inactive_cursors: boolean
screencast_enabled: boolean screencast_enabled: boolean
webrtc: SystemWebRTC webrtc: SystemWebRTC
} }

View File

@ -9,7 +9,7 @@ export default interface State {
screen: Screen screen: Screen
session_id: string | null session_id: string | null
sessions: Record<string, Session> sessions: Record<string, Session>
cursors: SessionCursor[] cursors: Cursors
} }
///////////////////////////// /////////////////////////////
@ -120,7 +120,16 @@ export interface Session {
state: SessionState state: SessionState
} }
export interface SessionCursor { /////////////////////////////
// Cursors
/////////////////////////////
export interface Cursors {
enabled: boolean
list: Cursor[]
}
export interface Cursor {
id: string id: string
x: number x: number
y: number y: number