mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
Display call notifications on all screens
This commit is contained in:
parent
5a8061ac7b
commit
5984be3d84
3 changed files with 58 additions and 44 deletions
|
@ -18,34 +18,37 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||||
|
|
||||||
let mut incoming_call = ActiveCall::global(cx).read(cx).incoming();
|
let mut incoming_call = ActiveCall::global(cx).read(cx).incoming();
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
let mut notification_window = None;
|
let mut notification_windows = Vec::new();
|
||||||
while let Some(incoming_call) = incoming_call.next().await {
|
while let Some(incoming_call) = incoming_call.next().await {
|
||||||
if let Some(window_id) = notification_window.take() {
|
for window_id in notification_windows.drain(..) {
|
||||||
cx.remove_window(window_id);
|
cx.remove_window(window_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(incoming_call) = incoming_call {
|
if let Some(incoming_call) = incoming_call {
|
||||||
const PADDING: f32 = 16.;
|
const PADDING: f32 = 16.;
|
||||||
let screen_size = cx.platform().screen_size();
|
|
||||||
|
|
||||||
let window_size = cx.read(|cx| {
|
let window_size = cx.read(|cx| {
|
||||||
let theme = &cx.global::<Settings>().theme.incoming_call_notification;
|
let theme = &cx.global::<Settings>().theme.incoming_call_notification;
|
||||||
vec2f(theme.window_width, theme.window_height)
|
vec2f(theme.window_width, theme.window_height)
|
||||||
});
|
});
|
||||||
let (window_id, _) = cx.add_window(
|
|
||||||
WindowOptions {
|
for screen in cx.platform().screens() {
|
||||||
bounds: WindowBounds::Fixed(RectF::new(
|
let screen_size = screen.size();
|
||||||
vec2f(screen_size.x() - window_size.x() - PADDING, PADDING),
|
let (window_id, _) = cx.add_window(
|
||||||
window_size,
|
WindowOptions {
|
||||||
)),
|
bounds: WindowBounds::Fixed(RectF::new(
|
||||||
titlebar: None,
|
vec2f(screen_size.x() - window_size.x() - PADDING, PADDING),
|
||||||
center: false,
|
window_size,
|
||||||
kind: WindowKind::PopUp,
|
)),
|
||||||
is_movable: false,
|
titlebar: None,
|
||||||
},
|
center: false,
|
||||||
|_| IncomingCallNotification::new(incoming_call),
|
kind: WindowKind::PopUp,
|
||||||
);
|
is_movable: false,
|
||||||
notification_window = Some(window_id);
|
screen: Some(screen),
|
||||||
|
},
|
||||||
|
|_| IncomingCallNotification::new(incoming_call.clone()),
|
||||||
|
);
|
||||||
|
notification_windows.push(window_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -27,39 +27,49 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||||
worktree_root_names,
|
worktree_root_names,
|
||||||
} => {
|
} => {
|
||||||
const PADDING: f32 = 16.;
|
const PADDING: f32 = 16.;
|
||||||
let screen_size = cx.platform().screen_size();
|
|
||||||
|
|
||||||
let theme = &cx.global::<Settings>().theme.project_shared_notification;
|
let theme = &cx.global::<Settings>().theme.project_shared_notification;
|
||||||
let window_size = vec2f(theme.window_width, theme.window_height);
|
let window_size = vec2f(theme.window_width, theme.window_height);
|
||||||
let (window_id, _) = cx.add_window(
|
|
||||||
WindowOptions {
|
for screen in cx.platform().screens() {
|
||||||
bounds: WindowBounds::Fixed(RectF::new(
|
let screen_size = screen.size();
|
||||||
vec2f(screen_size.x() - window_size.x() - PADDING, PADDING),
|
let (window_id, _) = cx.add_window(
|
||||||
window_size,
|
WindowOptions {
|
||||||
)),
|
bounds: WindowBounds::Fixed(RectF::new(
|
||||||
titlebar: None,
|
vec2f(screen_size.x() - window_size.x() - PADDING, PADDING),
|
||||||
center: false,
|
window_size,
|
||||||
kind: WindowKind::PopUp,
|
)),
|
||||||
is_movable: false,
|
titlebar: None,
|
||||||
},
|
center: false,
|
||||||
|_| {
|
kind: WindowKind::PopUp,
|
||||||
ProjectSharedNotification::new(
|
is_movable: false,
|
||||||
owner.clone(),
|
screen: Some(screen),
|
||||||
*project_id,
|
},
|
||||||
worktree_root_names.clone(),
|
|_| {
|
||||||
)
|
ProjectSharedNotification::new(
|
||||||
},
|
owner.clone(),
|
||||||
);
|
*project_id,
|
||||||
notification_windows.insert(*project_id, window_id);
|
worktree_root_names.clone(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
);
|
||||||
|
notification_windows
|
||||||
|
.entry(*project_id)
|
||||||
|
.or_insert(Vec::new())
|
||||||
|
.push(window_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
room::Event::RemoteProjectUnshared { project_id } => {
|
room::Event::RemoteProjectUnshared { project_id } => {
|
||||||
if let Some(window_id) = notification_windows.remove(&project_id) {
|
if let Some(window_ids) = notification_windows.remove(&project_id) {
|
||||||
cx.remove_window(window_id);
|
for window_id in window_ids {
|
||||||
|
cx.remove_window(window_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
room::Event::Left => {
|
room::Event::Left => {
|
||||||
for (_, window_id) in notification_windows.drain() {
|
for (_, window_ids) in notification_windows.drain() {
|
||||||
cx.remove_window(window_id);
|
for window_id in window_ids {
|
||||||
|
cx.remove_window(window_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -344,6 +344,7 @@ pub fn build_window_options() -> WindowOptions<'static> {
|
||||||
center: false,
|
center: false,
|
||||||
kind: WindowKind::Normal,
|
kind: WindowKind::Normal,
|
||||||
is_movable: true,
|
is_movable: true,
|
||||||
|
screen: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue