libcosmic updates
This commit is contained in:
parent
9c62f19e4b
commit
0491c4baaa
91 changed files with 3550 additions and 2300 deletions
|
|
@ -1,10 +1,11 @@
|
|||
use iced::{
|
||||
futures::{
|
||||
channel::mpsc::{unbounded, UnboundedReceiver},
|
||||
StreamExt,
|
||||
stream, StreamExt,
|
||||
},
|
||||
subscription, Rectangle,
|
||||
Rectangle,
|
||||
};
|
||||
use iced_futures::Subscription;
|
||||
use std::{collections::HashMap, fmt::Debug, hash::Hash};
|
||||
|
||||
use super::RectangleTracker;
|
||||
|
|
@ -14,8 +15,11 @@ pub fn rectangle_tracker_subscription<
|
|||
R: 'static + Hash + Copy + Send + Sync + Debug + Eq,
|
||||
>(
|
||||
id: I,
|
||||
) -> iced::Subscription<(I, RectangleUpdate<R>)> {
|
||||
subscription::unfold(id, State::Ready, move |state| start_listening(id, state))
|
||||
) -> Subscription<(I, RectangleUpdate<R>)> {
|
||||
Subscription::run_with_id(
|
||||
id,
|
||||
stream::unfold(State::Ready, move |state| start_listening(id, state)),
|
||||
)
|
||||
}
|
||||
|
||||
pub enum State<I> {
|
||||
|
|
@ -27,7 +31,7 @@ pub enum State<I> {
|
|||
async fn start_listening<I: Copy, R: 'static + Hash + Copy + Send + Sync + Debug + Eq>(
|
||||
id: I,
|
||||
mut state: State<R>,
|
||||
) -> ((I, RectangleUpdate<R>), State<R>) {
|
||||
) -> Option<((I, RectangleUpdate<R>), State<R>)> {
|
||||
loop {
|
||||
let (update, new_state) = match state {
|
||||
State::Ready => {
|
||||
|
|
@ -65,11 +69,11 @@ async fn start_listening<I: Copy, R: 'static + Hash + Copy + Send + Sync + Debug
|
|||
}
|
||||
None => (None, State::Finished),
|
||||
},
|
||||
State::Finished => iced::futures::future::pending().await,
|
||||
State::Finished => return None,
|
||||
};
|
||||
state = new_state;
|
||||
if let Some(u) = update {
|
||||
return (u, state);
|
||||
return Some((u, state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue