From: Pierre Ossman Date: Fri, 22 Aug 2014 13:09:54 +0000 (+0200) Subject: Attempt to handle Ctrl+key X-Git-Tag: v1.3.90~34^2~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=13a809a6baca9572ab4a9cb992121fbc4e4ffba6;p=tigervnc.git Attempt to handle Ctrl+key Hacky attempt to try to figure out the actual key pressed when FLTK is giving us control codes. --- diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 2209fe58..16b34e6c 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -30,6 +30,7 @@ // FLTK can pull in the X11 headers on some systems #ifndef XK_VoidSymbol +#define XK_LATIN1 #define XK_MISCELLANY #define XK_XKB_KEYS #include @@ -821,11 +822,26 @@ rdr::U32 Viewport::translateKeyEvent(void) } // Unknown special key? - if (keyText[0] == '\0') { + if (keyTextLen == 0) { vlog.error(_("Unknown FLTK key code %d (0x%04x)"), keyCode, keyCode); return NoSymbol; } + // Control character? + if ((keyTextLen == 1) && ((keyText[0] < 0x20) | (keyText[0] == 0x7f))) { + if (keyText[0] == 0x00) + return XK_2; + else if (keyText[0] < 0x1b) { + if (!!Fl::event_state(FL_SHIFT) != !!Fl::event_state(FL_CAPS_LOCK)) + return keyText[0] + XK_A - 0x01; + else + return keyText[0] + XK_a - 0x01; + } else if (keyText[0] < 0x20) + return keyText[0] + XK_3 - 0x1b; + else + return XK_8; + } + // Look up the symbol the key produces and translate that from Unicode // to a X11 keysym. if (fl_utf_nb_char((const unsigned char*)keyText, strlen(keyText)) != 1) {