From: Pierre Ossman Date: Thu, 14 Apr 2011 14:05:13 +0000 (+0000) Subject: Use a STL map to track keys so we don't have to care what range FLTK key codes X-Git-Tag: v1.1.90~397 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d7c5b048cd82f899e276ef1428362ae868a18f5b;p=tigervnc.git Use a STL map to track keys so we don't have to care what range FLTK key codes can have. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4368 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx index 8c08aa7f..4c1775fc 100644 --- a/vncviewer/DesktopWindow.cxx +++ b/vncviewer/DesktopWindow.cxx @@ -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; } diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h index a3178fb9..bf54c211 100644 --- a/vncviewer/DesktopWindow.h +++ b/vncviewer/DesktopWindow.h @@ -20,6 +20,8 @@ #ifndef __DESKTOPWINDOW_H__ #define __DESKTOPWINDOW_H__ +#include + #include #include @@ -116,7 +118,8 @@ private: rfb::Point lastPointerPos; int lastButtonMask; - rdr::U32 downKeySym[65536]; + typedef std::map DownMap; + DownMap downKeySym; }; #endif