Clean up internal clipboard handling
We now filter incoming data, which means we can start assuming the
clipboard data is always null terminated. This allows us to clean
up a lot of the internal handling.
diff --git a/win/rfb_win32/Clipboard.cxx b/win/rfb_win32/Clipboard.cxx
index fca6c1d..4952695 100644
--- a/win/rfb_win32/Clipboard.cxx
+++ b/win/rfb_win32/Clipboard.cxx
@@ -113,11 +113,11 @@
// Notify clients
if (notifier) {
if (!clipdata) {
- notifier->notifyClipboardChanged(0, 0);
+ notifier->notifyClipboardChanged(0);
} else {
CharArray unix_text(convertLF(clipdata, strlen(clipdata)));
removeNonISOLatin1Chars(unix_text.buf);
- notifier->notifyClipboardChanged(unix_text.buf, strlen(unix_text.buf));
+ notifier->notifyClipboardChanged(unix_text.buf);
}
} else {
vlog.debug("no clipboard notifier registered");
diff --git a/win/rfb_win32/Clipboard.h b/win/rfb_win32/Clipboard.h
index 3da7bfc..c69e981 100644
--- a/win/rfb_win32/Clipboard.h
+++ b/win/rfb_win32/Clipboard.h
@@ -1,4 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright 2016-2019 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,7 +39,7 @@
// -=- Abstract base class for callback recipients
class Notifier {
public:
- virtual void notifyClipboardChanged(const char* text, int len) = 0;
+ virtual void notifyClipboardChanged(const char* text) = 0;
virtual ~Notifier() {};
};
diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx
index 2cedc4a..2c91e3f 100644
--- a/win/rfb_win32/SDisplay.cxx
+++ b/win/rfb_win32/SDisplay.cxx
@@ -1,4 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright 2011-2019 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -328,19 +329,16 @@
return false;
}
-void SDisplay::clientCutText(const char* text, int len) {
- CharArray clip_sz(len+1);
- memcpy(clip_sz.buf, text, len);
- clip_sz.buf[len] = 0;
- clipboard->setClipText(clip_sz.buf);
+void SDisplay::clientCutText(const char* text) {
+ clipboard->setClipText(text);
}
void
-SDisplay::notifyClipboardChanged(const char* text, int len) {
+SDisplay::notifyClipboardChanged(const char* text) {
vlog.debug("clipboard text changed");
if (server)
- server->serverCutText(text, len);
+ server->serverCutText(text);
}
diff --git a/win/rfb_win32/SDisplay.h b/win/rfb_win32/SDisplay.h
index 6dbfabb..1773b78 100644
--- a/win/rfb_win32/SDisplay.h
+++ b/win/rfb_win32/SDisplay.h
@@ -1,4 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright 2011-2019 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -77,11 +78,11 @@
const char* userName);
virtual void pointerEvent(const Point& pos, int buttonmask);
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
- virtual void clientCutText(const char* str, int len);
+ virtual void clientCutText(const char* str);
// -=- Clipboard
- virtual void notifyClipboardChanged(const char* text, int len);
+ virtual void notifyClipboardChanged(const char* text);
// -=- Display events