collab: Add screen selector (#31506)

Instead of selecting a screen to share arbitrarily, we'll now allow user
to select the screen to share. Note that sharing multiple screens at the
time is still not supported (though prolly not too far-fetched).

Related to #4666

![image](https://github.com/user-attachments/assets/1afb664f-3cdb-4e0a-bb29-9d7093d87fa5)

Release Notes:

- Added screen selector dropdown to screen share button

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
Piotr Osiewicz 2025-07-21 13:44:51 +02:00 committed by Orual
parent 823b2fd292
commit a7c8679740
No known key found for this signature in database
26 changed files with 473 additions and 145 deletions

View file

@ -144,10 +144,22 @@ pub fn init(cx: &mut App) {
if let Some(room) = room {
window.defer(cx, move |_window, cx| {
room.update(cx, |room, cx| {
if room.is_screen_sharing() {
room.unshare_screen(cx).ok();
if room.is_sharing_screen() {
room.unshare_screen(true, cx).ok();
} else {
room.share_screen(cx).detach_and_log_err(cx);
let sources = cx.screen_capture_sources();
cx.spawn(async move |room, cx| {
let sources = sources.await??;
let first = sources.into_iter().next();
if let Some(first) = first {
room.update(cx, |room, cx| room.share_screen(first, cx))?
.await
} else {
Ok(())
}
})
.detach_and_log_err(cx);
};
});
});
@ -528,10 +540,10 @@ impl CollabPanel {
project_id: project.id,
worktree_root_names: project.worktree_root_names.clone(),
host_user_id: user_id,
is_last: projects.peek().is_none() && !room.is_screen_sharing(),
is_last: projects.peek().is_none() && !room.is_sharing_screen(),
});
}
if room.is_screen_sharing() {
if room.is_sharing_screen() {
self.entries.push(ListEntry::ParticipantScreen {
peer_id: None,
is_last: true,