mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-03-22 07:37:29 +08:00
[fix] fix cannot close connection from Server Window when the peer is a web client
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -881,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) {
|
||||||
@@ -902,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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user