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">
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'
const CANVAS_SCALE = 2
@ -38,7 +38,7 @@
private readonly canvasSize!: Dimension
@Prop()
private readonly cursors!: SessionCursor[]
private readonly cursors!: Cursor[]
@Prop()
private readonly cursorDraw!: CursorDrawFunction | null

View File

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

View File

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

View File

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

View File

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