mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-04-08 10:52:42 +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 = {
|
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 = {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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_) {
|
||||||
|
|||||||
Reference in New Issue
Block a user