diff --git a/ChangeLog b/ChangeLog index 69084b7d2..f1318c2b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ Bug fixes: - #7036 Fix tray icon not changing theme on Big Sur - #7046 Fix MacOS 10.13 build - #7049 Scroll doesn't work in case of macOS is server +- #7057 Fix copy paste logic, when OS reported about clipboard update too late - #7055 Add secure input notification on Linux - #7052 Add secure input notification on Windows - #7047 Fix prevent sleep option on Mac and Windows diff --git a/src/lib/platform/MSWindowsClipboard.cpp b/src/lib/platform/MSWindowsClipboard.cpp index 5a807a0cb..1764b8764 100644 --- a/src/lib/platform/MSWindowsClipboard.cpp +++ b/src/lib/platform/MSWindowsClipboard.cpp @@ -100,8 +100,7 @@ MSWindowsClipboard::empty() void MSWindowsClipboard::add(EFormat format, const String& data) { - LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format)); - + bool isSucceeded = false; // convert data to win32 form for (ConverterList::const_iterator index = m_converters.begin(); index != m_converters.end(); ++index) { @@ -111,11 +110,20 @@ MSWindowsClipboard::add(EFormat format, const String& data) if (converter->getFormat() == format) { HANDLE win32Data = converter->fromIClipboard(data); if (win32Data != NULL) { - UINT win32Format = converter->getWin32Format(); - m_facade->write(win32Data, win32Format); + LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format)); + m_facade->write(win32Data, converter->getWin32Format()); + isSucceeded = true; + break; + } + else { + LOG((CLOG_DEBUG "failed to convert clipboard data to platform format")); } } } + + if(!isSucceeded){ + LOG((CLOG_DEBUG "missed clipboard data convert for format: %d", format)); + } } bool diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index e56b83253..7ed4bfd80 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -1302,6 +1302,13 @@ Server::handleClipboardGrabbed(const Event& event, void* vclient) client->grabClipboard(info->m_id); } } + + if (m_active != m_primaryClient) { + LOG((CLOG_INFO "clipboard grabbed, but we are already changed active screen. Resend clipboard data")); + for (ClipboardID id = 0; id < kClipboardEnd; ++id) { + onClipboardChanged(m_primaryClient, id, m_clipboards[id].m_clipboardSeqNum); + } + } } void @@ -1570,7 +1577,6 @@ Server::onClipboardChanged(BaseClientProxy* sender, // get data sender->getClipboard(id, &clipboard.m_clipboard); - // ignore if data hasn't changed String data = clipboard.m_clipboard.marshall(); if (data.size() > m_maximumClipboardSize * 1024) { LOG((CLOG_NOTE "not updating clipboard because it's over the size limit (%i KB) configured by the server", @@ -1578,6 +1584,7 @@ Server::onClipboardChanged(BaseClientProxy* sender, return; } + // ignore if data hasn't changed if (data == clipboard.m_clipboardData) { LOG((CLOG_DEBUG "ignored screen \"%s\" update of clipboard %d (unchanged)", clipboard.m_clipboardOwner.c_str(), id)); return;