mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
use session ID in cursor draw functions.
This commit is contained in:
parent
5ffc6cadce
commit
c67e6c7dc3
@ -194,15 +194,15 @@
|
|||||||
x = Math.round((x / this.screenSize.width) * width)
|
x = Math.round((x / this.screenSize.width) * width)
|
||||||
y = Math.round((y / this.screenSize.height) * height)
|
y = Math.round((y / this.screenSize.height) * height)
|
||||||
|
|
||||||
// get cursor tag
|
|
||||||
const cursorTag = this.sessions[id]?.profile.name || ''
|
|
||||||
|
|
||||||
// use custom draw function, if available
|
// use custom draw function, if available
|
||||||
if (this.cursorDraw) {
|
if (this.cursorDraw) {
|
||||||
this.cursorDraw(this._ctx, x, y, cursorTag)
|
this.cursorDraw(this._ctx, x, y, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get cursor tag
|
||||||
|
const cursorTag = this.sessions[id]?.profile.name || ''
|
||||||
|
|
||||||
// draw inactive cursor tag
|
// draw inactive cursor tag
|
||||||
this._ctx.save()
|
this._ctx.save()
|
||||||
this._ctx.font = '14px Arial, sans-serif'
|
this._ctx.font = '14px Arial, sans-serif'
|
||||||
|
@ -14,16 +14,13 @@
|
|||||||
:cursorDraw="inactiveCursorDrawFunction"
|
:cursorDraw="inactiveCursorDrawFunction"
|
||||||
/>
|
/>
|
||||||
<neko-overlay
|
<neko-overlay
|
||||||
|
:sessions="state.sessions"
|
||||||
|
:hostId="state.control.host_id"
|
||||||
:webrtc="connection.webrtc"
|
:webrtc="connection.webrtc"
|
||||||
:scroll="state.control.scroll"
|
:scroll="state.control.scroll"
|
||||||
:screenSize="state.screen.size"
|
:screenSize="state.screen.size"
|
||||||
:canvasSize="canvasSize"
|
:canvasSize="canvasSize"
|
||||||
:isControling="controlling"
|
:isControling="controlling"
|
||||||
:cursorTag="
|
|
||||||
state.control.implicit_hosting && state.control.host_id != null
|
|
||||||
? state.sessions[state.control.host_id].profile.name
|
|
||||||
: ''
|
|
||||||
"
|
|
||||||
: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="state.cursors.enabled && state.sessions[state.session_id].profile.sends_inactive_cursor"
|
:inactiveCursors="state.cursors.enabled && state.sessions[state.session_id].profile.sends_inactive_cursor"
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
import { keySymsRemap } from './utils/keyboard-remapping'
|
import { keySymsRemap } from './utils/keyboard-remapping'
|
||||||
import { getFilesFromDataTansfer } from './utils/file-upload'
|
import { getFilesFromDataTansfer } from './utils/file-upload'
|
||||||
import { NekoWebRTC } from './internal/webrtc'
|
import { NekoWebRTC } from './internal/webrtc'
|
||||||
import { Scroll } from './types/state'
|
import { Session, Scroll } from './types/state'
|
||||||
import { CursorPosition, CursorImage } from './types/webrtc'
|
import { CursorPosition, CursorImage } from './types/webrtc'
|
||||||
import { CursorDrawFunction, Dimension, KeyboardModifiers } from './types/cursors'
|
import { CursorDrawFunction, Dimension, KeyboardModifiers } from './types/cursors'
|
||||||
|
|
||||||
@ -58,6 +58,12 @@
|
|||||||
private keyboard = GuacamoleKeyboard()
|
private keyboard = GuacamoleKeyboard()
|
||||||
private focused = false
|
private focused = false
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
private readonly sessions!: Record<string, Session>
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
private readonly hostId!: string
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
private readonly webrtc!: NekoWebRTC
|
private readonly webrtc!: NekoWebRTC
|
||||||
|
|
||||||
@ -70,9 +76,6 @@
|
|||||||
@Prop()
|
@Prop()
|
||||||
private readonly canvasSize!: Dimension
|
private readonly canvasSize!: Dimension
|
||||||
|
|
||||||
@Prop()
|
|
||||||
private readonly cursorTag!: string
|
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
private readonly cursorDraw!: CursorDrawFunction | null
|
private readonly cursorDraw!: CursorDrawFunction | null
|
||||||
|
|
||||||
@ -421,8 +424,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Watch('hostId')
|
||||||
@Watch('cursorDraw')
|
@Watch('cursorDraw')
|
||||||
@Watch('cursorTag')
|
|
||||||
canvasRequestRedraw() {
|
canvasRequestRedraw() {
|
||||||
// skip rendering if there is already in progress
|
// skip rendering if there is already in progress
|
||||||
if (this.canvasRequestedFrame) return
|
if (this.canvasRequestedFrame) return
|
||||||
@ -459,7 +462,7 @@
|
|||||||
|
|
||||||
// use custom draw function, if available
|
// use custom draw function, if available
|
||||||
if (this.cursorDraw) {
|
if (this.cursorDraw) {
|
||||||
this.cursorDraw(this._ctx, x, y, this.cursorElement, this.cursorImage, this.cursorTag)
|
this.cursorDraw(this._ctx, x, y, this.cursorElement, this.cursorImage, this.hostId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,7 +476,8 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
// draw cursor tag
|
// draw cursor tag
|
||||||
if (this.cursorTag) {
|
const cursorTag = this.sessions[this.hostId]?.profile.name || ''
|
||||||
|
if (cursorTag) {
|
||||||
x += this.cursorImage.width
|
x += this.cursorImage.width
|
||||||
y += this.cursorImage.height
|
y += this.cursorImage.height
|
||||||
|
|
||||||
@ -484,10 +488,10 @@
|
|||||||
this._ctx.shadowBlur = 2
|
this._ctx.shadowBlur = 2
|
||||||
this._ctx.lineWidth = 2
|
this._ctx.lineWidth = 2
|
||||||
this._ctx.fillStyle = 'black'
|
this._ctx.fillStyle = 'black'
|
||||||
this._ctx.strokeText(this.cursorTag, x, y)
|
this._ctx.strokeText(cursorTag, x, y)
|
||||||
this._ctx.shadowBlur = 0
|
this._ctx.shadowBlur = 0
|
||||||
this._ctx.fillStyle = 'white'
|
this._ctx.fillStyle = 'white'
|
||||||
this._ctx.fillText(this.cursorTag, x, y)
|
this._ctx.fillText(cursorTag, x, y)
|
||||||
this._ctx.restore()
|
this._ctx.restore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ export type CursorDrawFunction = (
|
|||||||
y: number,
|
y: number,
|
||||||
cursorElement: HTMLImageElement,
|
cursorElement: HTMLImageElement,
|
||||||
cursorImage: CursorImage,
|
cursorImage: CursorImage,
|
||||||
cursorTag: string,
|
sessionId: string,
|
||||||
) => void
|
) => void
|
||||||
|
|
||||||
export type InactiveCursorDrawFunction = (
|
export type InactiveCursorDrawFunction = (
|
||||||
ctx: CanvasRenderingContext2D,
|
ctx: CanvasRenderingContext2D,
|
||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
cursorTag: string,
|
sessionId: string,
|
||||||
) => void
|
) => void
|
||||||
|
|
||||||
export interface Dimension {
|
export interface Dimension {
|
||||||
|
Loading…
Reference in New Issue
Block a user