1pub mod channel_view;
2pub mod chat_panel;
3pub mod collab_panel;
4mod collab_titlebar_item;
5mod face_pile;
6pub mod notification_panel;
7pub mod notifications;
8mod panel_settings;
9
10use std::{rc::Rc, sync::Arc};
11
12use call::{report_call_event_for_room, ActiveCall};
13pub use collab_panel::CollabPanel;
14pub use collab_titlebar_item::CollabTitlebarItem;
15use gpui::{
16 actions, point, AppContext, Pixels, PlatformDisplay, Size, Task, WindowBackgroundAppearance,
17 WindowBounds, WindowContext, WindowKind, WindowOptions,
18};
19use panel_settings::MessageEditorSettings;
20pub use panel_settings::{
21 ChatPanelSettings, CollaborationPanelSettings, NotificationPanelSettings,
22};
23use release_channel::ReleaseChannel;
24use settings::Settings;
25use ui::px;
26use workspace::{notifications::DetachAndPromptErr, AppState};
27
28actions!(
29 collab,
30 [ToggleScreenSharing, ToggleMute, ToggleDeafen, LeaveCall]
31);
32
33pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
34 CollaborationPanelSettings::register(cx);
35 ChatPanelSettings::register(cx);
36 NotificationPanelSettings::register(cx);
37 MessageEditorSettings::register(cx);
38
39 vcs_menu::init(cx);
40 collab_titlebar_item::init(cx);
41 collab_panel::init(cx);
42 channel_view::init(cx);
43 chat_panel::init(cx);
44 notification_panel::init(cx);
45 notifications::init(&app_state, cx);
46}
47
48pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut WindowContext) {
49 let call = ActiveCall::global(cx).read(cx);
50 if let Some(room) = call.room().cloned() {
51 let client = call.client();
52 let toggle_screen_sharing = room.update(cx, |room, cx| {
53 if room.is_screen_sharing() {
54 report_call_event_for_room(
55 "disable screen share",
56 room.id(),
57 room.channel_id(),
58 &client,
59 );
60 Task::ready(room.unshare_screen(cx))
61 } else {
62 report_call_event_for_room(
63 "enable screen share",
64 room.id(),
65 room.channel_id(),
66 &client,
67 );
68 room.share_screen(cx)
69 }
70 });
71 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)));
72 }
73}
74
75pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
76 let call = ActiveCall::global(cx).read(cx);
77 if let Some(room) = call.room().cloned() {
78 let client = call.client();
79 room.update(cx, |room, cx| {
80 let operation = if room.is_muted() {
81 "enable microphone"
82 } else {
83 "disable microphone"
84 };
85 report_call_event_for_room(operation, room.id(), room.channel_id(), &client);
86
87 room.toggle_mute(cx)
88 });
89 }
90}
91
92pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) {
93 if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
94 room.update(cx, |room, cx| room.toggle_deafen(cx));
95 }
96}
97
98fn notification_window_options(
99 screen: Rc<dyn PlatformDisplay>,
100 size: Size<Pixels>,
101 cx: &AppContext,
102) -> WindowOptions {
103 let notification_margin_width = px(16.);
104 let notification_margin_height = px(-48.);
105
106 let bounds = gpui::Bounds::<Pixels> {
107 origin: screen.bounds().upper_right()
108 - point(
109 size.width + notification_margin_width,
110 notification_margin_height,
111 ),
112 size,
113 };
114
115 let app_id = ReleaseChannel::global(cx).app_id();
116
117 WindowOptions {
118 window_bounds: Some(WindowBounds::Windowed(bounds)),
119 titlebar: None,
120 focus: false,
121 show: true,
122 kind: WindowKind::PopUp,
123 is_movable: false,
124 display_id: Some(screen.id()),
125 window_background: WindowBackgroundAppearance::default(),
126 app_id: Some(app_id.to_owned()),
127 }
128}