update iced

This commit is contained in:
Ashley Wulber 2024-10-30 22:51:08 -04:00 • committed by Ashley Wulber
parent 11faa567f3
commit 5b5cd77e7c
45 changed files with 2360 additions and 1537 deletions

View file

@ -6,7 +6,12 @@
//! This code was generated by `zbus-xmlgen` `2.0.1` from DBus introspection data.
//! Source: `Interface '/org/freedesktop/UPower/KbdBacklight' from service 'org.freedesktop.UPower' on system bus`.
use cctk::{sctk::reexports::calloop, toplevel_info::ToplevelInfo};
use cosmic::{cctk, cctk::cosmic_protocols, iced, iced::subscription, iced_futures::futures};
use cosmic::{
cctk::{self, cosmic_protocols},
iced::{self, Subscription},
iced_core::image::Bytes,
iced_futures::{futures, stream},
};
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1;
use futures::{
channel::mpsc::{unbounded, UnboundedReceiver},
@ -23,16 +28,15 @@ pub static WAYLAND_RX: Lazy<Mutex<Option<UnboundedReceiver<WaylandUpdate>>>> =
Lazy::new(|| Mutex::new(None));
pub fn wayland_subscription() -> iced::Subscription<WaylandUpdate> {
subscription::channel(
Subscription::run_with_id(
std::any::TypeId::of::<WaylandUpdate>(),
50,
move |mut output| async move {
stream::channel(50, move |mut output| async move {
let mut state = State::Waiting;
loop {
state = start_listening(state, &mut output).await;
}
},
}),
)
}
@ -86,12 +90,18 @@ pub enum WaylandUpdate {
#[derive(Debug, Clone)]
pub struct WaylandImage {
pub img: Arc<image::RgbaImage>,
pub img: Bytes,
pub width: u32,
pub height: u32,
}
impl WaylandImage {
pub fn new(img: image::RgbaImage) -> Self {
Self { img: Arc::new(img) }
Self {
img: Bytes::copy_from_slice(img.as_bytes()),
width: img.width(),
height: img.height(),
}
}
}