From 8c64cbf54e3bbd647f654a590d980950eb23ee35 Mon Sep 17 00:00:00 2001 From: "Jerry (Xinyu Hou)" Date: Thu, 4 Jun 2015 10:04:08 -0700 Subject: [PATCH] Refactored send drag info on server #4584 --- src/lib/server/Server.cpp | 38 ++++++++++++++++++-------------------- src/lib/server/Server.h | 6 +++--- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index c3effe71..d77e7a2c 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -91,7 +91,7 @@ Server::Server( m_writeToDropDirThread(NULL), m_ignoreFileTransfer(false), m_enableDragDrop(enableDragDrop), - m_getDragInfoThread(NULL), + m_sendDragInfoThread(NULL), m_waitDragInfoThread(true), m_sendClipboardThread(NULL) { @@ -1788,37 +1788,30 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y) && m_screen->isDraggingStarted() && m_active != newScreen && m_waitDragInfoThread) { - if (m_getDragInfoThread == NULL) { - m_getDragInfoThread = new Thread( + if (m_sendDragInfoThread == NULL) { + m_sendDragInfoThread = new Thread( new TMethodJob( this, - &Server::getDragInfoThread)); + &Server::sendDragInfoThread, newScreen)); } + return false; } - if (m_getDragInfoThread == NULL) { - // switch screen - switchScreen(newScreen, x, y, false); - - // send drag file info to client if there is any - if (m_dragFileList.size() > 0) { - sendDragInfo(newScreen); - m_dragFileList.clear(); - } - - m_waitDragInfoThread = true; - - return true; - } + // switch screen + switchScreen(newScreen, x, y, false); + m_waitDragInfoThread = true; + return true; } return false; } void -Server::getDragInfoThread(void*) +Server::sendDragInfoThread(void* arg) { + BaseClientProxy* newScreen = reinterpret_cast(arg); + m_dragFileList.clear(); String& dragFileList = m_screen->getDraggingFilename(); if (!dragFileList.empty()) { @@ -1835,8 +1828,13 @@ Server::getDragInfoThread(void*) m_ignoreFileTransfer = true; #endif + // send drag file info to client if there is any + if (m_dragFileList.size() > 0) { + sendDragInfo(newScreen); + m_dragFileList.clear(); + } m_waitDragInfoThread = false; - m_getDragInfoThread = NULL; + m_sendDragInfoThread = NULL; } void diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 349b7bb3..8e3fee05 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -361,8 +361,8 @@ private: // thread function for writing file to drop directory void writeToDropDirThread(void*); - // thread function for getting drag filename - void getDragInfoThread(void*); + // thread function for sending drag information + void sendDragInfoThread(void*); // send drag info to new client screen void sendDragInfo(BaseClientProxy* newScreen); @@ -477,7 +477,7 @@ private: bool m_ignoreFileTransfer; bool m_enableDragDrop; - Thread* m_getDragInfoThread; + Thread* m_sendDragInfoThread; bool m_waitDragInfoThread; ClientListener* m_clientListener;