diff --git a/src/gui/component.rs b/src/gui/component.rs index b2fa259..708dcd9 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,11 @@ 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 } } 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,