Update libcosmic/iced for advanced text rebase
This commit is contained in:
parent
60a4a2fa63
commit
078fc31713
5 changed files with 851 additions and 557 deletions
1327
Cargo.lock
generated
1327
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -8,7 +8,7 @@ calloop = "0.10.5"
|
|||
cctk = { package = "cosmic-client-toolkit", git = "https://github.com/pop-os/cosmic-protocols" }
|
||||
env_logger = "0.10.0"
|
||||
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"
|
||||
zbus = { version = "3.7.0", default-features = false, features = ["tokio"] }
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use cosmic::{
|
|||
keyboard::KeyCode,
|
||||
widget, Application, Command, Subscription,
|
||||
},
|
||||
iced_native::{
|
||||
iced_runtime::{
|
||||
command::platform_specific::wayland::layer_surface::{
|
||||
IcedOutput, SctkLayerSurfaceSettings,
|
||||
},
|
||||
|
|
@ -85,7 +85,7 @@ struct LayerSurface {
|
|||
|
||||
#[derive(Default)]
|
||||
struct App {
|
||||
max_surface_id: usize,
|
||||
max_surface_id: u128,
|
||||
layer_surfaces: HashMap<SurfaceId, LayerSurface>,
|
||||
outputs: Vec<Output>,
|
||||
workspaces: Vec<Workspace>,
|
||||
|
|
@ -101,7 +101,7 @@ struct App {
|
|||
impl App {
|
||||
fn next_surface_id(&mut self) -> SurfaceId {
|
||||
self.max_surface_id += 1;
|
||||
SurfaceId::new(self.max_surface_id)
|
||||
SurfaceId(self.max_surface_id)
|
||||
}
|
||||
|
||||
fn workspace_for_handle(
|
||||
|
|
|
|||
|
|
@ -1,52 +1,31 @@
|
|||
use cosmic::iced::{self, futures::StreamExt, subscription};
|
||||
use futures_channel::mpsc;
|
||||
use cosmic::iced::{
|
||||
self,
|
||||
futures::{channel::mpsc, future, SinkExt},
|
||||
subscription,
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
use zbus::{dbus_interface, Connection, ConnectionBuilder};
|
||||
use zbus::{dbus_interface, ConnectionBuilder};
|
||||
|
||||
pub fn subscription() -> iced::Subscription<Event> {
|
||||
subscription::unfold("workspaces-dbus", State::Ready, move |state| {
|
||||
start_listening(state)
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum State {
|
||||
Ready,
|
||||
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()
|
||||
subscription::channel("workspaces-dbus", 64, move |sender| async {
|
||||
if let Some(conn) = ConnectionBuilder::session()
|
||||
.ok()
|
||||
.and_then(|conn| conn.name("com.system76.CosmicWorkspaces").ok())
|
||||
.and_then(|conn| {
|
||||
conn.serve_at(
|
||||
"/com/system76/CosmicWorkspaces",
|
||||
CosmicWorkspacesServer { sender },
|
||||
)
|
||||
.ok()
|
||||
.and_then(|conn| conn.name("com.system76.CosmicWorkspaces").ok())
|
||||
.and_then(|conn| {
|
||||
conn.serve_at(
|
||||
"/com/system76/CosmicWorkspaces",
|
||||
CosmicWorkspacesServer { tx },
|
||||
)
|
||||
.ok()
|
||||
})
|
||||
.map(|conn| conn.build())
|
||||
{
|
||||
if let Ok(conn) = conn.await {
|
||||
return (None, State::Waiting(conn, rx));
|
||||
}
|
||||
}
|
||||
(None, State::Finished)
|
||||
})
|
||||
.map(|conn| conn.build())
|
||||
{
|
||||
let _conn = conn.await;
|
||||
future::pending().await
|
||||
} else {
|
||||
future::pending().await
|
||||
}
|
||||
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)]
|
||||
|
|
@ -56,12 +35,12 @@ pub enum Event {
|
|||
|
||||
#[derive(Debug)]
|
||||
struct CosmicWorkspacesServer {
|
||||
tx: mpsc::UnboundedSender<Event>,
|
||||
sender: mpsc::Sender<Event>,
|
||||
}
|
||||
|
||||
#[dbus_interface(name = "com.system76.CosmicWorkspaces")]
|
||||
impl CosmicWorkspacesServer {
|
||||
async fn toggle(&self) {
|
||||
self.tx.unbounded_send(Event::Toggle).unwrap();
|
||||
self.sender.clone().send(Event::Toggle).await.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ pub enum 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)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue