void Client::sendClipboardThread(void * data) { Stopwatch timer(false); Clipboard clipboard[kClipboardEnd]; // fill clipboards that we own and that have changed for (ClipboardID id = 0; id < kClipboardEnd; ++id) { if (m_ownClipboard[id]) { fillClipboard(id, &clipboard[id]); } } LOG((CLOG_DEBUG1 "fill took %fs, signaling", (double) timer.getTime())); // signal that fill is done m_mutex->lock(); m_condData = true; m_condVar->signal(); m_mutex->unlock(); // send clipboards that we own and that have changed for (ClipboardID id = 0; id < kClipboardEnd; ++id) { if (m_ownClipboard[id]) { sendClipboard(id, &clipboard[id]); } } m_sendClipboardThread = NULL; LOG((CLOG_DEBUG1 "send took %fs", (double) timer.getTime())); }
bool CClient::leave() { m_screen->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); } } return true; }
void CClient::handleClipboardGrabbed(const CEvent& event, void*) { const IScreen::CClipboardInfo* info = reinterpret_cast<const IScreen::CClipboardInfo*>(event.getData()); // grab ownership m_server->onGrabClipboard(info->m_id); // we now own the clipboard and it has not been sent to the server m_ownClipboard[info->m_id] = true; m_sentClipboard[info->m_id] = false; m_timeClipboard[info->m_id] = 0; // if we're not the active screen then send the clipboard now, // otherwise we'll wait until we leave. if (!m_active) { sendClipboard(info->m_id); } }