Simplify livekit config so that cargo check Just Works (#21661)
Supersedes https://github.com/zed-industries/zed/pull/21653 This enables us to use `cargo test -p workspace` on macOS and Linux. Note that the line diffs in `shared_screen.rs` are spurious, I just re-ordered the `macos` and `cross-platform` modules to match the order in the call crate. Release Notes: - N/A
This commit is contained in:
parent
7d80d1208c
commit
de939e718a
11 changed files with 345 additions and 327 deletions
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
|
@ -129,8 +129,9 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cargo build --workspace --bins --all-features
|
cargo build --workspace --bins --all-features
|
||||||
cargo check -p gpui --features "macos-blade"
|
cargo check -p gpui --features "macos-blade"
|
||||||
cargo check -p workspace --features "livekit-cross-platform"
|
cargo check -p workspace
|
||||||
cargo build -p remote_server
|
cargo build -p remote_server
|
||||||
|
script/check-rust-livekit-macos
|
||||||
|
|
||||||
linux_tests:
|
linux_tests:
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
|
@ -162,8 +163,10 @@ jobs:
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
uses: ./.github/actions/run_tests
|
uses: ./.github/actions/run_tests
|
||||||
|
|
||||||
- name: Build Zed
|
- name: Build other binaries and features
|
||||||
run: cargo build -p zed
|
run: |
|
||||||
|
cargo build -p zed
|
||||||
|
cargo check -p workspace
|
||||||
|
|
||||||
build_remote_server:
|
build_remote_server:
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
|
|
|
@ -21,8 +21,6 @@ test-support = [
|
||||||
"project/test-support",
|
"project/test-support",
|
||||||
"util/test-support"
|
"util/test-support"
|
||||||
]
|
]
|
||||||
livekit-macos = ["livekit_client_macos"]
|
|
||||||
livekit-cross-platform = ["livekit_client"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
@ -42,8 +40,12 @@ serde.workspace = true
|
||||||
serde_derive.workspace = true
|
serde_derive.workspace = true
|
||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
livekit_client_macos = { workspace = true, optional = true }
|
|
||||||
livekit_client = { workspace = true, optional = true }
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
|
livekit_client_macos = { workspace = true }
|
||||||
|
|
||||||
|
[target.'cfg(not(target_os = "macos"))'.dependencies]
|
||||||
|
livekit_client = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
client = { workspace = true, features = ["test-support"] }
|
client = { workspace = true, features = ["test-support"] }
|
||||||
|
|
|
@ -1,41 +1,13 @@
|
||||||
pub mod call_settings;
|
pub mod call_settings;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(target_os = "macos")]
|
||||||
all(target_os = "macos", feature = "livekit-macos"),
|
|
||||||
all(
|
|
||||||
not(target_os = "macos"),
|
|
||||||
feature = "livekit-macos",
|
|
||||||
not(feature = "livekit-cross-platform")
|
|
||||||
)
|
|
||||||
))]
|
|
||||||
mod macos;
|
mod macos;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(target_os = "macos")]
|
||||||
all(target_os = "macos", feature = "livekit-macos"),
|
|
||||||
all(
|
|
||||||
not(target_os = "macos"),
|
|
||||||
feature = "livekit-macos",
|
|
||||||
not(feature = "livekit-cross-platform")
|
|
||||||
)
|
|
||||||
))]
|
|
||||||
pub use macos::*;
|
pub use macos::*;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(not(target_os = "macos"))]
|
||||||
all(
|
|
||||||
target_os = "macos",
|
|
||||||
feature = "livekit-cross-platform",
|
|
||||||
not(feature = "livekit-macos"),
|
|
||||||
),
|
|
||||||
all(not(target_os = "macos"), feature = "livekit-cross-platform"),
|
|
||||||
))]
|
|
||||||
mod cross_platform;
|
mod cross_platform;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(not(target_os = "macos"))]
|
||||||
all(
|
|
||||||
target_os = "macos",
|
|
||||||
feature = "livekit-cross-platform",
|
|
||||||
not(feature = "livekit-macos"),
|
|
||||||
),
|
|
||||||
all(not(target_os = "macos"), feature = "livekit-cross-platform"),
|
|
||||||
))]
|
|
||||||
pub use cross_platform::*;
|
pub use cross_platform::*;
|
||||||
|
|
|
@ -24,8 +24,6 @@ test-support = [
|
||||||
"gpui/test-support",
|
"gpui/test-support",
|
||||||
"fs/test-support",
|
"fs/test-support",
|
||||||
]
|
]
|
||||||
livekit-macos = ["call/livekit-macos"]
|
|
||||||
livekit-cross-platform = ["call/livekit-cross-platform"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
|
|
@ -1,282 +1,11 @@
|
||||||
#[cfg(any(
|
#[cfg(target_os = "macos")]
|
||||||
all(
|
mod macos;
|
||||||
target_os = "macos",
|
|
||||||
feature = "livekit-cross-platform",
|
|
||||||
not(feature = "livekit-macos"),
|
|
||||||
),
|
|
||||||
all(not(target_os = "macos"), feature = "livekit-cross-platform"),
|
|
||||||
))]
|
|
||||||
mod cross_platform {
|
|
||||||
use crate::{
|
|
||||||
item::{Item, ItemEvent},
|
|
||||||
ItemNavHistory, WorkspaceId,
|
|
||||||
};
|
|
||||||
use call::{RemoteVideoTrack, RemoteVideoTrackView};
|
|
||||||
use client::{proto::PeerId, User};
|
|
||||||
use gpui::{
|
|
||||||
div, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement,
|
|
||||||
ParentElement, Render, SharedString, Styled, View, ViewContext, VisualContext,
|
|
||||||
WindowContext,
|
|
||||||
};
|
|
||||||
use std::sync::Arc;
|
|
||||||
use ui::{prelude::*, Icon, IconName};
|
|
||||||
|
|
||||||
pub enum Event {
|
#[cfg(target_os = "macos")]
|
||||||
Close,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct SharedScreen {
|
|
||||||
pub peer_id: PeerId,
|
|
||||||
user: Arc<User>,
|
|
||||||
nav_history: Option<ItemNavHistory>,
|
|
||||||
view: View<RemoteVideoTrackView>,
|
|
||||||
focus: FocusHandle,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SharedScreen {
|
|
||||||
pub fn new(
|
|
||||||
track: RemoteVideoTrack,
|
|
||||||
peer_id: PeerId,
|
|
||||||
user: Arc<User>,
|
|
||||||
cx: &mut ViewContext<Self>,
|
|
||||||
) -> Self {
|
|
||||||
let view = cx.new_view(|cx| RemoteVideoTrackView::new(track.clone(), cx));
|
|
||||||
cx.subscribe(&view, |_, _, ev, cx| match ev {
|
|
||||||
call::RemoteVideoTrackViewEvent::Close => cx.emit(Event::Close),
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
Self {
|
|
||||||
view,
|
|
||||||
peer_id,
|
|
||||||
user,
|
|
||||||
nav_history: Default::default(),
|
|
||||||
focus: cx.focus_handle(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EventEmitter<Event> for SharedScreen {}
|
|
||||||
|
|
||||||
impl FocusableView for SharedScreen {
|
|
||||||
fn focus_handle(&self, _: &AppContext) -> FocusHandle {
|
|
||||||
self.focus.clone()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Render for SharedScreen {
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
|
||||||
div()
|
|
||||||
.bg(cx.theme().colors().editor_background)
|
|
||||||
.track_focus(&self.focus)
|
|
||||||
.key_context("SharedScreen")
|
|
||||||
.size_full()
|
|
||||||
.child(self.view.clone())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Item for SharedScreen {
|
|
||||||
type Event = Event;
|
|
||||||
|
|
||||||
fn tab_tooltip_text(&self, _: &AppContext) -> Option<SharedString> {
|
|
||||||
Some(format!("{}'s screen", self.user.github_login).into())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn deactivated(&mut self, cx: &mut ViewContext<Self>) {
|
|
||||||
if let Some(nav_history) = self.nav_history.as_mut() {
|
|
||||||
nav_history.push::<()>(None, cx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {
|
|
||||||
Some(Icon::new(IconName::Screen))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tab_content_text(&self, _cx: &WindowContext) -> Option<SharedString> {
|
|
||||||
Some(format!("{}'s screen", self.user.github_login).into())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn telemetry_event_text(&self) -> Option<&'static str> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {
|
|
||||||
self.nav_history = Some(history);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn clone_on_split(
|
|
||||||
&self,
|
|
||||||
_workspace_id: Option<WorkspaceId>,
|
|
||||||
cx: &mut ViewContext<Self>,
|
|
||||||
) -> Option<View<Self>> {
|
|
||||||
Some(cx.new_view(|cx| Self {
|
|
||||||
view: self.view.update(cx, |view, cx| view.clone(cx)),
|
|
||||||
peer_id: self.peer_id,
|
|
||||||
user: self.user.clone(),
|
|
||||||
nav_history: Default::default(),
|
|
||||||
focus: cx.focus_handle(),
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) {
|
|
||||||
match event {
|
|
||||||
Event::Close => f(ItemEvent::CloseItem),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(
|
|
||||||
all(
|
|
||||||
target_os = "macos",
|
|
||||||
feature = "livekit-cross-platform",
|
|
||||||
not(feature = "livekit-macos"),
|
|
||||||
),
|
|
||||||
all(not(target_os = "macos"), feature = "livekit-cross-platform"),
|
|
||||||
))]
|
|
||||||
pub use cross_platform::*;
|
|
||||||
|
|
||||||
#[cfg(any(
|
|
||||||
all(target_os = "macos", feature = "livekit-macos"),
|
|
||||||
all(
|
|
||||||
not(target_os = "macos"),
|
|
||||||
feature = "livekit-macos",
|
|
||||||
not(feature = "livekit-cross-platform")
|
|
||||||
)
|
|
||||||
))]
|
|
||||||
mod macos {
|
|
||||||
use crate::{
|
|
||||||
item::{Item, ItemEvent},
|
|
||||||
ItemNavHistory, WorkspaceId,
|
|
||||||
};
|
|
||||||
use anyhow::Result;
|
|
||||||
use call::participant::{Frame, RemoteVideoTrack};
|
|
||||||
use client::{proto::PeerId, User};
|
|
||||||
use futures::StreamExt;
|
|
||||||
use gpui::{
|
|
||||||
div, surface, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement,
|
|
||||||
ParentElement, Render, SharedString, Styled, Task, View, ViewContext, VisualContext,
|
|
||||||
WindowContext,
|
|
||||||
};
|
|
||||||
use std::sync::{Arc, Weak};
|
|
||||||
use ui::{prelude::*, Icon, IconName};
|
|
||||||
|
|
||||||
pub enum Event {
|
|
||||||
Close,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct SharedScreen {
|
|
||||||
track: Weak<RemoteVideoTrack>,
|
|
||||||
frame: Option<Frame>,
|
|
||||||
pub peer_id: PeerId,
|
|
||||||
user: Arc<User>,
|
|
||||||
nav_history: Option<ItemNavHistory>,
|
|
||||||
_maintain_frame: Task<Result<()>>,
|
|
||||||
focus: FocusHandle,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SharedScreen {
|
|
||||||
pub fn new(
|
|
||||||
track: Arc<RemoteVideoTrack>,
|
|
||||||
peer_id: PeerId,
|
|
||||||
user: Arc<User>,
|
|
||||||
cx: &mut ViewContext<Self>,
|
|
||||||
) -> Self {
|
|
||||||
cx.focus_handle();
|
|
||||||
let mut frames = track.frames();
|
|
||||||
Self {
|
|
||||||
track: Arc::downgrade(&track),
|
|
||||||
frame: None,
|
|
||||||
peer_id,
|
|
||||||
user,
|
|
||||||
nav_history: Default::default(),
|
|
||||||
_maintain_frame: cx.spawn(|this, mut cx| async move {
|
|
||||||
while let Some(frame) = frames.next().await {
|
|
||||||
this.update(&mut cx, |this, cx| {
|
|
||||||
this.frame = Some(frame);
|
|
||||||
cx.notify();
|
|
||||||
})?;
|
|
||||||
}
|
|
||||||
this.update(&mut cx, |_, cx| cx.emit(Event::Close))?;
|
|
||||||
Ok(())
|
|
||||||
}),
|
|
||||||
focus: cx.focus_handle(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EventEmitter<Event> for SharedScreen {}
|
|
||||||
|
|
||||||
impl FocusableView for SharedScreen {
|
|
||||||
fn focus_handle(&self, _: &AppContext) -> FocusHandle {
|
|
||||||
self.focus.clone()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Render for SharedScreen {
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
|
||||||
div()
|
|
||||||
.bg(cx.theme().colors().editor_background)
|
|
||||||
.track_focus(&self.focus)
|
|
||||||
.key_context("SharedScreen")
|
|
||||||
.size_full()
|
|
||||||
.children(
|
|
||||||
self.frame
|
|
||||||
.as_ref()
|
|
||||||
.map(|frame| surface(frame.image()).size_full()),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Item for SharedScreen {
|
|
||||||
type Event = Event;
|
|
||||||
|
|
||||||
fn tab_tooltip_text(&self, _: &AppContext) -> Option<SharedString> {
|
|
||||||
Some(format!("{}'s screen", self.user.github_login).into())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn deactivated(&mut self, cx: &mut ViewContext<Self>) {
|
|
||||||
if let Some(nav_history) = self.nav_history.as_mut() {
|
|
||||||
nav_history.push::<()>(None, cx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {
|
|
||||||
Some(Icon::new(IconName::Screen))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tab_content_text(&self, _cx: &WindowContext) -> Option<SharedString> {
|
|
||||||
Some(format!("{}'s screen", self.user.github_login).into())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn telemetry_event_text(&self) -> Option<&'static str> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {
|
|
||||||
self.nav_history = Some(history);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn clone_on_split(
|
|
||||||
&self,
|
|
||||||
_workspace_id: Option<WorkspaceId>,
|
|
||||||
cx: &mut ViewContext<Self>,
|
|
||||||
) -> Option<View<Self>> {
|
|
||||||
let track = self.track.upgrade()?;
|
|
||||||
Some(cx.new_view(|cx| Self::new(track, self.peer_id, self.user.clone(), cx)))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) {
|
|
||||||
match event {
|
|
||||||
Event::Close => f(ItemEvent::CloseItem),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(
|
|
||||||
all(target_os = "macos", feature = "livekit-macos"),
|
|
||||||
all(
|
|
||||||
not(target_os = "macos"),
|
|
||||||
feature = "livekit-macos",
|
|
||||||
not(feature = "livekit-cross-platform")
|
|
||||||
)
|
|
||||||
))]
|
|
||||||
pub use macos::*;
|
pub use macos::*;
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
mod cross_platform;
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
pub use cross_platform::*;
|
||||||
|
|
114
crates/workspace/src/shared_screen/cross_platform.rs
Normal file
114
crates/workspace/src/shared_screen/cross_platform.rs
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
use crate::{
|
||||||
|
item::{Item, ItemEvent},
|
||||||
|
ItemNavHistory, WorkspaceId,
|
||||||
|
};
|
||||||
|
use call::{RemoteVideoTrack, RemoteVideoTrackView};
|
||||||
|
use client::{proto::PeerId, User};
|
||||||
|
use gpui::{
|
||||||
|
div, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement, ParentElement,
|
||||||
|
Render, SharedString, Styled, View, ViewContext, VisualContext, WindowContext,
|
||||||
|
};
|
||||||
|
use std::sync::Arc;
|
||||||
|
use ui::{prelude::*, Icon, IconName};
|
||||||
|
|
||||||
|
pub enum Event {
|
||||||
|
Close,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SharedScreen {
|
||||||
|
pub peer_id: PeerId,
|
||||||
|
user: Arc<User>,
|
||||||
|
nav_history: Option<ItemNavHistory>,
|
||||||
|
view: View<RemoteVideoTrackView>,
|
||||||
|
focus: FocusHandle,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SharedScreen {
|
||||||
|
pub fn new(
|
||||||
|
track: RemoteVideoTrack,
|
||||||
|
peer_id: PeerId,
|
||||||
|
user: Arc<User>,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) -> Self {
|
||||||
|
let view = cx.new_view(|cx| RemoteVideoTrackView::new(track.clone(), cx));
|
||||||
|
cx.subscribe(&view, |_, _, ev, cx| match ev {
|
||||||
|
call::RemoteVideoTrackViewEvent::Close => cx.emit(Event::Close),
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
Self {
|
||||||
|
view,
|
||||||
|
peer_id,
|
||||||
|
user,
|
||||||
|
nav_history: Default::default(),
|
||||||
|
focus: cx.focus_handle(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EventEmitter<Event> for SharedScreen {}
|
||||||
|
|
||||||
|
impl FocusableView for SharedScreen {
|
||||||
|
fn focus_handle(&self, _: &AppContext) -> FocusHandle {
|
||||||
|
self.focus.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Render for SharedScreen {
|
||||||
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||||
|
div()
|
||||||
|
.bg(cx.theme().colors().editor_background)
|
||||||
|
.track_focus(&self.focus)
|
||||||
|
.key_context("SharedScreen")
|
||||||
|
.size_full()
|
||||||
|
.child(self.view.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Item for SharedScreen {
|
||||||
|
type Event = Event;
|
||||||
|
|
||||||
|
fn tab_tooltip_text(&self, _: &AppContext) -> Option<SharedString> {
|
||||||
|
Some(format!("{}'s screen", self.user.github_login).into())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn deactivated(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
if let Some(nav_history) = self.nav_history.as_mut() {
|
||||||
|
nav_history.push::<()>(None, cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {
|
||||||
|
Some(Icon::new(IconName::Screen))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tab_content_text(&self, _cx: &WindowContext) -> Option<SharedString> {
|
||||||
|
Some(format!("{}'s screen", self.user.github_login).into())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn telemetry_event_text(&self) -> Option<&'static str> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {
|
||||||
|
self.nav_history = Some(history);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clone_on_split(
|
||||||
|
&self,
|
||||||
|
_workspace_id: Option<WorkspaceId>,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) -> Option<View<Self>> {
|
||||||
|
Some(cx.new_view(|cx| Self {
|
||||||
|
view: self.view.update(cx, |view, cx| view.clone(cx)),
|
||||||
|
peer_id: self.peer_id,
|
||||||
|
user: self.user.clone(),
|
||||||
|
nav_history: Default::default(),
|
||||||
|
focus: cx.focus_handle(),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) {
|
||||||
|
match event {
|
||||||
|
Event::Close => f(ItemEvent::CloseItem),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
126
crates/workspace/src/shared_screen/macos.rs
Normal file
126
crates/workspace/src/shared_screen/macos.rs
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
use crate::{
|
||||||
|
item::{Item, ItemEvent},
|
||||||
|
ItemNavHistory, WorkspaceId,
|
||||||
|
};
|
||||||
|
use anyhow::Result;
|
||||||
|
use call::participant::{Frame, RemoteVideoTrack};
|
||||||
|
use client::{proto::PeerId, User};
|
||||||
|
use futures::StreamExt;
|
||||||
|
use gpui::{
|
||||||
|
div, surface, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement,
|
||||||
|
ParentElement, Render, SharedString, Styled, Task, View, ViewContext, VisualContext,
|
||||||
|
WindowContext,
|
||||||
|
};
|
||||||
|
use std::sync::{Arc, Weak};
|
||||||
|
use ui::{prelude::*, Icon, IconName};
|
||||||
|
|
||||||
|
pub enum Event {
|
||||||
|
Close,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SharedScreen {
|
||||||
|
track: Weak<RemoteVideoTrack>,
|
||||||
|
frame: Option<Frame>,
|
||||||
|
pub peer_id: PeerId,
|
||||||
|
user: Arc<User>,
|
||||||
|
nav_history: Option<ItemNavHistory>,
|
||||||
|
_maintain_frame: Task<Result<()>>,
|
||||||
|
focus: FocusHandle,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SharedScreen {
|
||||||
|
pub fn new(
|
||||||
|
track: Arc<RemoteVideoTrack>,
|
||||||
|
peer_id: PeerId,
|
||||||
|
user: Arc<User>,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) -> Self {
|
||||||
|
cx.focus_handle();
|
||||||
|
let mut frames = track.frames();
|
||||||
|
Self {
|
||||||
|
track: Arc::downgrade(&track),
|
||||||
|
frame: None,
|
||||||
|
peer_id,
|
||||||
|
user,
|
||||||
|
nav_history: Default::default(),
|
||||||
|
_maintain_frame: cx.spawn(|this, mut cx| async move {
|
||||||
|
while let Some(frame) = frames.next().await {
|
||||||
|
this.update(&mut cx, |this, cx| {
|
||||||
|
this.frame = Some(frame);
|
||||||
|
cx.notify();
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
this.update(&mut cx, |_, cx| cx.emit(Event::Close))?;
|
||||||
|
Ok(())
|
||||||
|
}),
|
||||||
|
focus: cx.focus_handle(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EventEmitter<Event> for SharedScreen {}
|
||||||
|
|
||||||
|
impl FocusableView for SharedScreen {
|
||||||
|
fn focus_handle(&self, _: &AppContext) -> FocusHandle {
|
||||||
|
self.focus.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Render for SharedScreen {
|
||||||
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||||
|
div()
|
||||||
|
.bg(cx.theme().colors().editor_background)
|
||||||
|
.track_focus(&self.focus)
|
||||||
|
.key_context("SharedScreen")
|
||||||
|
.size_full()
|
||||||
|
.children(
|
||||||
|
self.frame
|
||||||
|
.as_ref()
|
||||||
|
.map(|frame| surface(frame.image()).size_full()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Item for SharedScreen {
|
||||||
|
type Event = Event;
|
||||||
|
|
||||||
|
fn tab_tooltip_text(&self, _: &AppContext) -> Option<SharedString> {
|
||||||
|
Some(format!("{}'s screen", self.user.github_login).into())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn deactivated(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
if let Some(nav_history) = self.nav_history.as_mut() {
|
||||||
|
nav_history.push::<()>(None, cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {
|
||||||
|
Some(Icon::new(IconName::Screen))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tab_content_text(&self, _cx: &WindowContext) -> Option<SharedString> {
|
||||||
|
Some(format!("{}'s screen", self.user.github_login).into())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn telemetry_event_text(&self) -> Option<&'static str> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {
|
||||||
|
self.nav_history = Some(history);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clone_on_split(
|
||||||
|
&self,
|
||||||
|
_workspace_id: Option<WorkspaceId>,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) -> Option<View<Self>> {
|
||||||
|
let track = self.track.upgrade()?;
|
||||||
|
Some(cx.new_view(|cx| Self::new(track, self.peer_id, self.user.clone(), cx)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) {
|
||||||
|
match event {
|
||||||
|
Event::Close => f(ItemEvent::CloseItem),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -127,12 +127,6 @@ welcome.workspace = true
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
zed_actions.workspace = true
|
zed_actions.workspace = true
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
|
||||||
workspace = { workspace = true, features = ["livekit-macos"] }
|
|
||||||
|
|
||||||
[target.'cfg(not(target_os = "macos"))'.dependencies]
|
|
||||||
workspace = { workspace = true, features = ["livekit-cross-platform"] }
|
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
windows.workspace = true
|
windows.workspace = true
|
||||||
|
|
||||||
|
|
19
script/check-rust-livekit-macos
Executable file
19
script/check-rust-livekit-macos
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
set -exuo pipefail
|
||||||
|
|
||||||
|
git apply script/patches/use-cross-platform-livekit.patch
|
||||||
|
|
||||||
|
# Re-enable error skipping for this check, so that we can unapply the patch
|
||||||
|
set +e
|
||||||
|
|
||||||
|
cargo check -p workspace
|
||||||
|
exit_code=$?
|
||||||
|
|
||||||
|
# Disable error skipping again
|
||||||
|
set -e
|
||||||
|
|
||||||
|
git apply -R script/patches/use-cross-platform-livekit.patch
|
||||||
|
|
||||||
|
exit "$exit_code"
|
59
script/patches/use-cross-platform-livekit.patch
Normal file
59
script/patches/use-cross-platform-livekit.patch
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
diff --git a/crates/call/Cargo.toml b/crates/call/Cargo.toml
|
||||||
|
index 9ba10e56ba..bb69440691 100644
|
||||||
|
--- a/crates/call/Cargo.toml
|
||||||
|
+++ b/crates/call/Cargo.toml
|
||||||
|
@@ -41,10 +41,10 @@ serde_derive.workspace = true
|
||||||
|
settings.workspace = true
|
||||||
|
util.workspace = true
|
||||||
|
|
||||||
|
-[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
|
+[target.'cfg(any())'.dependencies]
|
||||||
|
livekit_client_macos = { workspace = true }
|
||||||
|
|
||||||
|
-[target.'cfg(not(target_os = "macos"))'.dependencies]
|
||||||
|
+[target.'cfg(all())'.dependencies]
|
||||||
|
livekit_client = { workspace = true }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
diff --git a/crates/call/src/call.rs b/crates/call/src/call.rs
|
||||||
|
index 5e212d35b7..a8f9e8f43e 100644
|
||||||
|
--- a/crates/call/src/call.rs
|
||||||
|
+++ b/crates/call/src/call.rs
|
||||||
|
@@ -1,13 +1,13 @@
|
||||||
|
pub mod call_settings;
|
||||||
|
|
||||||
|
-#[cfg(target_os = "macos")]
|
||||||
|
+#[cfg(any())]
|
||||||
|
mod macos;
|
||||||
|
|
||||||
|
-#[cfg(target_os = "macos")]
|
||||||
|
+#[cfg(any())]
|
||||||
|
pub use macos::*;
|
||||||
|
|
||||||
|
-#[cfg(not(target_os = "macos"))]
|
||||||
|
+#[cfg(all())]
|
||||||
|
mod cross_platform;
|
||||||
|
|
||||||
|
-#[cfg(not(target_os = "macos"))]
|
||||||
|
+#[cfg(all())]
|
||||||
|
pub use cross_platform::*;
|
||||||
|
diff --git a/crates/workspace/src/shared_screen.rs b/crates/workspace/src/shared_screen.rs
|
||||||
|
index 1d17cfa145..f845234987 100644
|
||||||
|
--- a/crates/workspace/src/shared_screen.rs
|
||||||
|
+++ b/crates/workspace/src/shared_screen.rs
|
||||||
|
@@ -1,11 +1,11 @@
|
||||||
|
-#[cfg(target_os = "macos")]
|
||||||
|
+#[cfg(any())]
|
||||||
|
mod macos;
|
||||||
|
|
||||||
|
-#[cfg(target_os = "macos")]
|
||||||
|
+#[cfg(any())]
|
||||||
|
pub use macos::*;
|
||||||
|
|
||||||
|
-#[cfg(not(target_os = "macos"))]
|
||||||
|
+#[cfg(all())]
|
||||||
|
mod cross_platform;
|
||||||
|
|
||||||
|
-#[cfg(not(target_os = "macos"))]
|
||||||
|
+#[cfg(all())]
|
||||||
|
pub use cross_platform::*;
|
|
@ -43,6 +43,8 @@ extend-exclude = [
|
||||||
"docs/theme/css/",
|
"docs/theme/css/",
|
||||||
# Spellcheck triggers on `|Fixe[sd]|` regex part.
|
# Spellcheck triggers on `|Fixe[sd]|` regex part.
|
||||||
"script/danger/dangerfile.ts",
|
"script/danger/dangerfile.ts",
|
||||||
|
# Hashes are not typos
|
||||||
|
"script/patches/use-cross-platform-livekit.patch"
|
||||||
]
|
]
|
||||||
|
|
||||||
[default]
|
[default]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue