Revision: 4432
http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4432&view=rev
Author: ossman_
Date: 2011-05-19 14:49:18 +0000 (Thu, 19 May 2011)
Log Message:
-----------
Implement support for sending the local clipboard to the server.
Modified Paths:
--------------
trunk/CMakeLists.txt
trunk/config.h.cmake.in
trunk/vncviewer/Viewport.cxx
trunk/vncviewer/Viewport.h
Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt 2011-05-19 14:47:43 UTC (rev 4431)
+++ trunk/CMakeLists.txt 2011-05-19 14:49:18 UTC (rev 4432)
@@ -177,10 +177,20 @@
set(FLTK_SKIP_OPENGL TRUE)
find_package(FLTK COMPONENTS REQUIRED)
- # FLTK STR #2599
+ # No proper handling for extra X11 libs that FLTK might need...
+ if(X11_Xfixes_FOUND)
+ set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xfixes_LIB})
+ endif()
+
set(CMAKE_REQUIRED_INCLUDES ${FLTK_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${FLTK_LIBRARIES})
+
+ # FLTK STR #2599
check_cxx_source_compiles("#include <FL/Fl_Widget.H>\nint main(int c, char**
v) { void *foo = (void*)&Fl_Widget::set_simple_keyboard; return 0; }"
HAVE_FLTK_DEAD_KEYS)
+
+ # FLTK STR #2636
+ check_cxx_source_compiles("#include <FL/Fl.H>\nint main(int c, char** v) {
Fl::add_clipboard_notify(NULL, NULL); return 0; }" HAVE_FLTK_CLIPBOARD)
+
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
endif()
Modified: trunk/config.h.cmake.in
===================================================================
--- trunk/config.h.cmake.in 2011-05-19 14:47:43 UTC (rev 4431)
+++ trunk/config.h.cmake.in 2011-05-19 14:49:18 UTC (rev 4432)
@@ -12,6 +12,7 @@
#cmakedefine HAVE_GNUTLS_PK_ALGORITHM_T
#cmakedefine HAVE_GNUTLS_SIGN_ALGORITHM_T
#cmakedefine HAVE_FLTK_DEAD_KEYS
+#cmakedefine HAVE_FLTK_CLIPBOARD
#cmakedefine ENABLE_NLS 1
/* MS Visual Studio 2008 and newer doesn't know ssize_t */
Modified: trunk/vncviewer/Viewport.cxx
===================================================================
--- trunk/vncviewer/Viewport.cxx 2011-05-19 14:47:43 UTC (rev 4431)
+++ trunk/vncviewer/Viewport.cxx 2011-05-19 14:49:18 UTC (rev 4432)
@@ -66,6 +66,11 @@
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 @@
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 @@
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::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) {
Modified: trunk/vncviewer/Viewport.h
===================================================================
--- trunk/vncviewer/Viewport.h 2011-05-19 14:47:43 UTC (rev 4431)
+++ trunk/vncviewer/Viewport.h 2011-05-19 14:49:18 UTC (rev 4432)
@@ -93,6 +93,8 @@
static void handleUpdateTimeout(void *data);
static void handleColourMap(void *data);
+ static void handleClipboardChange(int source, void *data);
+
void handlePointerEvent(const rfb::Point& pos, int buttonMask);
static void handlePointerTimeout(void *data);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Tigervnc-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits