diff options
author | Pierre Ossman <ossman@cendio.se> | 2011-05-13 12:47:54 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2011-05-13 12:47:54 +0000 |
commit | f8c5ef62fccb3d5dccf71257dfe5d30dbb524f63 (patch) | |
tree | f80a29a3e84c0180185b03a7aeb0f92e70c13d3b /vncviewer | |
parent | ad7430bb2a087fbf43f872b24494e8aab72f0d23 (diff) | |
download | tigervnc-f8c5ef62fccb3d5dccf71257dfe5d30dbb524f63.tar.gz tigervnc-f8c5ef62fccb3d5dccf71257dfe5d30dbb524f63.zip |
The initial fix for FLTK to handle dead keys broke CJK input, so a new method
had to be devised. Adopt our code to the new version.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4411 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/Viewport.cxx | 88 |
1 files changed, 7 insertions, 81 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 4fa3cfa3..6a6e983f 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -39,11 +39,6 @@ #include "parameters.h" #include "keysym2ucs.h" -// FLTK STR #2599 must be fixed for proper dead keys support -#ifndef HAVE_FLTK_DEAD_KEYS -#define event_compose_symbol event_text -#endif - using namespace rfb; #ifdef __APPLE__ @@ -64,6 +59,11 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_) : Fl_Widget(0, 0, w, h), cc(cc_), frameBuffer(NULL), pixelTrans(NULL), lastPointerPos(0, 0), lastButtonMask(0) { +// FLTK STR #2599 must be fixed for proper dead keys support +#ifdef HAVE_FLTK_DEAD_KEYS + set_simple_keyboard(); +#endif + frameBuffer = new ManagedPixelBuffer(getPreferredPF(), w, h); assert(frameBuffer); @@ -223,11 +223,11 @@ int Viewport::handle(int event) return 1; } - handleKeyEvent(Fl::event_key(), Fl::event_compose_symbol(), true); + handleKeyEvent(Fl::event_key(), Fl::event_text(), true); return 1; case FL_KEYUP: - handleKeyEvent(Fl::event_key(), Fl::event_compose_symbol(), false); + handleKeyEvent(Fl::event_key(), Fl::event_text(), false); return 1; } @@ -380,80 +380,6 @@ rdr::U32 Viewport::translateKeyEvent(int keyCode, const char *keyText) return XK_Multi_key; } - // Ctrl and Cmd tend to fudge input handling, so we need to cheat here - if (Fl::event_state() & (FL_COMMAND | FL_CTRL)) { -#ifdef WIN32 - BYTE keystate[256]; - WCHAR wbuf[8]; - int ret; - - static char buf[32]; - - switch (fl_msg.message) { - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - // Most buttons end up here when Ctrl is pressed. Here we can pretend - // that Ctrl isn't pressed, and do a character lookup. - GetKeyboardState(keystate); - keystate[VK_CONTROL] = keystate[VK_LCONTROL] = keystate[VK_RCONTROL] = 0; - - ret = ToUnicode(fl_msg.wParam, 0, keystate, wbuf, sizeof(wbuf)/sizeof(wbuf[0]), 0); - if (ret != 0) { - // -1 means one dead character - ret = abs(ret); - wbuf[ret] = 0x0000; - - if (fl_utf8fromwc(buf, sizeof(buf), wbuf, ret) >= sizeof(buf)) { - vlog.error(_("Out of buffer space whilst converting key event")); - return XK_VoidSymbol; - } - - keyText = buf; - } - break; - case WM_CHAR: - case WM_SYSCHAR: - // Windows doesn't seem to have any sanity when it comes to control - // characters. We assume that Ctrl-A through Ctrl-Z range maps to - // the VK_A through VK_Z keys, and just let the rest fall through. - if ((fl_msg.wParam < 0x01) || (fl_msg.wParam > 0x1a)) - break; - - // Pretend that Ctrl isn't pressed, and do a character lookup. - GetKeyboardState(keystate); - keystate[VK_CONTROL] = keystate[VK_LCONTROL] = keystate[VK_RCONTROL] = 0; - - // Ctrl-A is 0x01 and VK_A is 0x41, so add 0x40 for the conversion - ret = ToUnicode(fl_msg.wParam + 0x40, 0, keystate, wbuf, sizeof(wbuf)/sizeof(wbuf[0]), 0); - if (ret != 0) { - // -1 means one dead character - ret = abs(ret); - wbuf[ret] = 0x0000; - - if (fl_utf8fromwc(buf, sizeof(buf), wbuf, ret) >= sizeof(buf)) { - vlog.error(_("Out of buffer space whilst converting key event")); - return XK_VoidSymbol; - } - - keyText = buf; - } - break; - default: - // Not sure how we ended up here. Do nothing... - break; - } -#elif defined(__APPLE__) - keyText = osx_event_string(); -#else - char buf[16]; - KeySym sym; - - XLookupString((XKeyEvent*)fl_xevent, buf, sizeof(buf), &sym, NULL); - - return sym; -#endif - } - // Unknown special key? if (keyText[0] == '\0') { vlog.error(_("Unknown FLTK key code %d (0x%04x)"), keyCode, keyCode); |