mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] fix connection status window gui display
This commit is contained in:
@@ -5,9 +5,8 @@
|
|||||||
|
|
||||||
bool Render::ConnectionStatusWindow(
|
bool Render::ConnectionStatusWindow(
|
||||||
std::shared_ptr<SubStreamWindowProperties> &props) {
|
std::shared_ptr<SubStreamWindowProperties> &props) {
|
||||||
if (show_connection_status_window_) {
|
|
||||||
const ImGuiViewport *viewport = ImGui::GetMainViewport();
|
const ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||||
|
bool ret_flag = false;
|
||||||
ImGui::SetNextWindowPos(ImVec2((viewport->WorkSize.x - viewport->WorkPos.x -
|
ImGui::SetNextWindowPos(ImVec2((viewport->WorkSize.x - viewport->WorkPos.x -
|
||||||
connection_status_window_width_) /
|
connection_status_window_width_) /
|
||||||
2,
|
2,
|
||||||
@@ -43,8 +42,7 @@ bool Render::ConnectionStatusWindow(
|
|||||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||||
// ok
|
// ok
|
||||||
if (ImGui::Button(
|
if (ImGui::Button(localization::ok[localization_language_index_].c_str()) ||
|
||||||
localization::ok[localization_language_index_].c_str()) ||
|
|
||||||
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
||||||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||||
show_connection_status_window_ = false;
|
show_connection_status_window_ = false;
|
||||||
@@ -54,8 +52,7 @@ bool Render::ConnectionStatusWindow(
|
|||||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||||
// ok
|
// ok
|
||||||
if (ImGui::Button(
|
if (ImGui::Button(localization::ok[localization_language_index_].c_str()) ||
|
||||||
localization::ok[localization_language_index_].c_str()) ||
|
|
||||||
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
||||||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||||
show_connection_status_window_ = false;
|
show_connection_status_window_ = false;
|
||||||
@@ -65,8 +62,7 @@ bool Render::ConnectionStatusWindow(
|
|||||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||||
// ok
|
// ok
|
||||||
if (ImGui::Button(
|
if (ImGui::Button(localization::ok[localization_language_index_].c_str()) ||
|
||||||
localization::ok[localization_language_index_].c_str()) ||
|
|
||||||
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
||||||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||||
show_connection_status_window_ = false;
|
show_connection_status_window_ = false;
|
||||||
@@ -76,14 +72,12 @@ bool Render::ConnectionStatusWindow(
|
|||||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||||
// ok
|
// ok
|
||||||
if (ImGui::Button(
|
if (ImGui::Button(localization::ok[localization_language_index_].c_str()) ||
|
||||||
localization::ok[localization_language_index_].c_str()) ||
|
|
||||||
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
||||||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||||
show_connection_status_window_ = false;
|
show_connection_status_window_ = false;
|
||||||
}
|
}
|
||||||
} else if (ConnectionStatus::IncorrectPassword ==
|
} else if (ConnectionStatus::IncorrectPassword == props->connection_status_) {
|
||||||
props->connection_status_) {
|
|
||||||
if (!password_validating_) {
|
if (!password_validating_) {
|
||||||
if (password_validating_time_ == 1) {
|
if (password_validating_time_ == 1) {
|
||||||
text = localization::input_password[localization_language_index_];
|
text = localization::input_password[localization_language_index_];
|
||||||
@@ -115,8 +109,7 @@ bool Render::ConnectionStatusWindow(
|
|||||||
.c_str());
|
.c_str());
|
||||||
ImGui::SetCursorPosX((window_width - text_size.x) * 0.5f - 13.0f);
|
ImGui::SetCursorPosX((window_width - text_size.x) * 0.5f - 13.0f);
|
||||||
ImGui::Checkbox(
|
ImGui::Checkbox(
|
||||||
localization::remember_password[localization_language_index_]
|
localization::remember_password[localization_language_index_].c_str(),
|
||||||
.c_str(),
|
|
||||||
&(props->remember_password_));
|
&(props->remember_password_));
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
@@ -154,13 +147,12 @@ bool Render::ConnectionStatusWindow(
|
|||||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||||
// ok
|
// ok
|
||||||
if (ImGui::Button(
|
if (ImGui::Button(localization::ok[localization_language_index_].c_str()) ||
|
||||||
localization::ok[localization_language_index_].c_str()) ||
|
|
||||||
ImGui::IsKeyPressed(ImGuiKey_Enter)) {
|
ImGui::IsKeyPressed(ImGuiKey_Enter)) {
|
||||||
show_connection_status_window_ = false;
|
show_connection_status_window_ = false;
|
||||||
re_enter_remote_id_ = true;
|
re_enter_remote_id_ = true;
|
||||||
DestroyPeer(&props->peer_);
|
DestroyPeer(&props->peer_);
|
||||||
return true;
|
ret_flag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,6 +166,6 @@ bool Render::ConnectionStatusWindow(
|
|||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
}
|
|
||||||
return false;
|
return ret_flag;
|
||||||
}
|
}
|
||||||
@@ -29,13 +29,20 @@ int Render::MainWindow() {
|
|||||||
RecentConnectionsWindow();
|
RecentConnectionsWindow();
|
||||||
StatusBar();
|
StatusBar();
|
||||||
|
|
||||||
for (auto it = client_properties_.begin(); it != client_properties_.end();) {
|
if (show_connection_status_window_) {
|
||||||
|
for (auto it = client_properties_.begin();
|
||||||
|
it != client_properties_.end();) {
|
||||||
auto& props = it->second;
|
auto& props = it->second;
|
||||||
|
if (focused_remote_id_ == props->remote_id_) {
|
||||||
if (ConnectionStatusWindow(props)) {
|
if (ConnectionStatusWindow(props)) {
|
||||||
it = client_properties_.erase(it);
|
it = client_properties_.erase(it);
|
||||||
} else {
|
} else {
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ static int InputTextCallback(ImGuiInputTextCallbackData *data) {
|
|||||||
int Render::ConnectTo(const std::string &remote_id, const char *password,
|
int Render::ConnectTo(const std::string &remote_id, const char *password,
|
||||||
bool remember_password) {
|
bool remember_password) {
|
||||||
LOG_INFO("Connect to [{}]", remote_id);
|
LOG_INFO("Connect to [{}]", remote_id);
|
||||||
|
focused_remote_id_ = remote_id;
|
||||||
|
|
||||||
if (client_properties_.find(remote_id) == client_properties_.end()) {
|
if (client_properties_.find(remote_id) == client_properties_.end()) {
|
||||||
client_properties_[remote_id] =
|
client_properties_[remote_id] =
|
||||||
|
|||||||
@@ -343,6 +343,7 @@ class Render {
|
|||||||
bool need_to_rejoin_ = false;
|
bool need_to_rejoin_ = false;
|
||||||
bool just_created_ = false;
|
bool just_created_ = false;
|
||||||
std::string controlled_remote_id_ = "";
|
std::string controlled_remote_id_ = "";
|
||||||
|
std::string focused_remote_id_ = "";
|
||||||
bool need_to_send_host_info_ = false;
|
bool need_to_send_host_info_ = false;
|
||||||
SDL_Event last_mouse_event;
|
SDL_Event last_mouse_event;
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ int Render::StreamWindow() {
|
|||||||
|
|
||||||
ControlWindow(props);
|
ControlWindow(props);
|
||||||
|
|
||||||
|
focused_remote_id_ = props->remote_id_;
|
||||||
|
|
||||||
if (!props->peer_) {
|
if (!props->peer_) {
|
||||||
it = client_properties_.erase(it);
|
it = client_properties_.erase(it);
|
||||||
if (client_properties_.empty()) {
|
if (client_properties_.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user