mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
ignore session and host cursor.
This commit is contained in:
parent
5b34f906c6
commit
a6dea31605
@ -36,6 +36,9 @@
|
|||||||
@Prop()
|
@Prop()
|
||||||
private readonly sessionId!: string
|
private readonly sessionId!: string
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
private readonly hostId!: string | null
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
private readonly screenSize!: Dimension
|
private readonly screenSize!: Dimension
|
||||||
|
|
||||||
@ -99,36 +102,35 @@
|
|||||||
// draw current position
|
// draw current position
|
||||||
for (const p of this._points) {
|
for (const p of this._points) {
|
||||||
const { x, y } = getMovementXYatPercent(p.cursors, this._percent)
|
const { x, y } = getMovementXYatPercent(p.cursors, this._percent)
|
||||||
this.canvasRedraw(x, y, p.id)
|
this.canvasDrawCursor(x, y, p.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Watch('hostId')
|
||||||
@Watch('cursors')
|
@Watch('cursors')
|
||||||
canvasSetPosition(e: SessionCursors[]) {
|
canvasUpdateCursors() {
|
||||||
console.log('consuming', e)
|
|
||||||
|
|
||||||
// clear on no cursor
|
|
||||||
if (e.length == 0) {
|
|
||||||
this._last_points = {}
|
|
||||||
this.canvasClear()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// create points for animation
|
// create points for animation
|
||||||
this._points = []
|
this._points = []
|
||||||
for (const { id, cursors } of e) {
|
for (const { id, cursors } of this.cursors) {
|
||||||
|
// ignore my and host's cursor
|
||||||
|
if (id == this.sessionId || id == this.hostId) continue
|
||||||
|
|
||||||
|
// add last cursor position to cursors (if available)
|
||||||
let pos = { id } as SessionCursors
|
let pos = { id } as SessionCursors
|
||||||
if (id in this._last_points) {
|
if (id in this._last_points) {
|
||||||
pos.cursors = [this._last_points[id], ...cursors]
|
pos.cursors = [this._last_points[id], ...cursors]
|
||||||
} else {
|
} else {
|
||||||
pos.cursors = [...cursors]
|
pos.cursors = [...cursors]
|
||||||
}
|
}
|
||||||
|
|
||||||
this._last_points[id] = cursors[cursors.length - 1]
|
this._last_points[id] = cursors[cursors.length - 1]
|
||||||
this._points.push(pos)
|
this._points.push(pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
// no cursors to animate
|
// no cursors to animate
|
||||||
if (this._points.length == 0) {
|
if (this._points.length == 0) {
|
||||||
|
this._last_points = {}
|
||||||
|
this.canvasClear()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +142,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
canvasRedraw(x: number, y: number, id: string) {
|
canvasDrawCursor(x: number, y: number, id: string) {
|
||||||
// get intrinsic dimensions
|
// get intrinsic dimensions
|
||||||
let { width, height } = this.canvasSize
|
let { width, height } = this.canvasSize
|
||||||
x = Math.round((x / this.screenSize.width) * width)
|
x = Math.round((x / this.screenSize.width) * width)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
v-if="state.cursors.enabled && state.sessions[state.session_id].profile.can_see_inactive_cursors"
|
v-if="state.cursors.enabled && state.sessions[state.session_id].profile.can_see_inactive_cursors"
|
||||||
:sessions="state.sessions"
|
:sessions="state.sessions"
|
||||||
:sessionId="state.session_id"
|
:sessionId="state.session_id"
|
||||||
|
:hostId="state.control.host_id"
|
||||||
:screenSize="state.screen.size"
|
:screenSize="state.screen.size"
|
||||||
:canvasSize="canvasSize"
|
:canvasSize="canvasSize"
|
||||||
:cursors="state.cursors.list"
|
:cursors="state.cursors.list"
|
||||||
|
Loading…
Reference in New Issue
Block a user