]> source.dussan.org Git - tigervnc.git/commitdiff
Use a STL map to track keys so we don't have to care what range FLTK key codes
authorPierre Ossman <ossman@cendio.se>
Thu, 14 Apr 2011 14:05:13 +0000 (14:05 +0000)
committerPierre Ossman <ossman@cendio.se>
Thu, 14 Apr 2011 14:05:13 +0000 (14:05 +0000)
can have.

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

vncviewer/DesktopWindow.cxx
vncviewer/DesktopWindow.h

index 8c08aa7f8e1acbaea8fd54895cf22e533c680fb2..4c1775fc5de004e119284e16c8ed98a563d6d5cb 100644 (file)
@@ -479,17 +479,23 @@ void DesktopWindow::handleKeyEvent(int keyCode, const char *keyText, bool down)
   if (viewOnly)
     return;
 
-  if (keyCode > 0xFFFF) {
-      vlog.error(_("Too large FLTK key code %d (0x%08x)"), keyCode, keyCode);
-      return;
-  }
-
   // Because of the way keyboards work, we cannot expect to have the same
   // symbol on release as when pressed. This breaks the VNC protocol however,
   // so we need to keep track of what keysym a key _code_ generated on press
   // and send the same on release.
   if (!down) {
-    cc->writer()->keyEvent(downKeySym[keyCode], false);
+    DownMap::iterator iter;
+
+    iter = downKeySym.find(keyCode);
+    if (iter == downKeySym.end()) {
+      vlog.error(_("Unexpected release of FLTK key code %d (0x%04x)"), keyCode, keyCode);
+      return;
+    }
+
+    cc->writer()->keyEvent(iter->second, false);
+
+    downKeySym.erase(iter);
+
     return;
   }
 
index a3178fb97628b17728f0eaa76b84b5db548d39ee..bf54c211dad3bf4ac73b7c44df9d7dd3bdadc682 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef __DESKTOPWINDOW_H__
 #define __DESKTOPWINDOW_H__
 
+#include <map>
+
 #include <FL/Fl.H>
 #include <FL/Fl_Window.H>
 
@@ -116,7 +118,8 @@ private:
   rfb::Point lastPointerPos;
   int lastButtonMask;
 
-  rdr::U32 downKeySym[65536];
+  typedef std::map<int, rdr::U32> DownMap;
+  DownMap downKeySym;
 };
 
 #endif