synchronize keyboard modifiers with participant.

This commit is contained in:
Miroslav Šedivý 2021-02-18 16:53:19 +01:00
parent 91c465eeca
commit 49d6174953
2 changed files with 30 additions and 13 deletions

View File

@ -16,6 +16,7 @@
: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')"
@update-kbd-modifiers="websocket.send('keyboard/modifiers', $event)"
@drop-files="uploadDrop($event)" @drop-files="uploadDrop($event)"
/> />
</div> </div>

View File

@ -205,13 +205,8 @@
this._overlay.focus() this._overlay.focus()
this.focused = true this.focused = true
if (!this.isControling) { if (this.isControling) {
// TODO: Refactor this.updateKbdModifiers(e)
//syncKeyboardModifierState({
// capsLock: e.getModifierState('CapsLock'),
// numLock: e.getModifierState('NumLock'),
// scrollLock: e.getModifierState('ScrollLock'),
//})
} }
} }
@ -222,12 +217,11 @@
if (this.isControling) { if (this.isControling) {
this.keyboard.reset() this.keyboard.reset()
// TODO: Refactor // save current kbd modifiers state
//setKeyboardModifierState({ Vue.set(this, 'kbdModifiers', {
// capsLock: e.getModifierState('CapsLock'), capslock: e.getModifierState('CapsLock'),
// numLock: e.getModifierState('NumLock'), numlock: e.getModifierState('NumLock'),
// scrollLock: e.getModifierState('ScrollLock'), })
//})
} }
} }
@ -255,6 +249,25 @@
} }
} }
//
// keyboard modifiers
//
private kbdModifiers: { capslock: boolean; numlock: boolean } | null = null
updateKbdModifiers(e: MouseEvent) {
const capslock = e.getModifierState('CapsLock')
const numlock = e.getModifierState('NumLock')
if (
this.kbdModifiers === null ||
this.kbdModifiers.capslock !== capslock ||
this.kbdModifiers.numlock !== numlock
) {
this.$emit('update-kbd-modifiers', { capslock, numlock })
}
}
// //
// canvas // canvas
// //
@ -336,7 +349,10 @@
@Watch('isControling') @Watch('isControling')
onControlChange(isControling: boolean) { onControlChange(isControling: boolean) {
Vue.set(this, 'kbdModifiers', null)
if (isControling && this.reqMouseDown) { if (isControling && this.reqMouseDown) {
this.updateKbdModifiers(this.reqMouseDown)
this.setMousePos(this.reqMouseDown) this.setMousePos(this.reqMouseDown)
this.webrtc.send('mousedown', { key: this.reqMouseDown.button + 1 }) this.webrtc.send('mousedown', { key: this.reqMouseDown.button + 1 })
} }