mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[feat] use SDL_WINDOW_HIDDEN to delay showing the main window to avoid black window during initialization
This commit is contained in:
@@ -408,7 +408,8 @@ int Render::CreateMainWindow() {
|
|||||||
ImGui::SetCurrentContext(main_ctx_);
|
ImGui::SetCurrentContext(main_ctx_);
|
||||||
|
|
||||||
SDL_WindowFlags window_flags =
|
SDL_WindowFlags window_flags =
|
||||||
(SDL_WindowFlags)(SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS);
|
(SDL_WindowFlags)(SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS |
|
||||||
|
SDL_WINDOW_HIDDEN);
|
||||||
main_window_ = SDL_CreateWindow(
|
main_window_ = SDL_CreateWindow(
|
||||||
"Remote Desk", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
"Remote Desk", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||||
main_window_width_default_, main_window_height_default_, window_flags);
|
main_window_width_default_, main_window_height_default_, window_flags);
|
||||||
@@ -516,28 +517,13 @@ int Render::SetupFontAndStyle(bool is_main_window) {
|
|||||||
// Load Fonts
|
// Load Fonts
|
||||||
ImFontConfig config;
|
ImFontConfig config;
|
||||||
config.FontDataOwnedByAtlas = false;
|
config.FontDataOwnedByAtlas = false;
|
||||||
(is_main_window ? font_size_32_main_ : font_size_32_sub_) =
|
io.Fonts->AddFontFromMemoryTTF(OPPOSans_Regular_ttf, OPPOSans_Regular_ttf_len,
|
||||||
io.Fonts->AddFontFromMemoryTTF(
|
32.0f, &config,
|
||||||
OPPOSans_Regular_ttf, sizeof(OPPOSans_Regular_ttf), 32.0f, &config,
|
|
||||||
io.Fonts->GetGlyphRangesChineseFull());
|
io.Fonts->GetGlyphRangesChineseFull());
|
||||||
config.MergeMode = true;
|
config.MergeMode = true;
|
||||||
(is_main_window ? font_size_25_main_ : font_size_25_sub_) =
|
|
||||||
io.Fonts->AddFontFromMemoryTTF(
|
|
||||||
OPPOSans_Regular_ttf, sizeof(OPPOSans_Regular_ttf), 25.0f, &config,
|
|
||||||
io.Fonts->GetGlyphRangesChineseFull());
|
|
||||||
(is_main_window ? font_size_16_main_ : font_size_16_sub_) =
|
|
||||||
io.Fonts->AddFontFromMemoryTTF(
|
|
||||||
OPPOSans_Regular_ttf, sizeof(OPPOSans_Regular_ttf), 16.0f, &config,
|
|
||||||
io.Fonts->GetGlyphRangesChineseFull());
|
|
||||||
|
|
||||||
static const ImWchar icon_ranges[] = {ICON_MIN_FA, ICON_MAX_FA, 0};
|
static const ImWchar icon_ranges[] = {ICON_MIN_FA, ICON_MAX_FA, 0};
|
||||||
(is_main_window ? icon_size_30_main_ : icon_size_30_sub_) =
|
io.Fonts->AddFontFromMemoryTTF(fa_solid_900_ttf, fa_solid_900_ttf_len, 30.0f,
|
||||||
io.Fonts->AddFontFromMemoryTTF(fa_solid_900_ttf, fa_solid_900_ttf_len,
|
&config, icon_ranges);
|
||||||
30.0f, &config, icon_ranges);
|
|
||||||
(is_main_window ? icon_size_15_main_ : icon_size_15_sub_) =
|
|
||||||
io.Fonts->AddFontFromMemoryTTF(fa_solid_900_ttf, fa_solid_900_ttf_len,
|
|
||||||
15.0f, &config, icon_ranges);
|
|
||||||
|
|
||||||
io.Fonts->Build();
|
io.Fonts->Build();
|
||||||
ImGui::StyleColorsLight();
|
ImGui::StyleColorsLight();
|
||||||
|
|
||||||
@@ -930,9 +916,9 @@ int Render::Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reload_recent_connections_ && main_renderer_) {
|
if (reload_recent_connections_ && main_renderer_) {
|
||||||
// loal recent connection thumbnails after saving for 1 second
|
// loal recent connection thumbnails after saving for 0.5 second
|
||||||
uint32_t now_time = SDL_GetTicks();
|
uint32_t now_time = SDL_GetTicks();
|
||||||
if (now_time - recent_connection_image_save_time_ >= 1000) {
|
if (now_time - recent_connection_image_save_time_ >= 500) {
|
||||||
int ret = thumbnail_->LoadThumbnail(
|
int ret = thumbnail_->LoadThumbnail(
|
||||||
main_renderer_, recent_connection_textures_,
|
main_renderer_, recent_connection_textures_,
|
||||||
&recent_connection_image_width_, &recent_connection_image_height_);
|
&recent_connection_image_width_, &recent_connection_image_height_);
|
||||||
@@ -959,6 +945,10 @@ int Render::Run() {
|
|||||||
|
|
||||||
DrawMainWindow();
|
DrawMainWindow();
|
||||||
|
|
||||||
|
if (SDL_WINDOW_HIDDEN & SDL_GetWindowFlags(main_window_)) {
|
||||||
|
SDL_ShowWindow(main_window_);
|
||||||
|
}
|
||||||
|
|
||||||
if (stream_window_inited_) {
|
if (stream_window_inited_) {
|
||||||
DrawStreamWindow();
|
DrawStreamWindow();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class Render {
|
|||||||
int main_window_text_y_padding_ = 10;
|
int main_window_text_y_padding_ = 10;
|
||||||
int main_child_window_x_padding_ = 27;
|
int main_child_window_x_padding_ = 27;
|
||||||
int main_child_window_y_padding_ = 45;
|
int main_child_window_y_padding_ = 45;
|
||||||
int status_bar_height_ = 20;
|
int status_bar_height_ = 22;
|
||||||
int connection_status_window_width_ = 200;
|
int connection_status_window_width_ = 200;
|
||||||
int connection_status_window_height_ = 150;
|
int connection_status_window_height_ = 150;
|
||||||
int notification_window_width_ = 200;
|
int notification_window_width_ = 200;
|
||||||
@@ -353,19 +353,6 @@ class Render {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool settings_window_pos_reset_ = true;
|
bool settings_window_pos_reset_ = true;
|
||||||
|
|
||||||
private:
|
|
||||||
ImFont *font_size_32_main_ = nullptr;
|
|
||||||
ImFont *font_size_25_main_ = nullptr;
|
|
||||||
ImFont *font_size_16_main_ = nullptr;
|
|
||||||
ImFont *font_size_32_sub_ = nullptr;
|
|
||||||
ImFont *font_size_25_sub_ = nullptr;
|
|
||||||
ImFont *font_size_16_sub_ = nullptr;
|
|
||||||
|
|
||||||
ImFont *icon_size_30_main_ = nullptr;
|
|
||||||
ImFont *icon_size_15_main_ = nullptr;
|
|
||||||
ImFont *icon_size_30_sub_ = nullptr;
|
|
||||||
ImFont *icon_size_15_sub_ = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user