[fix] fix control bar display error in fullscreen mode when multiple connections established

This commit is contained in:
dijunkun
2025-05-06 19:49:08 +08:00
parent d05ff9f905
commit 93bd5b2660
2 changed files with 97 additions and 40 deletions

View File

@@ -179,7 +179,8 @@ int Render::ControlWindow(std::shared_ptr<SubStreamWindowProperties> &props) {
} }
} }
ImGui::Begin("ControlWindow", nullptr, std::string control_window_title = props->remote_id_ + "ControlWindow";
ImGui::Begin(control_window_title.c_str(), nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoDocking); ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoDocking);
ImGui::PopStyleVar(); ImGui::PopStyleVar();
@@ -201,8 +202,10 @@ int Render::ControlWindow(std::shared_ptr<SubStreamWindowProperties> &props) {
ImGuiCond_Always); ImGuiCond_Always);
ImGui::SetWindowFontScale(0.5f); ImGui::SetWindowFontScale(0.5f);
std::string control_child_window_title =
props->remote_id_ + "ControlChildWindow";
ImGui::BeginChild( ImGui::BeginChild(
"ControlBar", control_child_window_title.c_str(),
ImVec2(props->control_window_width_ * 2, props->control_window_height_), ImVec2(props->control_window_width_ * 2, props->control_window_height_),
ImGuiChildFlags_Border, ImGuiWindowFlags_NoDecoration); ImGuiChildFlags_Border, ImGuiWindowFlags_NoDecoration);
ImGui::SetWindowFontScale(1.0f); ImGui::SetWindowFontScale(1.0f);

View File

@@ -15,43 +15,51 @@ int Render::StreamWindow() {
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoBringToFrontOnFocus |
ImGuiWindowFlags_NoDocking); ImGuiWindowFlags_NoDocking);
ImGui::PopStyleColor(2); ImGui::PopStyleColor(2);
ImGui::PopStyleVar(); ImGui::PopStyleVar();
ImGuiTabBarFlags tab_bar_flags =
ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_AutoSelectNewTabs;
ImGuiWindowFlags stream_window_flag = ImGuiWindowFlags stream_window_flag =
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoMove; ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoMove;
ImGui::SetNextWindowPos(ImVec2(20, 0), ImGuiCond_Always); if (!fullscreen_button_pressed_) {
ImGui::SetNextWindowSize(ImVec2(0, 20), ImGuiCond_Always); ImGui::SetNextWindowPos(ImVec2(20, 0), ImGuiCond_Always);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 8.0f)); ImGui::SetNextWindowSize(ImVec2(0, 20), ImGuiCond_Always);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 8.0f));
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::Begin("TabBar", nullptr, ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0.0f));
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGui::Begin("TabBar", nullptr,
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoDocking); ImGuiWindowFlags_NoBringToFrontOnFocus |
ImGui::PopStyleColor(); ImGuiWindowFlags_NoDocking);
ImGui::PopStyleVar(2); ImGui::PopStyleColor();
if (ImGui::BeginTabBar("StreamTabBar", tab_bar_flags)) { ImGui::PopStyleVar(2);
if (ImGui::IsWindowHovered()) {
is_tab_bar_hovered_ = true; if (ImGui::BeginTabBar("StreamTabBar",
} else { ImGuiTabBarFlags_Reorderable |
is_tab_bar_hovered_ = false; ImGuiTabBarFlags_AutoSelectNewTabs)) {
} is_tab_bar_hovered_ = ImGui::IsWindowHovered();
for (auto it = client_properties_.begin();
it != client_properties_.end();) {
auto& props = it->second;
if (!props->tab_opened_) {
CleanupPeer(props);
it = client_properties_.erase(it);
if (client_properties_.empty()) {
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
}
continue;
}
for (auto it = client_properties_.begin();
it != client_properties_.end();) {
auto& props = it->second;
if (props->tab_opened_) {
ImGui::SetWindowFontScale(0.6f); ImGui::SetWindowFontScale(0.6f);
if (ImGui::BeginTabItem(props->remote_id_.c_str(), &props->tab_opened_, if (ImGui::BeginTabItem(props->remote_id_.c_str(),
ImGuiTabItemFlags_None)) { &props->tab_opened_)) {
props->tab_selected_ = true; props->tab_selected_ = true;
ImGui::SetWindowFontScale(1.0f); ImGui::SetWindowFontScale(1.0f);
ImGui::SetNextWindowSize( ImGui::SetNextWindowSize(
ImVec2(stream_window_width_, stream_window_height_), ImVec2(stream_window_width_, stream_window_height_),
ImGuiCond_Always); ImGuiCond_Always);
@@ -65,15 +73,15 @@ int Render::StreamWindow() {
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
ImVec2 stream_window_pos = ImGui::GetWindowPos(); ImVec2 pos = ImGui::GetWindowPos();
ImGuiViewport* viewport = ImGui::GetWindowViewport(); ImVec2 size = ImGui::GetWindowSize();
ImVec2 stream_window_size = ImGui::GetWindowSize(); props->render_window_x_ = pos.x;
props->render_window_x_ = stream_window_pos.x; props->render_window_y_ = pos.y;
props->render_window_y_ = stream_window_pos.y; props->render_window_width_ = size.x;
props->render_window_width_ = stream_window_size.x; props->render_window_height_ = size.y;
props->render_window_height_ = stream_window_size.y;
ControlWindow(props); ControlWindow(props);
if (!props->peer_) { if (!props->peer_) {
it = client_properties_.erase(it); it = client_properties_.erase(it);
if (client_properties_.empty()) { if (client_properties_.empty()) {
@@ -92,7 +100,17 @@ int Render::StreamWindow() {
ImGui::SetWindowFontScale(1.0f); ImGui::SetWindowFontScale(1.0f);
++it; ++it;
} }
} else { }
ImGui::EndTabBar();
}
ImGui::End(); // End TabBar
} else {
for (auto it = client_properties_.begin();
it != client_properties_.end();) {
auto& props = it->second;
if (!props->tab_opened_) {
CleanupPeer(props); CleanupPeer(props);
it = client_properties_.erase(it); it = client_properties_.erase(it);
if (client_properties_.empty()) { if (client_properties_.empty()) {
@@ -100,15 +118,51 @@ int Render::StreamWindow() {
event.type = SDL_QUIT; event.type = SDL_QUIT;
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }
continue;
}
if (props->tab_selected_) {
ImGui::SetNextWindowSize(
ImVec2(stream_window_width_, stream_window_height_),
ImGuiCond_Always);
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0.0f));
ImGui::Begin(props->remote_id_.c_str(), nullptr, stream_window_flag);
ImGui::PopStyleColor();
ImGui::PopStyleVar(2);
ImVec2 pos = ImGui::GetWindowPos();
ImVec2 size = ImGui::GetWindowSize();
props->render_window_x_ = pos.x;
props->render_window_y_ = pos.y;
props->render_window_width_ = size.x;
props->render_window_height_ = size.y;
ControlWindow(props);
ImGui::End();
if (!props->peer_) {
fullscreen_button_pressed_ = false;
SDL_SetWindowFullscreen(stream_window_, SDL_FALSE);
it = client_properties_.erase(it);
if (client_properties_.empty()) {
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
}
} else {
++it;
}
} else {
++it;
} }
} }
ImGui::EndTabBar();
} }
ImGui::End();
UpdateRenderRect(); UpdateRenderRect();
ImGui::End(); // End VideoBg
ImGui::End();
return 0; return 0;
} }