summaryrefslogtreecommitdiffstats
path: root/vncviewer/Viewport.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-07-21 16:48:43 +0200
committerPierre Ossman <ossman@cendio.se>2014-08-22 15:10:28 +0200
commit6b743d0c1bf1fe9e11b0ac2cb51ede39fda87362 (patch)
treef62272eefc30a071e786ffaf0ad0e485d089e6ef /vncviewer/Viewport.cxx
parent2e9684f12b106a1304121ca22aef5df0688e1bbf (diff)
downloadtigervnc-6b743d0c1bf1fe9e11b0ac2cb51ede39fda87362.tar.gz
tigervnc-6b743d0c1bf1fe9e11b0ac2cb51ede39fda87362.zip
Add OS X keyboard handler
Diffstat (limited to 'vncviewer/Viewport.cxx')
-rw-r--r--vncviewer/Viewport.cxx35
1 files changed, 34 insertions, 1 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index e183939d..027ca54c 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -77,10 +77,15 @@
#include <FL/Fl_Menu.H>
#include <FL/Fl_Menu_Button.H>
+#ifdef __APPLE__
+#include "cocoa.h"
+#endif
+
#ifdef WIN32
#include "win32.h"
#endif
+
using namespace rfb;
using namespace rdr;
@@ -708,7 +713,35 @@ bool Viewport::handleXEvent(void *event, void *data)
return true;
}
-#elif !defined(__APPLE__)
+#elif defined(__APPLE__)
+ if (cocoa_is_keyboard_event(event)) {
+ int keyCode;
+
+ keyCode = cocoa_event_keycode(event);
+
+ if (cocoa_is_key_press(event)) {
+ rdr::U32 keySym;
+
+ keySym = cocoa_event_keysym(event);
+ if (keySym == NoSymbol) {
+ vlog.error(_("No symbol for key code 0x%02x (in the current state)"),
+ (int)keyCode);
+ return true;
+ }
+
+ self->handleKeyPress(keyCode, keySym);
+
+ // We don't get any release events for CapsLock, so we have to
+ // send the release right away.
+ if (keySym == XK_Caps_Lock)
+ self->handleKeyRelease(keyCode);
+ } else {
+ self->handleKeyRelease(keyCode);
+ }
+
+ return true;
+ }
+#else
XEvent *xevent = (XEvent*)event;
if (xevent->type == KeyPress) {