mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-14 22:14:23 +00:00
63a5f46df4
Now, regardless of how the Zed window is closed, Zed can remember the window's restore size. - [x] Windows implementation - [x] macOS implementation - [x] Linux implementation (partial) - [x] update SQL data base (mark column `fullscreen` as deprecated) The current implementation on Linux is basic, and I'm not sure if it's correct. The variable `fullscreen` in SQL can be removed, but I'm unsure how to do it. edit: mark `fullscreen` as deprecated ### Case 1 When the window is closed as maximized, reopening it will open in the maximized state, and returning from maximized state will restore the position and size it had when it was maximized. https://github.com/zed-industries/zed/assets/14981363/7207752e-878a-4d43-93a7-41ad1fdb3a06 ### Case 2 When the window is closed as fullscreen, reopening it will open in fullscreen mode, and toggling fullscreen will restore the position and size it had when it entered fullscreen (note that the fullscreen application was not recorded in the video, showing a black screen, but it had actually entered fullscreen mode). https://github.com/zed-industries/zed/assets/14981363/ea5aa70d-b296-462a-afb3-4c3372883ea3 ### What's more - As English is not my native language, some variable and struct names may need to be modified to match their actual meaning. - I am not familiar with the APIs related to macOS and Linux, so implementation for these two platforms has not been done for now. - Any suggestions and ideas are welcome. Release Notes: - N/A
67 lines
2.1 KiB
Rust
67 lines
2.1 KiB
Rust
use gpui::*;
|
|
|
|
struct WindowContent {
|
|
text: SharedString,
|
|
}
|
|
|
|
impl Render for WindowContent {
|
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
|
|
div()
|
|
.flex()
|
|
.bg(rgb(0x1e2025))
|
|
.size_full()
|
|
.justify_center()
|
|
.items_center()
|
|
.text_xl()
|
|
.text_color(rgb(0xffffff))
|
|
.child(self.text.clone())
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
App::new().run(|cx: &mut AppContext| {
|
|
// Create several new windows, positioned in the top right corner of each screen
|
|
|
|
for screen in cx.displays() {
|
|
let options = {
|
|
let popup_margin_width = DevicePixels::from(16);
|
|
let popup_margin_height = DevicePixels::from(-0) - DevicePixels::from(48);
|
|
|
|
let window_size = Size {
|
|
width: px(400.),
|
|
height: px(72.),
|
|
};
|
|
|
|
let screen_bounds = screen.bounds();
|
|
let size: Size<DevicePixels> = window_size.into();
|
|
|
|
let bounds = gpui::Bounds::<DevicePixels> {
|
|
origin: screen_bounds.upper_right()
|
|
- point(size.width + popup_margin_width, popup_margin_height),
|
|
size: window_size.into(),
|
|
};
|
|
|
|
WindowOptions {
|
|
// Set the bounds of the window in screen coordinates
|
|
window_bounds: Some(WindowBounds::Windowed(bounds)),
|
|
// Specify the display_id to ensure the window is created on the correct screen
|
|
display_id: Some(screen.id()),
|
|
|
|
titlebar: None,
|
|
window_background: WindowBackgroundAppearance::default(),
|
|
focus: false,
|
|
show: true,
|
|
kind: WindowKind::PopUp,
|
|
is_movable: false,
|
|
app_id: None,
|
|
}
|
|
};
|
|
|
|
cx.open_window(options, |cx| {
|
|
cx.new_view(|_| WindowContent {
|
|
text: format!("{:?}", screen.id()).into(),
|
|
})
|
|
});
|
|
}
|
|
});
|
|
}
|