X11: Continuous Presentation (#7762)

Alternative to #7758, which doesn't involve adding a new trait method
`request_draw`.
Somehow, my whole screen goes blinking black with this when moving the
window, so not ready for landing.

Release Notes:
- N/A

---------

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
Dzmitry Malyshau 2024-02-14 12:24:12 -08:00 committed by GitHub
parent 181f556269
commit 8f7a26f397
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 78 additions and 23 deletions

View file

@ -39,10 +39,10 @@ postage.workspace = true
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.9.3"
[target.'cfg(not(target_os = "macos"))'.dependencies]
[target.'cfg(all(not(target_os = "macos")))'.dependencies]
async-trait = { workspace = true }
collections = { workspace = true, features = ["test-support"] }
gpui = { workspace = true, features = ["test-support"] }
collections = { workspace = true }
gpui = { workspace = true }
live_kit_server.workspace = true
nanoid = "0.4"

View file

@ -73,6 +73,8 @@ impl TestServer {
}
pub async fn create_room(&self, room: String) -> Result<()> {
//todo!(linux): Remove this once the cross-platform LiveKit implementation is merged
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;
let mut server_rooms = self.rooms.lock();
if server_rooms.contains_key(&room) {
@ -85,6 +87,8 @@ impl TestServer {
async fn delete_room(&self, room: String) -> Result<()> {
// TODO: clear state associated with all `Room`s.
//todo!(linux): Remove this once the cross-platform LiveKit implementation is merged
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;
let mut server_rooms = self.rooms.lock();
server_rooms
@ -94,7 +98,10 @@ impl TestServer {
}
async fn join_room(&self, token: String, client_room: Arc<Room>) -> Result<()> {
//todo!(linux): Remove this once the cross-platform LiveKit implementation is merged
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;
let claims = live_kit_server::token::validate(&token, &self.secret_key)?;
let identity = claims.sub.unwrap().to_string();
let room_name = claims.video.room.unwrap();
@ -140,6 +147,8 @@ impl TestServer {
}
async fn leave_room(&self, token: String) -> Result<()> {
//todo!(linux): Remove this once the cross-platform LiveKit implementation is merged
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;
let claims = live_kit_server::token::validate(&token, &self.secret_key)?;
let identity = claims.sub.unwrap().to_string();
@ -160,8 +169,10 @@ impl TestServer {
async fn remove_participant(&self, room_name: String, identity: String) -> Result<()> {
// TODO: clear state associated with the `Room`.
//todo!(linux): Remove this once the cross-platform LiveKit implementation is merged
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;
let mut server_rooms = self.rooms.lock();
let room = server_rooms
.get_mut(&room_name)
@ -182,6 +193,8 @@ impl TestServer {
identity: String,
permission: proto::ParticipantPermission,
) -> Result<()> {
//todo!(linux): Remove this once the cross-platform LiveKit implementation is merged
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;
let mut server_rooms = self.rooms.lock();
let room = server_rooms
@ -192,6 +205,8 @@ impl TestServer {
}
pub async fn disconnect_client(&self, client_identity: String) {
//todo!(linux): Remove this once the cross-platform LiveKit implementation is merged
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;
let mut server_rooms = self.rooms.lock();
for room in server_rooms.values_mut() {
@ -206,6 +221,8 @@ impl TestServer {
token: String,
local_track: LocalVideoTrack,
) -> Result<Sid> {
//todo!(linux): Remove this once the cross-platform LiveKit implementation is merged
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;
let claims = live_kit_server::token::validate(&token, &self.secret_key)?;
let identity = claims.sub.unwrap().to_string();
@ -259,7 +276,10 @@ impl TestServer {
token: String,
_local_track: &LocalAudioTrack,
) -> Result<Sid> {
//todo!(linux): Remove this once the cross-platform LiveKit implementation is merged
#[cfg(any(test, feature = "test-support"))]
self.executor.simulate_random_delay().await;
let claims = live_kit_server::token::validate(&token, &self.secret_key)?;
let identity = claims.sub.unwrap().to_string();
let room_name = claims.video.room.unwrap();
@ -539,8 +559,13 @@ impl Room {
pub fn display_sources(self: &Arc<Self>) -> impl Future<Output = Result<Vec<MacOSDisplay>>> {
let this = self.clone();
async move {
let server = this.test_server();
server.executor.simulate_random_delay().await;
//todo!(linux): Remove this once the cross-platform LiveKit implementation is merged
#[cfg(any(test, feature = "test-support"))]
{
let server = this.test_server();
server.executor.simulate_random_delay().await;
}
Ok(this.0.lock().display_sources.clone())
}
}