]> source.dussan.org Git - tigervnc.git/commitdiff
Make sure we release the same key we previously pressed for a
authorPierre Ossman <ossman@cendio.se>
Tue, 9 Apr 2013 15:16:50 +0000 (15:16 +0000)
committerPierre Ossman <ossman@cendio.se>
Tue, 9 Apr 2013 15:16:50 +0000 (15:16 +0000)
given keysym.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5072 3789f03b-4d11-0410-bbf8-ca57d06f2519

unix/xserver/hw/vnc/Input.cc
unix/xserver/hw/vnc/Input.h

index 80490e6a3253ab1af0c24cf93879a535f6353dd8..b23aeaed4989df86cd643d1183d3a58698a37ba2 100644 (file)
@@ -130,9 +130,14 @@ static void enqueueEvents(DeviceIntPtr dev, int n)
 InputDevice::InputDevice(rfb::VNCServerST *_server)
        : server(_server), initialized(false), oldButtonMask(0)
 {
+       int i;
+
 #if XORG < 111
        initEventq();
 #endif
+
+       for (i = 0;i < 256;i++)
+               pressedKeys[i] = NoSymbol;
 }
 
 void InputDevice::PointerButtonAction(int buttonMask)
@@ -614,6 +619,28 @@ void InputDevice::keyEvent(rdr::U32 keysym, bool down)
        KeybdCtrl ctrl;
 #endif
 
+       /*
+        * Release events must match the press event, so look up what
+        * keycode we sent for the press.
+        */
+       if (!down) {
+               for (i = 0;i < 256;i++) {
+                       if (pressedKeys[i] == keysym) {
+                               pressedKeys[i] = NoSymbol;
+                               pressKey(keyboardDev, i, false, "keycode");
+                               mieqProcessInputEvents();
+                               return;
+                       }
+               }
+
+               /*
+                * This can happen quite often as we ignore some
+                * key presses.
+                */
+               vlog.debug("Unexpected release of keysym 0x%x", keysym);
+               return;
+       }
+
        /* 
         * Since we are checking the current state to determine if we need
         * to fake modifiers, we must make sure that everything put on the
@@ -856,11 +883,23 @@ ModeSwitchFound:
        } else {
 press:
                pressKey(keyboardDev, kc, down, "keycode");
+
+               /* Store the mapping so that we can do a proper release later */
+               for (i = 0;i < 256;i++) {
+                       if (i == kc)
+                               continue;
+                       if (pressedKeys[i] == keysym) {
+                               vlog.error("Keysym 0x%x generated by both keys %d and %d", keysym, i, kc);
+                               pressedKeys[i] = NoSymbol;
+                       }
+               }
+
+               pressedKeys[kc] = keysym;
        }
 
 
         FREE_MAPS;
-       
+
        /*
         * When faking a modifier we are putting a keycode (which can
         * currently activate the desired modifier) on the input
index fd458a60601744792e7f2428522948d331fc8400..fafefdede14143fba3c76481fec891bc4f0ddced 100644 (file)
@@ -74,8 +74,11 @@ private:
        bool initialized;
        DeviceIntPtr keyboardDev;
        DeviceIntPtr pointerDev;
+
        int oldButtonMask;
        rfb::Point cursorPos, oldCursorPos;
+
+       KeySym pressedKeys[256];
 };
 
 #endif