summaryrefslogtreecommitdiffstats
path: root/vncviewer/Viewport.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-07-21 16:42:12 +0200
committerPierre Ossman <ossman@cendio.se>2014-08-22 15:10:28 +0200
commit6b9622db86bf4e35f8e5baf1be2321401659a42d (patch)
tree9dedc635652ef3095c6cc71c3855c81ff952b7e5 /vncviewer/Viewport.cxx
parent4f3ac69a11b98aa7eea88a6336140bced4c66eae (diff)
downloadtigervnc-6b9622db86bf4e35f8e5baf1be2321401659a42d.tar.gz
tigervnc-6b9622db86bf4e35f8e5baf1be2321401659a42d.zip
Add X11 keyboard handler
Diffstat (limited to 'vncviewer/Viewport.cxx')
-rw-r--r--vncviewer/Viewport.cxx41
1 files changed, 41 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;
}