Update libcosmic/iced for advanced text rebase

This commit is contained in:
Ian Douglas Scott 2023-05-12 13:25:19 -07:00
parent 60a4a2fa63
commit 078fc31713
5 changed files with 851 additions and 557 deletions

1327
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@ calloop = "0.10.5"
cctk = { package = "cosmic-client-toolkit", git = "https://github.com/pop-os/cosmic-protocols" } cctk = { package = "cosmic-client-toolkit", git = "https://github.com/pop-os/cosmic-protocols" }
env_logger = "0.10.0" env_logger = "0.10.0"
futures-channel = "0.3.25" futures-channel = "0.3.25"
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = ["tokio", "wayland"] } libcosmic = { git = "https://github.com/pop-os/libcosmic", branch = "cosmic-advanced-text", default-features = false, features = ["tokio", "wayland"] }
tokio = "1.23.0" tokio = "1.23.0"
zbus = { version = "3.7.0", default-features = false, features = ["tokio"] } zbus = { version = "3.7.0", default-features = false, features = ["tokio"] }

View file

@ -20,7 +20,7 @@ use cosmic::{
keyboard::KeyCode, keyboard::KeyCode,
widget, Application, Command, Subscription, widget, Application, Command, Subscription,
}, },
iced_native::{ iced_runtime::{
command::platform_specific::wayland::layer_surface::{ command::platform_specific::wayland::layer_surface::{
IcedOutput, SctkLayerSurfaceSettings, IcedOutput, SctkLayerSurfaceSettings,
}, },
@ -85,7 +85,7 @@ struct LayerSurface {
#[derive(Default)] #[derive(Default)]
struct App { struct App {
max_surface_id: usize, max_surface_id: u128,
layer_surfaces: HashMap<SurfaceId, LayerSurface>, layer_surfaces: HashMap<SurfaceId, LayerSurface>,
outputs: Vec<Output>, outputs: Vec<Output>,
workspaces: Vec<Workspace>, workspaces: Vec<Workspace>,
@ -101,7 +101,7 @@ struct App {
impl App { impl App {
fn next_surface_id(&mut self) -> SurfaceId { fn next_surface_id(&mut self) -> SurfaceId {
self.max_surface_id += 1; self.max_surface_id += 1;
SurfaceId::new(self.max_surface_id) SurfaceId(self.max_surface_id)
} }
fn workspace_for_handle( fn workspace_for_handle(

View file

@ -1,52 +1,31 @@
use cosmic::iced::{self, futures::StreamExt, subscription}; use cosmic::iced::{
use futures_channel::mpsc; self,
futures::{channel::mpsc, future, SinkExt},
subscription,
};
use std::fmt::Debug; use std::fmt::Debug;
use zbus::{dbus_interface, Connection, ConnectionBuilder}; use zbus::{dbus_interface, ConnectionBuilder};
pub fn subscription() -> iced::Subscription<Event> { pub fn subscription() -> iced::Subscription<Event> {
subscription::unfold("workspaces-dbus", State::Ready, move |state| { subscription::channel("workspaces-dbus", 64, move |sender| async {
start_listening(state) if let Some(conn) = ConnectionBuilder::session()
}) .ok()
} .and_then(|conn| conn.name("com.system76.CosmicWorkspaces").ok())
.and_then(|conn| {
#[derive(Debug)] conn.serve_at(
enum State { "/com/system76/CosmicWorkspaces",
Ready, CosmicWorkspacesServer { sender },
Waiting(Connection, mpsc::UnboundedReceiver<Event>), )
Finished,
}
async fn start_listening(state: State) -> (Option<Event>, State) {
match state {
State::Ready => {
let (tx, rx) = mpsc::unbounded();
if let Some(conn) = ConnectionBuilder::session()
.ok() .ok()
.and_then(|conn| conn.name("com.system76.CosmicWorkspaces").ok()) })
.and_then(|conn| { .map(|conn| conn.build())
conn.serve_at( {
"/com/system76/CosmicWorkspaces", let _conn = conn.await;
CosmicWorkspacesServer { tx }, future::pending().await
) } else {
.ok() future::pending().await
})
.map(|conn| conn.build())
{
if let Ok(conn) = conn.await {
return (None, State::Waiting(conn, rx));
}
}
(None, State::Finished)
} }
State::Waiting(conn, mut rx) => { })
if let Some(Event::Toggle) = rx.next().await {
(Some(Event::Toggle), State::Waiting(conn, rx))
} else {
(None, State::Finished)
}
}
State::Finished => iced::futures::future::pending().await,
}
} }
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
@ -56,12 +35,12 @@ pub enum Event {
#[derive(Debug)] #[derive(Debug)]
struct CosmicWorkspacesServer { struct CosmicWorkspacesServer {
tx: mpsc::UnboundedSender<Event>, sender: mpsc::Sender<Event>,
} }
#[dbus_interface(name = "com.system76.CosmicWorkspaces")] #[dbus_interface(name = "com.system76.CosmicWorkspaces")]
impl CosmicWorkspacesServer { impl CosmicWorkspacesServer {
async fn toggle(&self) { async fn toggle(&self) {
self.tx.unbounded_send(Event::Toggle).unwrap(); self.sender.clone().send(Event::Toggle).await.unwrap();
} }
} }

View file

@ -82,7 +82,7 @@ pub enum Event {
} }
pub fn subscription() -> iced::Subscription<Event> { pub fn subscription() -> iced::Subscription<Event> {
iced::subscription::run("wayland-sub", async { start() }.flatten_stream()) iced::subscription::run_with_id("wayland-sub", async { start() }.flatten_stream())
} }
#[derive(Debug)] #[derive(Debug)]