From 6f28f1ca0a447355fd49b216d70402d6db3c6e8d Mon Sep 17 00:00:00 2001 From: aa11653 <1165320598@qq.com> Date: Fri, 17 Jul 2026 01:34:15 +0800 Subject: [PATCH 1/2] fix: defer window visibility until initialization completes --- src/gui/component.rs | 5 +++-- src/main.rs | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/component.rs b/src/gui/component.rs index b2fa259..a5c746e 100644 --- a/src/gui/component.rs +++ b/src/gui/component.rs @@ -165,8 +165,6 @@ impl AsyncComponent for Greeter { // The `view!` macro needs a proper widget, not a template, as the root. #[name = "window"] gtk::ApplicationWindow { - set_visible: true, - // Name the UI widget, otherwise the inner children cannot be accessed by name. #[name = "ui"] #[template] @@ -455,6 +453,9 @@ impl AsyncComponent for Greeter { } } + // Set window visible after all the setup is done. + root.set_visible(true); + AsyncComponentParts { model, widgets } } diff --git a/src/main.rs b/src/main.rs index 493505e..61a4797 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,7 +76,8 @@ fn main() { // Keep the guard alive till the end of the function, since logging depends on this. let _guard = init_logging(&args.logs, &args.log_level, args.verbose); - let app = relm4::RelmApp::new(APP_ID); + // We will make the app invisible on startup, then make it visible after style loaded and initialized. + let app = relm4::RelmApp::new(APP_ID).visible_on_activate(false); app.with_args(vec![]).run_async::(GreeterInit { config_path: args.config, css_path: args.style, From afff903ae6789c3745d0a1c50f8980808dbfa8ea Mon Sep 17 00:00:00 2001 From: aa11653 <1165320598@qq.com> Date: Fri, 17 Jul 2026 01:52:14 +0800 Subject: [PATCH 2/2] fix: restore the intended initial focus --- src/gui/component.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/component.rs b/src/gui/component.rs index a5c746e..708dcd9 100644 --- a/src/gui/component.rs +++ b/src/gui/component.rs @@ -455,6 +455,8 @@ impl AsyncComponent for Greeter { // Set window visible after all the setup is done. root.set_visible(true); + // Restore the intended initial focus. + widgets.ui.login_button.grab_focus(); AsyncComponentParts { model, widgets } }