Browse Source

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
tags/v1.1.90
Pierre Ossman 13 years ago
parent
commit
4a6be4a2a0
4 changed files with 48 additions and 1 deletions
  1. 11
    1
      CMakeLists.txt
  2. 1
    0
      config.h.cmake.in
  3. 34
    0
      vncviewer/Viewport.cxx
  4. 2
    0
      vncviewer/Viewport.h

+ 11
- 1
CMakeLists.txt View File

@@ -177,10 +177,20 @@ if(BUILD_NEW_VNCVIEWER)
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()

+ 1
- 0
config.h.cmake.in View File

@@ -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 */

+ 34
- 0
vncviewer/Viewport.cxx View File

@@ -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) {

+ 2
- 0
vncviewer/Viewport.h View File

@@ -93,6 +93,8 @@ private:
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);


Loading…
Cancel
Save