From 42952d3d9ee32edf31b8b14701e40397d8e278d0 Mon Sep 17 00:00:00 2001 From: zhangtingan Date: Sat, 22 Aug 2026 01:23:29 +0800 Subject: [PATCH] fix: push clipboard data to remote clients on primary screen grab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the primary screen (server side) grabs the clipboard, handleClipboardGrabbed only marked ownership and notified other screens to grab — it never read or sent the actual clipboard data. Real data was only transferred during screen switches (switchScreen/onClipboardChanged), so if the user copied text on the server side without moving the mouse to a client screen, remote clients never received the clipboard content. Fix: in handleClipboardGrabbed, when the grabber is the primary client, read the clipboard data via getClipboard and push it to all non-grabber clients via setClipboard. This mirrors the client-side pattern in Client::handleClipboardGrabbed which sends clipboard data immediately when not active. Log: PMS Bug 341993 — 协同后复制文本接收端剪贴板未显示 --- 3rdparty/barrier/src/lib/server/Server.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/3rdparty/barrier/src/lib/server/Server.cpp b/3rdparty/barrier/src/lib/server/Server.cpp index a169db165..f1ca58dd7 100644 --- a/3rdparty/barrier/src/lib/server/Server.cpp +++ b/3rdparty/barrier/src/lib/server/Server.cpp @@ -1265,6 +1265,25 @@ Server::handleClipboardGrabbed(const Event& event, void* vclient) client->grabClipboard(info->m_id); } } + + // if the primary screen grabbed the clipboard (i.e. the user copied + // on the server side), read the actual clipboard data now and push + // it to all other clients. without this the data would only be + // transferred when the mouse crosses the screen boundary (via + // switchScreen), leaving remote clients without clipboard content + // when the user never moves the mouse off the primary screen. + if (grabber == m_primaryClient) { + if (grabber->getClipboard(info->m_id, &clipboard.m_clipboard)) { + clipboard.m_clipboardData = clipboard.m_clipboard.marshall(); + for (ClientList::iterator index = m_clients.begin(); + index != m_clients.end(); ++index) { + BaseClientProxy* client = index->second; + if (client != grabber) { + client->setClipboard(info->m_id, &clipboard.m_clipboard); + } + } + } + } } void