diff options
author | Pierre Ossman <ossman@cendio.se> | 2011-05-19 14:49:18 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2011-05-19 14:49:18 +0000 |
commit | 4a6be4a2a0ebba32133c09c92b0ef84050d2f96f (patch) | |
tree | 8655c9f2eea976a203956e2a8eb54a1c8090808b /vncviewer/Viewport.cxx | |
parent | 6a9e2e63415b3e8ed473686968cd7b28274879e0 (diff) | |
download | tigervnc-4a6be4a2a0ebba32133c09c92b0ef84050d2f96f.tar.gz tigervnc-4a6be4a2a0ebba32133c09c92b0ef84050d2f96f.zip |
Implement support for sending the local clipboard to the server.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4432 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer/Viewport.cxx')
-rw-r--r-- | vncviewer/Viewport.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 3e829905..acbf36cb 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -66,6 +66,11 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_) set_simple_keyboard(); #endif +// FLTK STR #2636 gives us the ability to monitor clipboard changes +#ifdef HAVE_FLTK_CLIPBOARD + Fl::add_clipboard_notify(handleClipboardChange, this); +#endif + frameBuffer = new ManagedPixelBuffer(getPreferredPF(), w, h); assert(frameBuffer); @@ -84,6 +89,10 @@ Viewport::~Viewport() Fl::remove_timeout(handleColourMap, this); Fl::remove_timeout(handlePointerTimeout, this); +#ifdef HAVE_FLTK_CLIPBOARD + Fl::remove_clipboard_notify(handleClipboardChange); +#endif + delete frameBuffer; if (pixelTrans) @@ -172,10 +181,22 @@ void Viewport::draw() int Viewport::handle(int event) { + char buffer[1024]; + int ret; int buttonMask, wheelMask; DownMap::const_iterator iter; switch (event) { + case FL_PASTE: + // This is documented as to ASCII, but actually does to 8859-1 + ret = fl_utf8toa(Fl::event_text(), Fl::event_length(), buffer, sizeof(buffer)); + if (ret >= sizeof(buffer)) { + vlog.error(_("Clipboard buffer overflow!")); + return 1; + } + vlog.debug("Sending clipboard data: '%s'", buffer); + cc->writer()->clientCutText(buffer, ret); + return 1; case FL_ENTER: // Yes, we would like some pointer events please! return 1; @@ -260,6 +281,19 @@ void Viewport::handleColourMap(void *data) } +void Viewport::handleClipboardChange(int source, void *data) +{ + Viewport *self = (Viewport *)data; + + assert(self); + + if (!sendPrimary && (source == 0)) + return; + + Fl::paste(*self, source); +} + + void Viewport::handlePointerEvent(const rfb::Point& pos, int buttonMask) { if (!viewOnly) { |