]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Only send QEMU Extended Key Event if we have a scan code
authorPierre Ossman <ossman@cendio.se>
Fri, 7 Jul 2017 13:06:13 +0000 (15:06 +0200)
committerPierre Ossman <ossman@cendio.se>
Fri, 7 Jul 2017 13:06:13 +0000 (15:06 +0200)
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
tests/test.rfb.js

index 968cd407506f1e4737148beb62d452f6a6493176..4def709918050457788d36a5940c333468cc21c4 100644 (file)
@@ -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;
 
index b39f52e6803324b4c0b0580f347ecf234427d020..99b93b5759efb143bda5816d461eefb028f27cfb 100644 (file)
@@ -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 () {