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"
@implicit-control-request="websocket.send('control/request')"
@implicit-control-release="websocket.send('control/release')"
@update-kbd-modifiers="websocket.send('keyboard/modifiers', $event)"
@drop-files="uploadDrop($event)"
/>
</div>

View File

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