diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rs index 41dc41f6b5401ddded90199cbf077449d0a2f7a6..322f5d76110ee36e3cfdf26449bbec85c3d51af5 100644 --- a/crates/gpui/src/platform/linux/platform.rs +++ b/crates/gpui/src/platform/linux/platform.rs @@ -77,10 +77,8 @@ pub trait LinuxClient { #[cfg(any(feature = "wayland", feature = "x11"))] fn window_identifier( &self, - ) -> futures::channel::oneshot::Receiver> { - let (sources_tx, sources_rx) = futures::channel::oneshot::channel(); - sources_tx.send(None).ok(); - sources_rx + ) -> impl Future> + Send + 'static { + std::future::ready::>(None) } } @@ -310,10 +308,9 @@ impl Platform for P { } else { "Open File" }; - let identifier = identifier.await.ok().flatten(); let request = match ashpd::desktop::file_chooser::OpenFileRequest::default() - .identifier(identifier) + .identifier(identifier.await) .modal(true) .title(title) .accept_label(options.prompt.as_ref().map(crate::SharedString::as_str)) @@ -370,11 +367,9 @@ impl Platform for P { let suggested_name = suggested_name.map(|s| s.to_owned()); async move { - let identifier = identifier.await.ok().flatten(); - let mut request_builder = ashpd::desktop::file_chooser::SaveFileRequest::default() - .identifier(identifier) + .identifier(identifier.await) .modal(true) .title("Save File") .current_folder(directory) diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 1101c6b080bc0b8b0db334e4ac0d615e5f6971b4..f8672971ec51415ba93708f2b06be49678aa3738 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -860,23 +860,18 @@ impl LinuxClient for WaylandClient { "Wayland" } - fn window_identifier(&self) -> futures::channel::oneshot::Receiver> { - let (done_tx, done_rx) = futures::channel::oneshot::channel(); - let client_state = self.0.borrow(); - let executor = &client_state.common.foreground_executor; - - if let Some(active_window) = client_state.keyboard_focused_window.as_ref() { - let surface = active_window.surface(); - executor - .spawn(async move { - let window_identifier = ashpd::WindowIdentifier::from_wayland(&surface).await; - done_tx.send(window_identifier).ok(); - }) - .detach(); - } else { - done_tx.send(None).ok(); + fn window_identifier(&self) -> impl Future> + Send + 'static { + async fn inner(surface: Option) -> Option { + if let Some(surface) = surface { + ashpd::WindowIdentifier::from_wayland(&surface).await + } else { + None + } } - done_rx + + let client_state = self.0.borrow(); + let active_window = client_state.keyboard_focused_window.as_ref(); + inner(active_window.map(|aw| aw.surface())) } } diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index 1edd42d8f53b6ab82fc89d571d2cc77762e6b2fd..b1f1e52ae2a7789958526ff8f6d7984ee970cd8e 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -1662,19 +1662,14 @@ impl LinuxClient for X11Client { Some(handles) } - fn window_identifier(&self) -> futures::channel::oneshot::Receiver> { - let (done_tx, done_rx) = futures::channel::oneshot::channel(); + fn window_identifier(&self) -> impl Future> + Send + 'static { let state = self.0.borrow(); - if let Some(window) = state + state .keyboard_focused_window .and_then(|focused_window| state.windows.get(&focused_window)) - { - let window_identifier = WindowIdentifier::from_xid(window.window.x_window as u64); - done_tx.send(Some(window_identifier)).ok(); - } else { - done_tx.send(None).ok(); - } - done_rx + .map(|window| window.window.x_window as u64) + .map(|x_window| std::future::ready(Some(WindowIdentifier::from_xid(x_window)))) + .unwrap_or(std::future::ready(None)) } }