overlay use control instead of event emitter.

This commit is contained in:
Miroslav Šedivý 2022-07-21 19:37:34 +02:00
parent cf97610067
commit f3850e022c
2 changed files with 8 additions and 6 deletions

View File

@ -22,6 +22,7 @@
<neko-overlay <neko-overlay
v-show="!private_mode_enabled && connected" v-show="!private_mode_enabled && connected"
:style="{ pointerEvents: state.control.locked ? 'none' : 'auto' }" :style="{ pointerEvents: state.control.locked ? 'none' : 'auto' }"
:control="control"
:sessions="state.sessions" :sessions="state.sessions"
:hostId="state.control.host_id" :hostId="state.control.host_id"
:webrtc="connection.webrtc" :webrtc="connection.webrtc"
@ -32,12 +33,9 @@
:cursorDraw="cursorDrawFunction" :cursorDraw="cursorDrawFunction"
:implicitControl="state.settings.implicit_hosting && session.profile.can_host" :implicitControl="state.settings.implicit_hosting && session.profile.can_host"
:inactiveCursors="state.settings.inactive_cursors && session.profile.sends_inactive_cursor" :inactiveCursors="state.settings.inactive_cursors && session.profile.sends_inactive_cursor"
@implicitControlRequest="control.request()"
@implicitControlRelease="control.release()"
@updateKeyboardModifiers="updateKeyboardModifiers($event)" @updateKeyboardModifiers="updateKeyboardModifiers($event)"
@uploadDrop="uploadDrop($event)" @uploadDrop="uploadDrop($event)"
@onAction="control.emit('overlay.' + $event.action, $event.target)" @onAction="control.emit('overlay.' + $event.action, $event.target)"
@clipboard="control.paste($event)"
/> />
</div> </div>
</div> </div>

View File

@ -49,6 +49,7 @@
import GuacamoleKeyboard from './utils/guacamole-keyboard' import GuacamoleKeyboard from './utils/guacamole-keyboard'
import { KeyTable, keySymsRemap } from './utils/keyboard-remapping' import { KeyTable, keySymsRemap } from './utils/keyboard-remapping'
import { getFilesFromDataTansfer } from './utils/file-upload' import { getFilesFromDataTansfer } from './utils/file-upload'
import { NekoControl } from './internal/control'
import { NekoWebRTC } from './internal/webrtc' import { NekoWebRTC } from './internal/webrtc'
import { Session, Scroll } from './types/state' import { Session, Scroll } from './types/state'
import { CursorPosition, CursorImage } from './types/webrtc' import { CursorPosition, CursorImage } from './types/webrtc'
@ -72,6 +73,9 @@
private keyboard = GuacamoleKeyboard() private keyboard = GuacamoleKeyboard()
private focused = false private focused = false
@Prop()
private readonly control!: NekoControl
@Prop() @Prop()
private readonly sessions!: Record<string, Session> private readonly sessions!: Record<string, Session>
@ -231,7 +235,7 @@
} }
onInput(e: InputEvent) { onInput(e: InputEvent) {
this.$emit('clipboard', this._textarea.value) this.control.paste(this._textarea.value)
this._textarea.value = '' this._textarea.value = ''
} }
@ -560,7 +564,7 @@
implicitControlRequest(e: MouseEvent) { implicitControlRequest(e: MouseEvent) {
if (this.implicitControl && e.type === 'mousedown' && this.reqMouseDown == null) { if (this.implicitControl && e.type === 'mousedown' && this.reqMouseDown == null) {
this.reqMouseDown = e this.reqMouseDown = e
this.$emit('implicitControlRequest') this.control.request()
} }
if (this.implicitControl && e.type === 'mouseup' && this.reqMouseUp == null) { if (this.implicitControl && e.type === 'mouseup' && this.reqMouseUp == null) {
@ -571,7 +575,7 @@
// unused // unused
implicitControlRelease() { implicitControlRelease() {
if (this.implicitControl) { if (this.implicitControl) {
this.$emit('implicitControlRelease') this.control.release()
} }
} }
} }