Update to workspace v2, based on ext-workspace

In the workspace applet, this now uses `Workspace` in the front-end code
instead of a tuple with unnamed fields. Handling of scrolling is also
moved to the frontend, which uses less code and seems more natural. It
would be good to have a helper in libcosmic for this. It also changes
`ObjectId` to `ExtWorkspaceHandleV1`, which is a little simpler and I
see no reason here to avoid the more strongly typed object.

At some point we may want a shared subscription for workspaces in
multiple applets. As well as a higher-level abstraction for screen
capture.
This commit is contained in:
Ian Douglas Scott 2025-03-06 14:13:01 -08:00 committed by Ian Douglas Scott
parent f08d80a891
commit 7ba2ed0c53
12 changed files with 196 additions and 269 deletions

View file

@ -1,8 +1,8 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only
use crate::wayland::{self, WorkspaceEvent, WorkspaceList};
use cctk::sctk::reexports::calloop::channel::SyncSender;
use crate::wayland::{self, WorkspaceEvent};
use cctk::{sctk::reexports::calloop::channel::SyncSender, workspace::Workspace};
use cosmic::iced::{
self,
futures::{channel::mpsc, SinkExt, StreamExt},
@ -11,12 +11,12 @@ use cosmic::iced::{
use once_cell::sync::Lazy;
use tokio::sync::Mutex;
pub static WAYLAND_RX: Lazy<Mutex<Option<mpsc::Receiver<WorkspaceList>>>> =
pub static WAYLAND_RX: Lazy<Mutex<Option<mpsc::Receiver<Vec<Workspace>>>>> =
Lazy::new(|| Mutex::new(None));
#[derive(Debug, Clone)]
pub enum WorkspacesUpdate {
Workspaces(WorkspaceList),
Workspaces(Vec<Workspace>),
Started(SyncSender<WorkspaceEvent>),
Errored,
}
@ -71,7 +71,7 @@ pub enum State {
}
pub struct WorkspacesWatcher {
rx: mpsc::Receiver<WorkspaceList>,
rx: mpsc::Receiver<Vec<Workspace>>,
tx: SyncSender<WorkspaceEvent>,
}