commit 1e9122826142119170e552c560bcaaefa5f71611
parent 6492564a3007fe20ef83c1b8676c486b0603838a
Author: triesap <tyson@radroots.org>
Date: Fri, 17 Apr 2026 23:10:46 +0000
app: align macos desktop bootstrap
Diffstat:
5 files changed, 58 insertions(+), 37 deletions(-)
diff --git a/crates/launchers/desktop/src/app.rs b/crates/launchers/desktop/src/app.rs
@@ -1,18 +1,19 @@
-use gpui::{AppContext, Application, WindowOptions, px, size};
+use gpui::{Application, WindowOptions, px, size};
use radroots_app_core::{APP_PROJECTION_SOURCE, AppBuildIdentity, AppRuntimeSnapshot};
use radroots_app_i18n::select_locale_from_host;
use radroots_app_ui::APP_UI_THEME;
use crate::menus::install_native_app_menu;
use crate::runtime::DesktopAppRuntime;
-use crate::window::{HomeView, home_titlebar_options};
+use crate::window::{home_titlebar_options, open_home_window};
pub fn launch() {
let snapshot = AppRuntimeSnapshot::capture(build_identity());
let runtime = DesktopAppRuntime::bootstrap();
- let app = Application::new();
+ let app = Application::new().with_assets(gpui_component_assets::Assets);
app.run(move |cx| {
+ gpui_component::init(cx);
select_locale_from_host(&snapshot.host.host_locale);
install_native_app_menu(runtime.clone(), cx);
@@ -36,7 +37,10 @@ pub fn launch() {
titlebar: Some(home_titlebar_options()),
..Default::default()
},
- |_, cx| cx.new(|_| HomeView::new(runtime.clone())),
+ |window, cx| {
+ window.activate_window();
+ open_home_window(window, cx, runtime.clone())
+ },
)
.expect("main radroots app window should open");
diff --git a/crates/launchers/desktop/src/menus.rs b/crates/launchers/desktop/src/menus.rs
@@ -1,9 +1,13 @@
-use gpui::{App, KeyBinding, Menu, MenuItem, SystemMenuType, actions};
+use gpui::{
+ App, Bounds, KeyBinding, Menu, MenuItem, SystemMenuType, WindowBounds, WindowOptions,
+ actions, px, size,
+};
use radroots_app_i18n::{AppTextKey, app_text};
+use radroots_app_ui::APP_UI_THEME;
use crate::{
runtime::DesktopAppRuntime,
- window::{SettingsPanelViewKey, open_settings_window},
+ window::{SettingsPanelViewKey, open_settings_window, settings_titlebar_options},
};
actions!(radroots_app, [OpenAboutWindow, QuitApp]);
@@ -14,7 +18,30 @@ const fn about_menu_settings_view() -> SettingsPanelViewKey {
pub fn install_native_app_menu(runtime: DesktopAppRuntime, cx: &mut App) {
cx.on_action(move |_: &OpenAboutWindow, cx| {
- open_settings_window(cx, runtime.clone(), about_menu_settings_view());
+ let bounds = Bounds::centered(
+ None,
+ size(
+ px(APP_UI_THEME.windows.settings_width_px),
+ px(APP_UI_THEME.windows.settings_height_px),
+ ),
+ cx,
+ );
+
+ cx.open_window(
+ WindowOptions {
+ window_bounds: Some(WindowBounds::Windowed(bounds)),
+ window_min_size: Some(size(
+ px(APP_UI_THEME.windows.settings_width_px),
+ px(APP_UI_THEME.windows.settings_height_px),
+ )),
+ titlebar: Some(settings_titlebar_options()),
+ ..Default::default()
+ },
+ |window, cx| {
+ open_settings_window(window, cx, runtime.clone(), about_menu_settings_view())
+ },
+ )
+ .expect("settings window should open");
});
cx.on_action(|_: &QuitApp, cx| cx.quit());
cx.bind_keys([KeyBinding::new("cmd-q", QuitApp, None)]);
diff --git a/crates/launchers/desktop/src/source_guards.rs b/crates/launchers/desktop/src/source_guards.rs
@@ -1,6 +1,6 @@
use std::collections::BTreeSet;
-const ALLOWED_MENU_LITERALS: &[&str] = &["cmd-q"];
+const ALLOWED_MENU_LITERALS: &[&str] = &["cmd-q", "settings window should open"];
const ALLOWED_WINDOW_LITERALS: &[&str] = &[
"account-add",
@@ -8,7 +8,6 @@ const ALLOWED_WINDOW_LITERALS: &[&str] = &[
"account-log-out",
"account-more",
"home-today-scroll",
- "settings window should open",
"settings-allow-relay-connections",
"settings-launch-at-login",
"settings-manage-media-servers",
diff --git a/crates/launchers/desktop/src/window.rs b/crates/launchers/desktop/src/window.rs
@@ -1,9 +1,9 @@
use gpui::{
- AnyElement, App, AppContext, Bounds, Context, InteractiveElement, IntoElement, ParentElement,
- Render, SharedString, StatefulInteractiveElement, Styled, Window, WindowBounds, WindowOptions,
- div, prelude::FluentBuilder, px, relative, rgb, size,
+ AnyElement, App, AppContext, Context, InteractiveElement, IntoElement, ParentElement, Render,
+ SharedString, StatefulInteractiveElement, Styled, Window, div, prelude::FluentBuilder, px,
+ relative, rgb,
};
-use gpui_component::IconName;
+use gpui_component::{IconName, Root};
use radroots_app_i18n::AppTextKey;
pub use radroots_app_models::SettingsSection as SettingsPanelViewKey;
use radroots_app_models::{
@@ -36,34 +36,24 @@ pub fn settings_titlebar_options() -> gpui::TitlebarOptions {
}
}
+pub fn open_home_window(
+ window: &mut Window,
+ cx: &mut App,
+ runtime: DesktopAppRuntime,
+) -> gpui::Entity<Root> {
+ let view = cx.new(|_| HomeView::new(runtime));
+ cx.new(|cx| Root::new(view, window, cx))
+}
+
pub fn open_settings_window(
+ window: &mut Window,
cx: &mut App,
runtime: DesktopAppRuntime,
initial_view: SettingsPanelViewKey,
-) {
- let bounds = Bounds::centered(
- None,
- size(
- px(APP_UI_THEME.windows.settings_width_px),
- px(APP_UI_THEME.windows.settings_height_px),
- ),
- cx,
- );
+) -> gpui::Entity<Root> {
let _ = runtime.select_settings_section(initial_view);
-
- cx.open_window(
- WindowOptions {
- window_bounds: Some(WindowBounds::Windowed(bounds)),
- window_min_size: Some(size(
- px(APP_UI_THEME.windows.settings_width_px),
- px(APP_UI_THEME.windows.settings_height_px),
- )),
- titlebar: Some(settings_titlebar_options()),
- ..Default::default()
- },
- |_, cx| cx.new(|_| SettingsWindowView::new(runtime.clone())),
- )
- .expect("settings window should open");
+ let view = cx.new(|_| SettingsWindowView::new(runtime));
+ cx.new(|cx| Root::new(view, window, cx))
}
pub struct HomeView {
diff --git a/platforms/macos/Scripts/run-macos-host.sh b/platforms/macos/Scripts/run-macos-host.sh
@@ -20,4 +20,5 @@ executable_name="$(
)"
executable_path="${app_path}/Contents/MacOS/${executable_name}"
-exec "${executable_path}" "$@"
+"${executable_path}" "$@" &
+disown