mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add cursor changing (WIP).
This commit is contained in:
parent
980b3217f8
commit
94186f3ef6
@ -81,6 +81,16 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
|||||||
// TODO: Handle.
|
// TODO: Handle.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Refactor.
|
||||||
|
protected ['cursor/image']({ payload }: any) {
|
||||||
|
console.log('cursor/image')
|
||||||
|
Vue.set(this.state.control, 'cursor', {
|
||||||
|
uri: payload.Uri,
|
||||||
|
hot_x: payload.Xhot,
|
||||||
|
hot_y: payload.Yhot,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Signal Events
|
// Signal Events
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
@ -4,11 +4,10 @@
|
|||||||
<video ref="video" />
|
<video ref="video" />
|
||||||
<neko-overlay
|
<neko-overlay
|
||||||
:webrtc="webrtc"
|
:webrtc="webrtc"
|
||||||
|
:control="state.control"
|
||||||
:screenWidth="state.screen.size.width"
|
:screenWidth="state.screen.size.width"
|
||||||
:screenHeight="state.screen.size.height"
|
:screenHeight="state.screen.size.height"
|
||||||
:isControling="controlling && watching"
|
:isControling="controlling && watching"
|
||||||
:scrollSensitivity="state.control.scroll.sensitivity"
|
|
||||||
:scrollInvert="state.control.scroll.inverse"
|
|
||||||
:implicitControl="state.control.implicit_hosting && state.members[state.member_id].profile.can_host"
|
:implicitControl="state.control.implicit_hosting && state.members[state.member_id].profile.can_host"
|
||||||
@implicit-control-request="websocket.send('control/request')"
|
@implicit-control-request="websocket.send('control/request')"
|
||||||
@implicit-control-release="websocket.send('control/release')"
|
@implicit-control-release="websocket.send('control/release')"
|
||||||
@ -97,6 +96,7 @@
|
|||||||
inverse: true,
|
inverse: true,
|
||||||
sensitivity: 1,
|
sensitivity: 1,
|
||||||
},
|
},
|
||||||
|
cursor: null,
|
||||||
clipboard: null,
|
clipboard: null,
|
||||||
host_id: null,
|
host_id: null,
|
||||||
implicit_hosting: false,
|
implicit_hosting: false,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
ref="overlay"
|
ref="overlay"
|
||||||
class="overlay"
|
class="overlay"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
:style="{ cursor }"
|
||||||
@click.stop.prevent
|
@click.stop.prevent
|
||||||
@contextmenu.stop.prevent
|
@contextmenu.stop.prevent
|
||||||
@wheel.stop.prevent="onWheel"
|
@wheel.stop.prevent="onWheel"
|
||||||
@ -35,6 +36,7 @@
|
|||||||
import GuacamoleKeyboard from './utils/guacamole-keyboard'
|
import GuacamoleKeyboard from './utils/guacamole-keyboard'
|
||||||
import { getFilesFromDataTansfer } from './utils/file-upload'
|
import { getFilesFromDataTansfer } from './utils/file-upload'
|
||||||
import { NekoWebRTC } from './internal/webrtc'
|
import { NekoWebRTC } from './internal/webrtc'
|
||||||
|
import { Control } from './types/state'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'neko-overlay',
|
name: 'neko-overlay',
|
||||||
@ -48,24 +50,28 @@
|
|||||||
@Prop()
|
@Prop()
|
||||||
private readonly webrtc!: NekoWebRTC
|
private readonly webrtc!: NekoWebRTC
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
private readonly control!: Control
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
private readonly screenWidth!: number
|
private readonly screenWidth!: number
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
private readonly screenHeight!: number
|
private readonly screenHeight!: number
|
||||||
|
|
||||||
@Prop()
|
|
||||||
private readonly scrollSensitivity!: number
|
|
||||||
|
|
||||||
@Prop()
|
|
||||||
private readonly scrollInvert!: boolean
|
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
private readonly isControling!: boolean
|
private readonly isControling!: boolean
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
private readonly implicitControl!: boolean
|
private readonly implicitControl!: boolean
|
||||||
|
|
||||||
|
get cursor(): string {
|
||||||
|
if (!this.control.cursor) return 'auto'
|
||||||
|
|
||||||
|
const { uri, hot_x, hot_y } = this.control.cursor
|
||||||
|
return 'url(' + uri + ') ' + hot_x + ' ' + hot_y + ', auto'
|
||||||
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
// Initialize Guacamole Keyboard
|
// Initialize Guacamole Keyboard
|
||||||
this.keyboard.onkeydown = (key: number) => {
|
this.keyboard.onkeydown = (key: number) => {
|
||||||
@ -122,13 +128,13 @@
|
|||||||
let x = e.deltaX
|
let x = e.deltaX
|
||||||
let y = e.deltaY
|
let y = e.deltaY
|
||||||
|
|
||||||
if (this.scrollInvert) {
|
if (this.control.scroll.inverse) {
|
||||||
x *= -1
|
x *= -1
|
||||||
y *= -1
|
y *= -1
|
||||||
}
|
}
|
||||||
|
|
||||||
x = Math.min(Math.max(x, -this.scrollSensitivity), this.scrollSensitivity)
|
x = Math.min(Math.max(x, -this.control.scroll.sensitivity), this.control.scroll.sensitivity)
|
||||||
y = Math.min(Math.max(y, -this.scrollSensitivity), this.scrollSensitivity)
|
y = Math.min(Math.max(y, -this.control.scroll.sensitivity), this.control.scroll.sensitivity)
|
||||||
|
|
||||||
this.setMousePos(e)
|
this.setMousePos(e)
|
||||||
this.webrtc.send('wheel', { x, y })
|
this.webrtc.send('wheel', { x, y })
|
||||||
|
@ -35,6 +35,7 @@ export interface Video {
|
|||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
export interface Control {
|
export interface Control {
|
||||||
scroll: Scroll
|
scroll: Scroll
|
||||||
|
cursor: Cursor | null
|
||||||
clipboard: Clipboard | null
|
clipboard: Clipboard | null
|
||||||
host_id: string | null
|
host_id: string | null
|
||||||
implicit_hosting: boolean
|
implicit_hosting: boolean
|
||||||
@ -45,6 +46,12 @@ export interface Scroll {
|
|||||||
sensitivity: number
|
sensitivity: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Cursor {
|
||||||
|
uri: string
|
||||||
|
hot_x: number
|
||||||
|
hot_y: number
|
||||||
|
}
|
||||||
|
|
||||||
export interface Clipboard {
|
export interface Clipboard {
|
||||||
text: string
|
text: string
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user