From be70fe0a3d94a209b369cd3443974e5ec05df551 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 7 Jul 2017 15:06:13 +0200 Subject: [PATCH] Only send QEMU Extended Key Event if we have a scan code Servers will assume that a scan code is present if this message type is used, so fall back to the standard key event message if we don't know the scan code. --- core/rfb.js | 11 ++--------- tests/test.rfb.js | 8 ++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/rfb.js b/core/rfb.js index 968cd407..4def7099 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -335,16 +335,9 @@ RFB.prototype = { return true; } - if (this._qemuExtKeyEventSupported) { - var scancode = XtScancode[code]; - - if (scancode === undefined) { - Log.Error('Unable to find a xt scancode for code: ' + code); - // FIXME: not in the spec, but this is what - // gtk-vnc does - scancode = 0; - } + var scancode = XtScancode[code]; + if (this._qemuExtKeyEventSupported && scancode) { // 0 is NoSymbol keysym = keysym || 0; diff --git a/tests/test.rfb.js b/tests/test.rfb.js index b39f52e6..99b93b57 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -224,6 +224,14 @@ describe('Remote Frame Buffer Protocol Client', function() { client.sendKey(0x20, 'Space', true); expect(client._sock).to.have.sent(expected._sQ); }); + + it('should not send QEMU extended events if unknown key code', function () { + client._qemuExtKeyEventSupported = true; + var expected = {_sQ: new Uint8Array(8), _sQlen: 0, flush: function () {}}; + RFB.messages.keyEvent(expected, 123, 1); + client.sendKey(123, 'FooBar', true); + expect(client._sock).to.have.sent(expected._sQ); + }); }); describe('#clipboardPasteFrom', function () {