fix: build without tokio feature

This commit is contained in:
Ashley Wulber 2025-03-11 18:32:12 -04:00
parent 4c4abd939e
commit b01f4ff422
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
3 changed files with 18 additions and 4 deletions

View file

@ -87,11 +87,19 @@ winit_wgpu = ["winit", "wgpu"]
xdg-portal = ["ashpd"] xdg-portal = ["ashpd"]
qr_code = ["iced/qr_code"] qr_code = ["iced/qr_code"]
markdown = ["iced/markdown"] markdown = ["iced/markdown"]
async-std = [
"dep:async-std",
"ashpd/async-std",
"rfd?/async-std",
"zbus?/async-io",
"iced/async-std",
]
[dependencies] [dependencies]
apply = "0.3.0" apply = "0.3.0"
ashpd = { version = "0.9.1", default-features = false, optional = true } ashpd = { version = "0.9.1", default-features = false, optional = true }
async-fs = { version = "2.1", optional = true } async-fs = { version = "2.1", optional = true }
async-std = { version = "1.10", optional = true }
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "178eb0b", optional = true } cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "178eb0b", optional = true }
chrono = "0.4.35" chrono = "0.4.35"
cosmic-config = { path = "cosmic-config" } cosmic-config = { path = "cosmic-config" }

View file

@ -1,7 +1,7 @@
use ashpd::desktop::settings::{ColorScheme, Contrast}; use ashpd::desktop::settings::{ColorScheme, Contrast};
use ashpd::desktop::Color; use ashpd::desktop::Color;
use iced::futures::{self, select, FutureExt, SinkExt, StreamExt}; use iced::futures::{self, select, FutureExt, SinkExt, StreamExt};
use iced_futures::{stream, subscription}; use iced_futures::stream;
use tracing::error; use tracing::error;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -27,7 +27,7 @@ pub fn desktop_settings() -> iced_futures::Subscription<Desktop> {
.await; .await;
#[cfg(not(feature = "tokio"))] #[cfg(not(feature = "tokio"))]
{ {
pending::<()>().await; futures::future::pending::<()>().await;
unreachable!(); unreachable!();
} }
attempts += 1; attempts += 1;

View file

@ -483,8 +483,14 @@ pub fn update<'a, Message: Clone + 'static, TopLevelMessage: Clone + 'static>(
let view = view.clone(); let view = view.clone();
let is_hovered = is_hovered.clone(); let is_hovered = is_hovered.clone();
Task::future(async move { Task::future(async move {
_ = tokio::time::sleep(delay).await; #[cfg(feature = "tokio")]
{
_ = tokio::time::sleep(delay).await;
}
#[cfg(feature = "async-std")]
{
_ = async_std::task::sleep(delay).await;
}
let is_hovered = is_hovered.clone(); let is_hovered = is_hovered.clone();
let g = is_hovered.lock().unwrap(); let g = is_hovered.lock().unwrap();
if !*g { if !*g {