diff options
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/Viewport.cxx | 31 | ||||
-rw-r--r-- | vncviewer/Viewport.h | 2 |
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); |