summaryrefslogtreecommitdiffstats
path: root/vncviewer
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-08-22 15:10:22 +0200
committerPierre Ossman <ossman@cendio.se>2014-08-22 15:10:22 +0200
commit4f3ac69a11b98aa7eea88a6336140bced4c66eae (patch)
tree195546fd1a02c65b86bf03c2d0b25e51552a767a /vncviewer
parent796580af8791db18cf95f32784c0270085f0b361 (diff)
downloadtigervnc-4f3ac69a11b98aa7eea88a6336140bced4c66eae.tar.gz
tigervnc-4f3ac69a11b98aa7eea88a6336140bced4c66eae.zip
Add xhandler hook
Boiler plate code to intercept system events from FLTK so that we can generate proper keyboard messages.
Diffstat (limited to 'vncviewer')
-rw-r--r--vncviewer/Viewport.cxx31
-rw-r--r--vncviewer/Viewport.h2
2 files changed, 33 insertions, 0 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 16b34e6c..2b22a973 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -100,6 +100,11 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_)
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 @@ Viewport::~Viewport()
// 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 @@ void Viewport::handleKeyRelease(int keyCode)
}
+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 d9eea353..30dacad4 100644
--- a/vncviewer/Viewport.h
+++ b/vncviewer/Viewport.h
@@ -73,6 +73,8 @@ private:
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);