
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
130 lines
4.1 KiB
Rust
130 lines
4.1 KiB
Rust
pub mod channel_view;
|
|
pub mod chat_panel;
|
|
pub mod collab_panel;
|
|
mod collab_titlebar_item;
|
|
mod face_pile;
|
|
pub mod notification_panel;
|
|
pub mod notifications;
|
|
mod panel_settings;
|
|
|
|
use std::{rc::Rc, sync::Arc};
|
|
|
|
use call::{report_call_event_for_room, ActiveCall};
|
|
pub use collab_panel::CollabPanel;
|
|
pub use collab_titlebar_item::CollabTitlebarItem;
|
|
use gpui::{
|
|
actions, point, AppContext, DevicePixels, Pixels, PlatformDisplay, Size, Task,
|
|
WindowBackgroundAppearance, WindowBounds, WindowContext, WindowKind, WindowOptions,
|
|
};
|
|
use panel_settings::MessageEditorSettings;
|
|
pub use panel_settings::{
|
|
ChatPanelSettings, CollaborationPanelSettings, NotificationPanelSettings,
|
|
};
|
|
use release_channel::ReleaseChannel;
|
|
use settings::Settings;
|
|
use workspace::{notifications::DetachAndPromptErr, AppState};
|
|
|
|
actions!(
|
|
collab,
|
|
[ToggleScreenSharing, ToggleMute, ToggleDeafen, LeaveCall]
|
|
);
|
|
|
|
pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
|
CollaborationPanelSettings::register(cx);
|
|
ChatPanelSettings::register(cx);
|
|
NotificationPanelSettings::register(cx);
|
|
MessageEditorSettings::register(cx);
|
|
|
|
vcs_menu::init(cx);
|
|
collab_titlebar_item::init(cx);
|
|
collab_panel::init(cx);
|
|
channel_view::init(cx);
|
|
chat_panel::init(cx);
|
|
notification_panel::init(cx);
|
|
notifications::init(&app_state, cx);
|
|
}
|
|
|
|
pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut WindowContext) {
|
|
let call = ActiveCall::global(cx).read(cx);
|
|
if let Some(room) = call.room().cloned() {
|
|
let client = call.client();
|
|
let toggle_screen_sharing = room.update(cx, |room, cx| {
|
|
if room.is_screen_sharing() {
|
|
report_call_event_for_room(
|
|
"disable screen share",
|
|
room.id(),
|
|
room.channel_id(),
|
|
&client,
|
|
);
|
|
Task::ready(room.unshare_screen(cx))
|
|
} else {
|
|
report_call_event_for_room(
|
|
"enable screen share",
|
|
room.id(),
|
|
room.channel_id(),
|
|
&client,
|
|
);
|
|
room.share_screen(cx)
|
|
}
|
|
});
|
|
toggle_screen_sharing.detach_and_prompt_err("Sharing Screen Failed", cx, |e, _| Some(format!("{:?}\n\nPlease check that you have given Zed permissions to record your screen in Settings.", e)));
|
|
}
|
|
}
|
|
|
|
pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
|
|
let call = ActiveCall::global(cx).read(cx);
|
|
if let Some(room) = call.room().cloned() {
|
|
let client = call.client();
|
|
room.update(cx, |room, cx| {
|
|
let operation = if room.is_muted() {
|
|
"enable microphone"
|
|
} else {
|
|
"disable microphone"
|
|
};
|
|
report_call_event_for_room(operation, room.id(), room.channel_id(), &client);
|
|
|
|
room.toggle_mute(cx)
|
|
});
|
|
}
|
|
}
|
|
|
|
pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) {
|
|
if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
|
|
room.update(cx, |room, cx| room.toggle_deafen(cx));
|
|
}
|
|
}
|
|
|
|
fn notification_window_options(
|
|
screen: Rc<dyn PlatformDisplay>,
|
|
window_size: Size<Pixels>,
|
|
cx: &AppContext,
|
|
) -> WindowOptions {
|
|
let notification_margin_width = DevicePixels::from(16);
|
|
let notification_margin_height = DevicePixels::from(-0) - DevicePixels::from(48);
|
|
|
|
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 + notification_margin_width,
|
|
notification_margin_height,
|
|
),
|
|
size: window_size.into(),
|
|
};
|
|
|
|
let app_id = ReleaseChannel::global(cx).app_id();
|
|
|
|
WindowOptions {
|
|
window_bounds: Some(WindowBounds::Windowed(bounds)),
|
|
titlebar: None,
|
|
focus: false,
|
|
show: true,
|
|
kind: WindowKind::PopUp,
|
|
is_movable: false,
|
|
display_id: Some(screen.id()),
|
|
window_background: WindowBackgroundAppearance::default(),
|
|
app_id: Some(app_id.to_owned()),
|
|
}
|
|
}
|