diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index a309cf9e..a99d3695 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -79,7 +79,8 @@ Client::Client( m_writeToDropDirThread(NULL), m_socket(NULL), m_useSecureNetwork(false), - m_args(args) + m_args(args), + m_sendClipboardThread(NULL) { assert(m_socketFactory != NULL); assert(m_screen != NULL); @@ -265,12 +266,11 @@ Client::leave() m_active = false; - // send clipboards that we own and that have changed - for (ClipboardID id = 0; id < kClipboardEnd; ++id) { - if (m_ownClipboard[id]) { - sendClipboard(id); - } - } + m_sendClipboardThread = new Thread( + new TMethodJob( + this, + &Client::sendClipboardThread, + NULL)); return true; } @@ -750,6 +750,17 @@ Client::onFileRecieveCompleted() } } +void +Client::sendClipboardThread(void*) +{ + // send clipboards that we own and that have changed + for (ClipboardID id = 0; id < kClipboardEnd; ++id) { + if (m_ownClipboard[id]) { + sendClipboard(id); + } + } +} + void Client::handleStopRetry(const Event&, void*) { diff --git a/src/lib/client/Client.h b/src/lib/client/Client.h index 62bc2473..7ab25738 100644 --- a/src/lib/client/Client.h +++ b/src/lib/client/Client.h @@ -194,6 +194,7 @@ private: void handleFileRecieveCompleted(const Event&, void*); void handleStopRetry(const Event&, void*); void onFileRecieveCompleted(); + void sendClipboardThread(void*); public: bool m_mock; @@ -224,4 +225,5 @@ private: TCPSocket* m_socket; bool m_useSecureNetwork; ClientArgs& m_args; + Thread* m_sendClipboardThread; }; diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 60f75e66..44f68de5 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -92,7 +92,8 @@ Server::Server( m_ignoreFileTransfer(false), m_enableDragDrop(enableDragDrop), m_getDragInfoThread(NULL), - m_waitDragInfoThread(true) + m_waitDragInfoThread(true), + m_sendClipboardThread(NULL) { // must have a primary client and it must have a canonical name assert(m_primaryClient != NULL); @@ -505,6 +506,13 @@ Server::switchScreen(BaseClientProxy* dst, m_primaryClient->getToggleMask(), forScreensaver); + // send the clipboard data to new active screen + m_sendClipboardThread = new Thread( + new TMethodJob( + this, + &Server::sendClipboardThread, + NULL)); + Server::SwitchToScreenInfo* info = Server::SwitchToScreenInfo::alloc(m_active->getName()); m_events->addEvent(Event(m_events->forServer().screenSwitched(), this, info)); diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 02b9cd47..631ca762 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -484,5 +484,5 @@ private: ClientListener* m_clientListener; - Thread* m_dataTransmissionThread; + Thread* m_sendClipboardThread; };