mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-03-22 07:37:29 +08:00
[fix] disable clipboard sharing when not in control mode
This commit is contained in:
@@ -1546,7 +1546,8 @@ void Render::InitializeModules() {
|
|||||||
std::shared_lock lock(client_properties_mutex_);
|
std::shared_lock lock(client_properties_mutex_);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
for (const auto& [remote_id, props] : client_properties_) {
|
for (const auto& [remote_id, props] : client_properties_) {
|
||||||
if (props && props->peer_ && props->connection_established_) {
|
if (props && props->peer_ && props->connection_established_ &&
|
||||||
|
props->enable_mouse_control_) {
|
||||||
ret = SendReliableDataFrame(props->peer_, data, size,
|
ret = SendReliableDataFrame(props->peer_, data, size,
|
||||||
props->clipboard_label_.c_str());
|
props->clipboard_label_.c_str());
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class Render {
|
|||||||
bool connection_established_ = false;
|
bool connection_established_ = false;
|
||||||
bool rejoin_ = false;
|
bool rejoin_ = false;
|
||||||
bool net_traffic_stats_button_pressed_ = false;
|
bool net_traffic_stats_button_pressed_ = false;
|
||||||
bool mouse_control_button_pressed_ = true;
|
bool enable_mouse_control_ = true;
|
||||||
bool mouse_controller_is_started_ = false;
|
bool mouse_controller_is_started_ = false;
|
||||||
bool audio_capture_button_pressed_ = true;
|
bool audio_capture_button_pressed_ = true;
|
||||||
bool control_mouse_ = true;
|
bool control_mouse_ = true;
|
||||||
|
|||||||
@@ -395,6 +395,13 @@ void Render::OnReceiveDataBufferCb(const char* data, size_t size,
|
|||||||
return;
|
return;
|
||||||
} else if (source_id == render->clipboard_label_) {
|
} else if (source_id == render->clipboard_label_) {
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
|
std::string remote_user_id(user_id, user_id_size);
|
||||||
|
auto props =
|
||||||
|
render->GetSubStreamWindowPropertiesByRemoteId(remote_user_id);
|
||||||
|
if (props && !props->enable_mouse_control_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::string clipboard_text(data, size);
|
std::string clipboard_text(data, size);
|
||||||
if (!Clipboard::SetText(clipboard_text)) {
|
if (!Clipboard::SetText(clipboard_text)) {
|
||||||
LOG_ERROR("Failed to set clipboard content from remote");
|
LOG_ERROR("Failed to set clipboard content from remote");
|
||||||
@@ -764,7 +771,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char* user_id,
|
|||||||
case ConnectionStatus::Failed:
|
case ConnectionStatus::Failed:
|
||||||
case ConnectionStatus::Closed: {
|
case ConnectionStatus::Closed: {
|
||||||
props->connection_established_ = false;
|
props->connection_established_ = false;
|
||||||
props->mouse_control_button_pressed_ = false;
|
props->enable_mouse_control_ = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(props->video_frame_mutex_);
|
std::lock_guard<std::mutex> lock(props->video_frame_mutex_);
|
||||||
|
|||||||
@@ -198,24 +198,21 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
float mouse_y = ImGui::GetCursorScreenPos().y;
|
float mouse_y = ImGui::GetCursorScreenPos().y;
|
||||||
float disable_mouse_x = mouse_x + line_padding;
|
float disable_mouse_x = mouse_x + line_padding;
|
||||||
float disable_mouse_y = mouse_y + line_padding;
|
float disable_mouse_y = mouse_y + line_padding;
|
||||||
std::string mouse = props->mouse_control_button_pressed_
|
std::string mouse = ICON_FA_COMPUTER_MOUSE;
|
||||||
? ICON_FA_COMPUTER_MOUSE
|
|
||||||
: ICON_FA_COMPUTER_MOUSE;
|
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
if (ImGui::Button(mouse.c_str(), ImVec2(button_width, button_height))) {
|
if (ImGui::Button(mouse.c_str(), ImVec2(button_width, button_height))) {
|
||||||
if (props->connection_established_) {
|
if (props->connection_established_) {
|
||||||
start_keyboard_capturer_ = !start_keyboard_capturer_;
|
start_keyboard_capturer_ = !start_keyboard_capturer_;
|
||||||
props->control_mouse_ = !props->control_mouse_;
|
props->control_mouse_ = !props->control_mouse_;
|
||||||
props->mouse_control_button_pressed_ =
|
props->enable_mouse_control_ = !props->enable_mouse_control_;
|
||||||
!props->mouse_control_button_pressed_;
|
|
||||||
props->mouse_control_button_label_ =
|
props->mouse_control_button_label_ =
|
||||||
props->mouse_control_button_pressed_
|
props->enable_mouse_control_
|
||||||
? localization::release_mouse[localization_language_index_]
|
? localization::release_mouse[localization_language_index_]
|
||||||
: localization::control_mouse[localization_language_index_];
|
: localization::control_mouse[localization_language_index_];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!props->mouse_control_button_pressed_) {
|
if (!props->enable_mouse_control_) {
|
||||||
draw_list->AddLine(ImVec2(disable_mouse_x, disable_mouse_y),
|
draw_list->AddLine(ImVec2(disable_mouse_x, disable_mouse_y),
|
||||||
ImVec2(mouse_x + button_width - line_padding,
|
ImVec2(mouse_x + button_width - line_padding,
|
||||||
mouse_y + button_height - line_padding),
|
mouse_y + button_height - line_padding),
|
||||||
|
|||||||
Reference in New Issue
Block a user