Sent clipboard on a thread #4601

This commit is contained in:
Xinyu Hou 2015-05-20 19:53:30 +01:00
parent 49ac320f97
commit cf5347c8f6
4 changed files with 30 additions and 9 deletions

View File

@ -79,7 +79,8 @@ Client::Client(
m_writeToDropDirThread(NULL), m_writeToDropDirThread(NULL),
m_socket(NULL), m_socket(NULL),
m_useSecureNetwork(false), m_useSecureNetwork(false),
m_args(args) m_args(args),
m_sendClipboardThread(NULL)
{ {
assert(m_socketFactory != NULL); assert(m_socketFactory != NULL);
assert(m_screen != NULL); assert(m_screen != NULL);
@ -265,12 +266,11 @@ Client::leave()
m_active = false; m_active = false;
// send clipboards that we own and that have changed m_sendClipboardThread = new Thread(
for (ClipboardID id = 0; id < kClipboardEnd; ++id) { new TMethodJob<Client>(
if (m_ownClipboard[id]) { this,
sendClipboard(id); &Client::sendClipboardThread,
} NULL));
}
return true; 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 void
Client::handleStopRetry(const Event&, void*) Client::handleStopRetry(const Event&, void*)
{ {

View File

@ -194,6 +194,7 @@ private:
void handleFileRecieveCompleted(const Event&, void*); void handleFileRecieveCompleted(const Event&, void*);
void handleStopRetry(const Event&, void*); void handleStopRetry(const Event&, void*);
void onFileRecieveCompleted(); void onFileRecieveCompleted();
void sendClipboardThread(void*);
public: public:
bool m_mock; bool m_mock;
@ -224,4 +225,5 @@ private:
TCPSocket* m_socket; TCPSocket* m_socket;
bool m_useSecureNetwork; bool m_useSecureNetwork;
ClientArgs& m_args; ClientArgs& m_args;
Thread* m_sendClipboardThread;
}; };

View File

@ -92,7 +92,8 @@ Server::Server(
m_ignoreFileTransfer(false), m_ignoreFileTransfer(false),
m_enableDragDrop(enableDragDrop), m_enableDragDrop(enableDragDrop),
m_getDragInfoThread(NULL), m_getDragInfoThread(NULL),
m_waitDragInfoThread(true) m_waitDragInfoThread(true),
m_sendClipboardThread(NULL)
{ {
// must have a primary client and it must have a canonical name // must have a primary client and it must have a canonical name
assert(m_primaryClient != NULL); assert(m_primaryClient != NULL);
@ -505,6 +506,13 @@ Server::switchScreen(BaseClientProxy* dst,
m_primaryClient->getToggleMask(), m_primaryClient->getToggleMask(),
forScreensaver); forScreensaver);
// send the clipboard data to new active screen
m_sendClipboardThread = new Thread(
new TMethodJob<Server>(
this,
&Server::sendClipboardThread,
NULL));
Server::SwitchToScreenInfo* info = Server::SwitchToScreenInfo* info =
Server::SwitchToScreenInfo::alloc(m_active->getName()); Server::SwitchToScreenInfo::alloc(m_active->getName());
m_events->addEvent(Event(m_events->forServer().screenSwitched(), this, info)); m_events->addEvent(Event(m_events->forServer().screenSwitched(), this, info));

View File

@ -484,5 +484,5 @@ private:
ClientListener* m_clientListener; ClientListener* m_clientListener;
Thread* m_dataTransmissionThread; Thread* m_sendClipboardThread;
}; };