Add xhandler hook

Boiler plate code to intercept system events from FLTK so that
we can generate proper keyboard messages.
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 16b34e6..2b22a97 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -100,6 +100,11 @@
   Fl::add_clipboard_notify(handleClipboardChange, this);
 #endif
 
+#ifdef HAVE_FLTK_XHANDLERS
+  // We need to intercept keyboard events early
+  Fl::add_xhandler(handleXEvent, this);
+#endif
+
   frameBuffer = createFramebuffer(w, h);
   assert(frameBuffer);
 
@@ -132,6 +137,10 @@
   // again later when this object is already gone.
   Fl::remove_timeout(handlePointerTimeout, this);
 
+#ifdef HAVE_FLTK_XHANDLERS
+  Fl::remove_xhandler(handleXEvent);
+#endif
+
 #ifdef HAVE_FLTK_CLIPBOARD
   Fl::remove_clipboard_notify(handleClipboardChange);
 #endif
@@ -620,6 +629,28 @@
 }
 
 
+bool Viewport::handleXEvent(void *event, void *data)
+{
+  Viewport *self = (Viewport *)data;
+  Fl_Widget *focus;
+
+  assert(self);
+
+  focus = Fl::grab();
+  if (!focus)
+    focus = Fl::focus();
+  if (!focus)
+    return false;
+
+  if (focus != self)
+    return false;
+
+  assert(event);
+
+  return false;
+}
+
+
 rdr::U32 Viewport::translateKeyEvent(void)
 {
   unsigned ucs;
diff --git a/vncviewer/Viewport.h b/vncviewer/Viewport.h
index d9eea35..30dacad 100644
--- a/vncviewer/Viewport.h
+++ b/vncviewer/Viewport.h
@@ -73,6 +73,8 @@
   void handleKeyPress(int keyCode, rdr::U32 keySym);
   void handleKeyRelease(int keyCode);
 
+  static bool handleXEvent(void *event, void *data);
+
   rdr::U32 translateKeyEvent(void);
   void handleFLTKKeyPress(void);