Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom app_id for window managers #25349

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/gpui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ pub struct App {
pub(crate) tracked_entities: FxHashMap<WindowId, FxHashSet<EntityId>>,
#[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<String>,
}

impl App {
Expand Down Expand Up @@ -334,6 +336,7 @@ impl App {

#[cfg(any(test, feature = "test-support", debug_assertions))]
name: None,
app_id: None,
}),
});

Expand Down
6 changes: 6 additions & 0 deletions crates/zed/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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<String>,

/// Instructs zed to use custom app_id for window managers.
#[arg(long)]
app_id: Option<String>,
}

#[derive(Clone, Debug)]
Expand Down
8 changes: 6 additions & 2 deletions crates/zed/src/zed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ pub fn build_window_options(display_uuid: Option<Uuid>, 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,
Expand All @@ -143,7 +147,7 @@ pub fn build_window_options(display_uuid: Option<Uuid>, 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),
Expand Down
Loading