[feat] add web clipboard synchronization, refs #132

This commit is contained in:
dijunkun
2026-10-29 23:17:06 +08:00
parent 38a01b085a
commit 0f0dde8b49
7 changed files with 285 additions and 8 deletions
@@ -220,6 +220,7 @@ void GuiRuntime::HandleServerControllerDisconnected(
std::memory_order_relaxed);
#endif
}
clipboard_.ForgetWeb(remote_id);
if (has_connected_controller) {
remote_client_id_ = remaining_controller_id;
return;
@@ -14,6 +14,7 @@
#include <vector>
#include <display_stream_id.h>
#include <web_clipboard_protocol.h>
#include "localization.h"
#include "platform/video_renderer.h"
#include "rd_log.h"
@@ -308,6 +309,8 @@ int GuiRuntime::CreateConnectionPeer() {
AddDataStream(peer_, file_label_.c_str(), true);
AddDataStream(peer_, file_feedback_label_.c_str(), true);
AddDataStream(peer_, clipboard_label_.c_str(), true);
if (!unattended_host_)
AddDataStream(peer_, web_clipboard::kStream, true);
return 0;
} else {
return -1;
@@ -25,6 +25,7 @@
#include "platform.h"
#include "rd_log.h"
#include "runtime/gui_runtime.h"
#include "web_clipboard_protocol.h"
#ifdef __OHOS__
#include "platform/harmony/input/system_shortcuts.h"
#endif
@@ -137,8 +138,14 @@ void PeerEventHandler::OnReceiveDataBuffer(
if (runtime->unattended_host_ &&
(source_id == runtime->file_label_ ||
source_id == runtime->file_feedback_label_ ||
source_id == runtime->clipboard_label_))
source_id == runtime->clipboard_label_ ||
source_id == web_clipboard::kStream))
return;
if (source_id == web_clipboard::kStream) {
runtime->clipboard_.ReceiveWeb(
data, size, handler->ConnectionKey(user_id, user_id_size), handler);
return;
}
if (source_id == runtime->file_label_) {
runtime->transfers_.Receive(data, size, handler,
handler->ConnectionKey(user_id, user_id_size));