diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 00b50e1e417cf2..1db4af4e6e21fe 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -270,6 +270,8 @@ pub struct App { pub(crate) tracked_entities: FxHashMap>, #[cfg(any(test, feature = "test-support", debug_assertions))] pub(crate) name: Option<&'static str>, + /// Represents the application identifier, which can be set via a command-line argument. + pub app_id: Option, } impl App { @@ -334,6 +336,7 @@ impl App { #[cfg(any(test, feature = "test-support", debug_assertions))] name: None, + app_id: None, }), }); diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 6ec65acb40188a..88d0ec26af6a46 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -578,6 +578,8 @@ fn main() { open_listener.open_urls(urls) } + cx.app_id = args.app_id; // None, by default + match open_rx .try_next() .ok() @@ -1005,6 +1007,10 @@ struct Args { /// Instructs zed to run as a dev server on this machine. (not implemented) #[arg(long)] dev_server_token: Option, + + /// Instructs zed to use custom app_id for window managers. + #[arg(long)] + app_id: Option, } #[derive(Clone, Debug)] diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index adb1d2b03f490d..c319ae6e5820fb 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -123,7 +123,11 @@ pub fn build_window_options(display_uuid: Option, cx: &mut App) -> WindowO .into_iter() .find(|display| display.uuid().ok() == Some(uuid)) }); - let app_id = ReleaseChannel::global(cx).app_id(); + if cx.app_id.is_none() { + let default_app_id = ReleaseChannel::global(cx).app_id().to_string(); + cx.app_id = Some(default_app_id); + } + let window_decorations = match std::env::var("ZED_WINDOW_DECORATIONS") { Ok(val) if val == "server" => gpui::WindowDecorations::Server, Ok(val) if val == "client" => gpui::WindowDecorations::Client, @@ -143,7 +147,7 @@ pub fn build_window_options(display_uuid: Option, cx: &mut App) -> WindowO is_movable: true, display_id: display.map(|display| display.id()), window_background: cx.theme().window_background_appearance(), - app_id: Some(app_id.to_owned()), + app_id: cx.app_id.to_owned(), window_decorations: Some(window_decorations), window_min_size: Some(gpui::Size { width: px(360.0),