mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-29 12:38:02 +00:00
Apply bounds to all windows when using start-local-collaboration script
This commit is contained in:
parent
5e4da6433f
commit
3d1ba1b363
1 changed files with 36 additions and 17 deletions
|
@ -765,25 +765,21 @@ impl Workspace {
|
||||||
DB.next_id().await.unwrap_or(0)
|
DB.next_id().await.unwrap_or(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
let window_bounds_override =
|
|
||||||
ZED_WINDOW_POSITION
|
|
||||||
.zip(*ZED_WINDOW_SIZE)
|
|
||||||
.map(|(position, size)| {
|
|
||||||
WindowBounds::Fixed(RectF::new(
|
|
||||||
cx.platform().screens()[0].bounds().origin() + position,
|
|
||||||
size,
|
|
||||||
))
|
|
||||||
});
|
|
||||||
|
|
||||||
let build_workspace = |cx: &mut ViewContext<Workspace>| {
|
|
||||||
Workspace::new(workspace_id, project_handle.clone(), app_state.clone(), cx)
|
|
||||||
};
|
|
||||||
|
|
||||||
let workspace = requesting_window_id
|
let workspace = requesting_window_id
|
||||||
.and_then(|window_id| {
|
.and_then(|window_id| {
|
||||||
cx.update(|cx| cx.replace_root_view(window_id, |cx| build_workspace(cx)))
|
cx.update(|cx| {
|
||||||
|
cx.replace_root_view(window_id, |cx| {
|
||||||
|
Workspace::new(
|
||||||
|
workspace_id,
|
||||||
|
project_handle.clone(),
|
||||||
|
app_state.clone(),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
|
let window_bounds_override = window_bounds_env_override(&cx);
|
||||||
let (bounds, display) = if let Some(bounds) = window_bounds_override {
|
let (bounds, display) = if let Some(bounds) = window_bounds_override {
|
||||||
(Some(bounds), None)
|
(Some(bounds), None)
|
||||||
} else {
|
} else {
|
||||||
|
@ -819,7 +815,14 @@ impl Workspace {
|
||||||
// Use the serialized workspace to construct the new window
|
// Use the serialized workspace to construct the new window
|
||||||
cx.add_window(
|
cx.add_window(
|
||||||
(app_state.build_window_options)(bounds, display, cx.platform().as_ref()),
|
(app_state.build_window_options)(bounds, display, cx.platform().as_ref()),
|
||||||
|cx| build_workspace(cx),
|
|cx| {
|
||||||
|
Workspace::new(
|
||||||
|
workspace_id,
|
||||||
|
project_handle.clone(),
|
||||||
|
app_state.clone(),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.1
|
.1
|
||||||
});
|
});
|
||||||
|
@ -3110,6 +3113,17 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn window_bounds_env_override(cx: &AsyncAppContext) -> Option<WindowBounds> {
|
||||||
|
ZED_WINDOW_POSITION
|
||||||
|
.zip(*ZED_WINDOW_SIZE)
|
||||||
|
.map(|(position, size)| {
|
||||||
|
WindowBounds::Fixed(RectF::new(
|
||||||
|
cx.platform().screens()[0].bounds().origin() + position,
|
||||||
|
size,
|
||||||
|
))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async fn open_items(
|
async fn open_items(
|
||||||
serialized_workspace: Option<SerializedWorkspace>,
|
serialized_workspace: Option<SerializedWorkspace>,
|
||||||
workspace: &WeakViewHandle<Workspace>,
|
workspace: &WeakViewHandle<Workspace>,
|
||||||
|
@ -3642,8 +3656,13 @@ pub fn join_remote_project(
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let window_bounds_override = window_bounds_env_override(&cx);
|
||||||
let (_, workspace) = cx.add_window(
|
let (_, workspace) = cx.add_window(
|
||||||
(app_state.build_window_options)(None, None, cx.platform().as_ref()),
|
(app_state.build_window_options)(
|
||||||
|
window_bounds_override,
|
||||||
|
None,
|
||||||
|
cx.platform().as_ref(),
|
||||||
|
),
|
||||||
|cx| Workspace::new(0, project, app_state.clone(), cx),
|
|cx| Workspace::new(0, project, app_state.clone(), cx),
|
||||||
);
|
);
|
||||||
(app_state.initialize_workspace)(
|
(app_state.initialize_workspace)(
|
||||||
|
|
Loading…
Reference in a new issue