mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-03-28 20:45:32 +08:00
Compare commits
8 Commits
d679c6251b
...
v1.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b230b851e4 | ||
|
|
ff32477ffe | ||
|
|
c6c60decdb | ||
|
|
7505adeca8 | ||
|
|
754f1fba88 | ||
|
|
8be46b870a | ||
|
|
81cb1d6c0b | ||
|
|
319416f1b7 |
@@ -146,6 +146,8 @@ static std::vector<std::string> p2p_disconnected = {
|
|||||||
static std::vector<std::string> p2p_connecting = {
|
static std::vector<std::string> p2p_connecting = {
|
||||||
reinterpret_cast<const char*>(u8"正在建立对等连接..."),
|
reinterpret_cast<const char*>(u8"正在建立对等连接..."),
|
||||||
"P2P Connecting ..."};
|
"P2P Connecting ..."};
|
||||||
|
static std::vector<std::string> receiving_screen = {
|
||||||
|
reinterpret_cast<const char*>(u8"画面接收中..."), "Receiving screen..."};
|
||||||
static std::vector<std::string> p2p_failed = {
|
static std::vector<std::string> p2p_failed = {
|
||||||
reinterpret_cast<const char*>(u8"对等连接失败"), "P2P Failed"};
|
reinterpret_cast<const char*>(u8"对等连接失败"), "P2P Failed"};
|
||||||
static std::vector<std::string> p2p_closed = {
|
static std::vector<std::string> p2p_closed = {
|
||||||
|
|||||||
@@ -227,14 +227,8 @@ int Render::ShowRecentConnections() {
|
|||||||
if (ImGui::Button(connect_to_this_connection_button_name.c_str(),
|
if (ImGui::Button(connect_to_this_connection_button_name.c_str(),
|
||||||
ImVec2(recent_connection_button_width,
|
ImVec2(recent_connection_button_width,
|
||||||
recent_connection_button_height))) {
|
recent_connection_button_height))) {
|
||||||
if (online) {
|
ConnectTo(it.second.remote_id, it.second.password.c_str(),
|
||||||
ConnectTo(it.second.remote_id, it.second.password.c_str(),
|
it.second.remember_password);
|
||||||
it.second.remember_password);
|
|
||||||
} else {
|
|
||||||
show_offline_warning_window_ = true;
|
|
||||||
offline_warning_text_ =
|
|
||||||
localization::device_offline[localization_language_index_];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
|||||||
@@ -197,6 +197,9 @@ int Render::ConnectTo(const std::string& remote_id, const char* password,
|
|||||||
props->control_window_max_width_ = title_bar_height_ * 9.0f;
|
props->control_window_max_width_ = title_bar_height_ * 9.0f;
|
||||||
props->control_window_max_height_ = title_bar_height_ * 7.0f;
|
props->control_window_max_height_ = title_bar_height_ * 7.0f;
|
||||||
|
|
||||||
|
props->connection_status_ = ConnectionStatus::Connecting;
|
||||||
|
show_connection_status_window_ = true;
|
||||||
|
|
||||||
if (!props->peer_) {
|
if (!props->peer_) {
|
||||||
LOG_INFO("Create peer [{}] instance failed", props->local_id_);
|
LOG_INFO("Create peer [{}] instance failed", props->local_id_);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1173,13 +1173,16 @@ int Render::DestroyServerWindow() {
|
|||||||
|
|
||||||
if (server_renderer_) {
|
if (server_renderer_) {
|
||||||
SDL_DestroyRenderer(server_renderer_);
|
SDL_DestroyRenderer(server_renderer_);
|
||||||
|
server_renderer_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server_window_) {
|
if (server_window_) {
|
||||||
SDL_DestroyWindow(server_window_);
|
SDL_DestroyWindow(server_window_);
|
||||||
|
server_window_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
server_window_created_ = false;
|
server_window_created_ = false;
|
||||||
|
server_window_inited_ = false;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1546,7 +1549,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;
|
||||||
@@ -261,6 +261,8 @@ class Render {
|
|||||||
int NetTrafficStats(std::shared_ptr<SubStreamWindowProperties>& props);
|
int NetTrafficStats(std::shared_ptr<SubStreamWindowProperties>& props);
|
||||||
void DrawConnectionStatusText(
|
void DrawConnectionStatusText(
|
||||||
std::shared_ptr<SubStreamWindowProperties>& props);
|
std::shared_ptr<SubStreamWindowProperties>& props);
|
||||||
|
void DrawReceivingScreenText(
|
||||||
|
std::shared_ptr<SubStreamWindowProperties>& props);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
int RequestPermissionWindow();
|
int RequestPermissionWindow();
|
||||||
bool CheckScreenRecordingPermission();
|
bool CheckScreenRecordingPermission();
|
||||||
|
|||||||
@@ -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");
|
||||||
@@ -491,9 +498,9 @@ void Render::OnReceiveDataBufferCb(const char* data, size_t size,
|
|||||||
const double bps =
|
const double bps =
|
||||||
(static_cast<double>(delta_bytes) * 8.0) / delta_seconds;
|
(static_cast<double>(delta_bytes) * 8.0) / delta_seconds;
|
||||||
if (bps > 0.0) {
|
if (bps > 0.0) {
|
||||||
const double capped =
|
const double capped = (std::min)(
|
||||||
(std::min)(bps, static_cast<double>(
|
bps,
|
||||||
(std::numeric_limits<uint32_t>::max)()));
|
static_cast<double>((std::numeric_limits<uint32_t>::max)()));
|
||||||
estimated_rate_bps = static_cast<uint32_t>(capped);
|
estimated_rate_bps = static_cast<uint32_t>(capped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -648,6 +655,7 @@ void Render::OnSignalStatusCb(SignalStatus status, const char* user_id,
|
|||||||
render->signal_connected_ = false;
|
render->signal_connected_ = false;
|
||||||
} else if (SignalStatus::SignalConnected == status) {
|
} else if (SignalStatus::SignalConnected == status) {
|
||||||
render->signal_connected_ = true;
|
render->signal_connected_ = true;
|
||||||
|
render->need_to_send_recent_connections_ = true;
|
||||||
LOG_INFO("[{}] connected to signal server", client_id);
|
LOG_INFO("[{}] connected to signal server", client_id);
|
||||||
} else if (SignalStatus::SignalFailed == status) {
|
} else if (SignalStatus::SignalFailed == status) {
|
||||||
render->signal_connected_ = false;
|
render->signal_connected_ = false;
|
||||||
@@ -764,7 +772,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_);
|
||||||
@@ -873,6 +881,8 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char* user_id,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ConnectionStatus::Disconnected:
|
||||||
|
case ConnectionStatus::Failed:
|
||||||
case ConnectionStatus::Closed: {
|
case ConnectionStatus::Closed: {
|
||||||
if (std::all_of(render->connection_status_.begin(),
|
if (std::all_of(render->connection_status_.begin(),
|
||||||
render->connection_status_.end(), [](const auto& kv) {
|
render->connection_status_.end(), [](const auto& kv) {
|
||||||
@@ -894,6 +904,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char* user_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
render->connection_status_.erase(remote_id);
|
render->connection_status_.erase(remote_id);
|
||||||
|
render->connection_host_names_.erase(remote_id);
|
||||||
if (render->screen_capturer_) {
|
if (render->screen_capturer_) {
|
||||||
render->screen_capturer_->ResetToInitialMonitor();
|
render->screen_capturer_->ResetToInitialMonitor();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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),
|
||||||
|
|||||||
@@ -36,6 +36,18 @@ bool Render::ConnectionStatusWindow(
|
|||||||
text = localization::p2p_connecting[localization_language_index_];
|
text = localization::p2p_connecting[localization_language_index_];
|
||||||
ImGui::SetCursorPosX(connection_status_window_width * 0.43f);
|
ImGui::SetCursorPosX(connection_status_window_width * 0.43f);
|
||||||
ImGui::SetCursorPosY(connection_status_window_height * 0.67f);
|
ImGui::SetCursorPosY(connection_status_window_height * 0.67f);
|
||||||
|
// cancel
|
||||||
|
if (ImGui::Button(
|
||||||
|
localization::cancel[localization_language_index_].c_str()) ||
|
||||||
|
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||||
|
show_connection_status_window_ = false;
|
||||||
|
re_enter_remote_id_ = true;
|
||||||
|
LOG_INFO("User cancelled connecting to [{}]", props->remote_id_);
|
||||||
|
if (props->peer_) {
|
||||||
|
LeaveConnection(props->peer_, props->remote_id_.c_str());
|
||||||
|
}
|
||||||
|
ret_flag = true;
|
||||||
|
}
|
||||||
} else if (ConnectionStatus::Connected == props->connection_status_) {
|
} else if (ConnectionStatus::Connected == props->connection_status_) {
|
||||||
text = localization::p2p_connected[localization_language_index_];
|
text = localization::p2p_connected[localization_language_index_];
|
||||||
ImGui::SetCursorPosX(connection_status_window_width * 0.43f);
|
ImGui::SetCursorPosX(connection_status_window_width * 0.43f);
|
||||||
|
|||||||
@@ -148,33 +148,38 @@ int Render::RemoteClientInfoWindow() {
|
|||||||
|
|
||||||
float font_scale = localization_language_index_ == 0 ? 0.5f : 0.45f;
|
float font_scale = localization_language_index_ == 0 ? 0.5f : 0.45f;
|
||||||
|
|
||||||
std::vector<std::string> remote_hostnames;
|
std::vector<std::pair<std::string, std::string>> remote_entries;
|
||||||
remote_hostnames.reserve(connection_host_names_.size());
|
remote_entries.reserve(connection_status_.size());
|
||||||
for (const auto& kv : connection_host_names_) {
|
for (const auto& kv : connection_status_) {
|
||||||
remote_hostnames.push_back(kv.second);
|
const auto host_it = connection_host_names_.find(kv.first);
|
||||||
|
const std::string display_name =
|
||||||
|
(host_it != connection_host_names_.end() && !host_it->second.empty())
|
||||||
|
? host_it->second
|
||||||
|
: kv.first;
|
||||||
|
remote_entries.emplace_back(kv.first, display_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto find_remote_id_by_hostname =
|
auto find_display_name_by_remote_id =
|
||||||
[this](const std::string& hostname) -> std::string {
|
[&remote_entries](const std::string& remote_id) -> std::string {
|
||||||
for (const auto& kv : connection_host_names_) {
|
for (const auto& entry : remote_entries) {
|
||||||
if (kv.second == hostname) {
|
if (entry.first == remote_id) {
|
||||||
return kv.first;
|
return entry.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!selected_server_remote_hostname_.empty()) {
|
if (!selected_server_remote_id_.empty() &&
|
||||||
if (std::find(remote_hostnames.begin(), remote_hostnames.end(),
|
find_display_name_by_remote_id(selected_server_remote_id_).empty()) {
|
||||||
selected_server_remote_hostname_) == remote_hostnames.end()) {
|
selected_server_remote_id_.clear();
|
||||||
selected_server_remote_hostname_.clear();
|
selected_server_remote_hostname_.clear();
|
||||||
selected_server_remote_id_.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (selected_server_remote_hostname_.empty() && !remote_hostnames.empty()) {
|
if (selected_server_remote_id_.empty() && !remote_entries.empty()) {
|
||||||
selected_server_remote_hostname_ = remote_hostnames.front();
|
selected_server_remote_id_ = remote_entries.front().first;
|
||||||
selected_server_remote_id_ =
|
}
|
||||||
find_remote_id_by_hostname(selected_server_remote_hostname_);
|
if (!selected_server_remote_id_.empty()) {
|
||||||
|
selected_server_remote_hostname_ =
|
||||||
|
find_display_name_by_remote_id(selected_server_remote_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(font_scale);
|
ImGui::SetWindowFontScale(font_scale);
|
||||||
@@ -196,13 +201,12 @@ int Render::RemoteClientInfoWindow() {
|
|||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
if (ImGui::BeginCombo("##server_remote_id", selected_preview)) {
|
if (ImGui::BeginCombo("##server_remote_id", selected_preview)) {
|
||||||
ImGui::SetWindowFontScale(localization_language_index_ == 0 ? 0.45f : 0.4f);
|
ImGui::SetWindowFontScale(localization_language_index_ == 0 ? 0.45f : 0.4f);
|
||||||
for (int i = 0; i < static_cast<int>(remote_hostnames.size()); i++) {
|
for (int i = 0; i < static_cast<int>(remote_entries.size()); i++) {
|
||||||
const bool selected =
|
const bool selected =
|
||||||
(remote_hostnames[i] == selected_server_remote_hostname_);
|
(remote_entries[i].first == selected_server_remote_id_);
|
||||||
if (ImGui::Selectable(remote_hostnames[i].c_str(), selected)) {
|
if (ImGui::Selectable(remote_entries[i].second.c_str(), selected)) {
|
||||||
selected_server_remote_hostname_ = remote_hostnames[i];
|
selected_server_remote_id_ = remote_entries[i].first;
|
||||||
selected_server_remote_id_ =
|
selected_server_remote_hostname_ = remote_entries[i].second;
|
||||||
find_remote_id_by_hostname(selected_server_remote_hostname_);
|
|
||||||
}
|
}
|
||||||
if (selected) {
|
if (selected) {
|
||||||
ImGui::SetItemDefaultFocus();
|
ImGui::SetItemDefaultFocus();
|
||||||
|
|||||||
@@ -31,6 +31,34 @@ void Render::DrawConnectionStatusText(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Render::DrawReceivingScreenText(
|
||||||
|
std::shared_ptr<SubStreamWindowProperties>& props) {
|
||||||
|
if (!props->connection_established_ ||
|
||||||
|
props->connection_status_ != ConnectionStatus::Connected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool has_valid_frame = false;
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(props->video_frame_mutex_);
|
||||||
|
has_valid_frame = props->stream_texture_ != nullptr &&
|
||||||
|
props->video_width_ > 0 && props->video_height_ > 0 &&
|
||||||
|
props->front_frame_ && !props->front_frame_->empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_valid_frame) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& text =
|
||||||
|
localization::receiving_screen[localization_language_index_];
|
||||||
|
ImVec2 size = ImGui::GetWindowSize();
|
||||||
|
ImVec2 text_size = ImGui::CalcTextSize(text.c_str());
|
||||||
|
ImGui::SetCursorPos(
|
||||||
|
ImVec2((size.x - text_size.x) * 0.5f, (size.y - text_size.y) * 0.5f));
|
||||||
|
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.92f), "%s", text.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void Render::CloseTab(decltype(client_properties_)::iterator& it) {
|
void Render::CloseTab(decltype(client_properties_)::iterator& it) {
|
||||||
// std::unique_lock lock(client_properties_mutex_);
|
// std::unique_lock lock(client_properties_mutex_);
|
||||||
if (it != client_properties_.end()) {
|
if (it != client_properties_.end()) {
|
||||||
@@ -144,6 +172,8 @@ int Render::StreamWindow() {
|
|||||||
// Show file transfer window if needed
|
// Show file transfer window if needed
|
||||||
FileTransferWindow(props);
|
FileTransferWindow(props);
|
||||||
|
|
||||||
|
DrawReceivingScreenText(props);
|
||||||
|
|
||||||
focused_remote_id_ = props->remote_id_;
|
focused_remote_id_ = props->remote_id_;
|
||||||
|
|
||||||
if (!props->peer_) {
|
if (!props->peer_) {
|
||||||
@@ -244,6 +274,8 @@ int Render::StreamWindow() {
|
|||||||
// Show file transfer window if needed
|
// Show file transfer window if needed
|
||||||
FileTransferWindow(props);
|
FileTransferWindow(props);
|
||||||
|
|
||||||
|
DrawReceivingScreenText(props);
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
if (!props->peer_) {
|
if (!props->peer_) {
|
||||||
|
|||||||
Submodule submodules/minirtc updated: 27c117a81a...a0001b1faf
Reference in New Issue
Block a user