#ifdef WIN32
altGrArmed(false),
#endif
+ pendingServerCutText(NULL), pendingClientCutText(NULL),
menuCtrlKey(false), menuAltKey(false), cursor(NULL)
{
#if !defined(WIN32) && !defined(__APPLE__)
delete cursor;
}
+ clearPendingClipboard();
+
// FLTK automatically deletes all child widgets, so we shouldn't touch
// them ourselves here
}
char *buffer;
int size, ret;
+ clearPendingClipboard();
+
if (!acceptClipboard)
return;
vlog.debug("Got clipboard data (%d bytes)", (int)strlen(buffer));
+ if (!hasFocus()) {
+ pendingServerCutText = buffer;
+ return;
+ }
+
// RFB doesn't have separate selection and clipboard concepts, so we
// dump the data into both variants.
if (setPrimary)
case FL_PASTE:
buffer = new char[Fl::event_length() + 1];
+ clearPendingClipboard();
+
// This is documented as to ASCII, but actually does to 8859-1
ret = fl_utf8toa(Fl::event_text(), Fl::event_length(), buffer,
Fl::event_length() + 1);
assert(ret < (Fl::event_length() + 1));
+ if (!hasFocus()) {
+ pendingClientCutText = buffer;
+ return 1;
+ }
+
vlog.debug("Sending clipboard data (%d bytes)", (int)strlen(buffer));
try {
Fl::disable_im();
try {
+ flushPendingClipboard();
+
// We may have gotten our lock keys out of sync with the server
// whilst we didn't have focus. Try to sort this out.
pushLEDState();
}
+void Viewport::clearPendingClipboard()
+{
+ delete [] pendingServerCutText;
+ pendingServerCutText = NULL;
+ delete [] pendingClientCutText;
+ pendingClientCutText = NULL;
+}
+
+
+void Viewport::flushPendingClipboard()
+{
+ if (pendingServerCutText) {
+ size_t len = strlen(pendingServerCutText);
+ if (setPrimary)
+ Fl::copy(pendingServerCutText, len, 0);
+ Fl::copy(pendingServerCutText, len, 1);
+ }
+ if (pendingClientCutText) {
+ size_t len = strlen(pendingClientCutText);
+ vlog.debug("Sending pending clipboard data (%d bytes)", (int)len);
+ cc->writer()->clientCutText(pendingClientCutText, len);
+ }
+
+ clearPendingClipboard();
+}
+
+
void Viewport::handlePointerEvent(const rfb::Point& pos, int buttonMask)
{
if (!viewOnly) {
static void handleClipboardChange(int source, void *data);
+ void clearPendingClipboard();
+ void flushPendingClipboard();
+
void handlePointerEvent(const rfb::Point& pos, int buttonMask);
static void handlePointerTimeout(void *data);
unsigned int altGrCtrlTime;
#endif
+ const char* pendingServerCutText;
+ const char* pendingClientCutText;
+
rdr::U32 menuKeySym;
int menuKeyCode, menuKeyFLTK;
Fl_Menu_Button *contextMenu;