diff options
author | Pierre Ossman <ossman@cendio.se> | 2014-07-21 16:42:12 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2014-08-22 15:10:28 +0200 |
commit | 6b9622db86bf4e35f8e5baf1be2321401659a42d (patch) | |
tree | 9dedc635652ef3095c6cc71c3855c81ff952b7e5 /vncviewer | |
parent | 4f3ac69a11b98aa7eea88a6336140bced4c66eae (diff) | |
download | tigervnc-6b9622db86bf4e35f8e5baf1be2321401659a42d.tar.gz tigervnc-6b9622db86bf4e35f8e5baf1be2321401659a42d.zip |
Add X11 keyboard handler
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/Viewport.cxx | 41 | ||||
-rw-r--r-- | vncviewer/vncviewer.cxx | 10 |
2 files changed, 51 insertions, 0 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 2b22a973..0f627229 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -647,6 +647,47 @@ bool Viewport::handleXEvent(void *event, void *data) assert(event); +#if !defined(WIN32) && !defined(__APPLE__) + XEvent *xevent = (XEvent*)event; + + if (xevent->type == KeyPress) { + char str; + KeySym keysym; + + XLookupString(&xevent->xkey, &str, 1, &keysym, NULL); + if (keysym == NoSymbol) { + vlog.error(_("No symbol for key code %d (in the current state)"), + (int)xevent->xkey.keycode); + return true; + } + + switch (keysym) { + // For the first few years, there wasn't a good consensus on what the + // Windows keys should be mapped to for X11. So we need to help out a + // bit and map all variants to the same key... + case XK_Meta_L: + case XK_Hyper_L: + keysym = XK_Super_L; + break; + case XK_Meta_R: + case XK_Hyper_R: + keysym = XK_Super_R; + break; + // There has been several variants for Shift-Tab over the years. + // RFB states that we should always send a normal tab. + case XK_ISO_Left_Tab: + keysym = XK_Tab; + break; + } + + self->handleKeyPress(xevent->xkey.keycode, keysym); + return true; + } else if (xevent->type == KeyRelease) { + self->handleKeyRelease(xevent->xkey.keycode); + return true; + } +#endif + return false; } diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 3f039379..82286ab8 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -36,6 +36,11 @@ #define mkdir(path, mode) _mkdir(path) #endif +#if !defined(WIN32) && !defined(__APPLE__) +#include <X11/Xlib.h> +#include <X11/XKBlib.h> +#endif + #include <rfb/Logger_stdio.h> #include <rfb/SecurityClient.h> #include <rfb/Security.h> @@ -386,6 +391,11 @@ int main(int argc, char** argv) init_fltk(); +#if !defined(WIN32) && !defined(__APPLE__) + fl_open_display(); + XkbSetDetectableAutoRepeat(fl_display, True, NULL); +#endif + Configuration::enableViewerParams(); /* Load the default parameter settings */ |