mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-03-22 07:37:29 +08:00
[feat] show 'Receiving screen' text before the remote frame arrives
This commit is contained in:
@@ -146,6 +146,8 @@ static std::vector<std::string> p2p_disconnected = {
|
||||
static std::vector<std::string> p2p_connecting = {
|
||||
reinterpret_cast<const char*>(u8"正在建立对等连接..."),
|
||||
"P2P Connecting ..."};
|
||||
static std::vector<std::string> receiving_screen = {
|
||||
reinterpret_cast<const char*>(u8"画面接收中..."), "Receiving screen..."};
|
||||
static std::vector<std::string> p2p_failed = {
|
||||
reinterpret_cast<const char*>(u8"对等连接失败"), "P2P Failed"};
|
||||
static std::vector<std::string> p2p_closed = {
|
||||
|
||||
@@ -261,6 +261,8 @@ class Render {
|
||||
int NetTrafficStats(std::shared_ptr<SubStreamWindowProperties>& props);
|
||||
void DrawConnectionStatusText(
|
||||
std::shared_ptr<SubStreamWindowProperties>& props);
|
||||
void DrawReceivingScreenText(
|
||||
std::shared_ptr<SubStreamWindowProperties>& props);
|
||||
#ifdef __APPLE__
|
||||
int RequestPermissionWindow();
|
||||
bool CheckScreenRecordingPermission();
|
||||
|
||||
@@ -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) {
|
||||
// std::unique_lock lock(client_properties_mutex_);
|
||||
if (it != client_properties_.end()) {
|
||||
@@ -144,6 +172,8 @@ int Render::StreamWindow() {
|
||||
// Show file transfer window if needed
|
||||
FileTransferWindow(props);
|
||||
|
||||
DrawReceivingScreenText(props);
|
||||
|
||||
focused_remote_id_ = props->remote_id_;
|
||||
|
||||
if (!props->peer_) {
|
||||
@@ -244,6 +274,8 @@ int Render::StreamWindow() {
|
||||
// Show file transfer window if needed
|
||||
FileTransferWindow(props);
|
||||
|
||||
DrawReceivingScreenText(props);
|
||||
|
||||
ImGui::End();
|
||||
|
||||
if (!props->peer_) {
|
||||
|
||||
Reference in New Issue
Block a user