refactor: better event types
This commit is contained in:
parent
3a41e58159
commit
c67f6fdb2d
4 changed files with 12 additions and 13 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -394,7 +394,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-panel-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/cosmic-panel/#8787823d807ea9a9d7b96ecacf017d695ba7b58a"
|
||||
source = "git+https://github.com/pop-os/cosmic-panel#8787823d807ea9a9d7b96ecacf017d695ba7b58a"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"gtk4",
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ use gtk4::{
|
|||
CssProvider, StyleContext,
|
||||
};
|
||||
use once_cell::sync::OnceCell;
|
||||
use wayland::State;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tokio::sync::mpsc;
|
||||
use utils::{Activate, WorkspaceEvent};
|
||||
use utils::{Activate};
|
||||
use window::CosmicWorkspacesWindow;
|
||||
|
||||
mod localize;
|
||||
|
|
@ -56,7 +57,7 @@ fn main() {
|
|||
|
||||
app.connect_activate(|app| {
|
||||
load_css();
|
||||
let (tx, mut rx) = mpsc::channel::<Vec<WorkspaceEvent>>(100);
|
||||
let (tx, mut rx) = mpsc::channel::<State>(100);
|
||||
|
||||
let wayland_tx = wayland::spawn_workspaces(tx.clone());
|
||||
let window = CosmicWorkspacesWindow::new(app);
|
||||
|
|
|
|||
|
|
@ -6,11 +6,6 @@ use gtk4::glib;
|
|||
use std::future::Future;
|
||||
|
||||
pub type Activate = u32;
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct WorkspaceEvent {
|
||||
pub(crate) id: u32,
|
||||
pub(crate) active: bool,
|
||||
}
|
||||
|
||||
pub fn data_path() -> PathBuf {
|
||||
let mut path = glib::user_data_dir();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::utils::{Activate, WorkspaceEvent};
|
||||
use crate::utils::{Activate};
|
||||
use std::{env, os::unix::net::UnixStream, path::PathBuf};
|
||||
use tokio::sync::mpsc;
|
||||
use wayland_client::{
|
||||
|
|
@ -36,7 +36,7 @@ use self::generated::client::{
|
|||
zext_workspace_handle_v1::{self, ZextWorkspaceHandleV1},
|
||||
};
|
||||
|
||||
pub fn spawn_workspaces(tx: mpsc::Sender<Vec<WorkspaceEvent>>) -> mpsc::Sender<Activate> {
|
||||
pub fn spawn_workspaces(tx: mpsc::Sender<State>) -> mpsc::Sender<Activate> {
|
||||
let (workspaces_tx, mut workspaces_rx) = mpsc::channel(100);
|
||||
if let Ok(Ok(conn)) = std::env::var("HOST_WAYLAND_DISPLAY")
|
||||
.map_err(anyhow::Error::msg)
|
||||
|
|
@ -76,19 +76,22 @@ pub fn spawn_workspaces(tx: mpsc::Sender<Vec<WorkspaceEvent>>) -> mpsc::Sender<A
|
|||
workspaces_tx
|
||||
}
|
||||
|
||||
struct State {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct State {
|
||||
running: bool,
|
||||
tx: mpsc::Sender<Vec<WorkspaceEvent>>,
|
||||
tx: mpsc::Sender<State>,
|
||||
workspace_manager: Option<zext_workspace_manager_v1::ZextWorkspaceManagerV1>,
|
||||
workspace_groups: Vec<WorkspaceGroup>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct WorkspaceGroup {
|
||||
workspace_group_handle: ZextWorkspaceGroupHandleV1,
|
||||
output: Option<WlOutput>,
|
||||
workspaces: Vec<Workspace>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Workspace {
|
||||
workspace_handle: ZextWorkspaceHandleV1,
|
||||
name: String,
|
||||
|
|
@ -151,7 +154,7 @@ impl Dispatch<zext_workspace_manager_v1::ZextWorkspaceManagerV1, ()> for State {
|
|||
zext_workspace_manager_v1::Event::Done => {
|
||||
// TODO
|
||||
println!("sending event with workspace list state");
|
||||
let _ = self.tx.send(Vec::new());
|
||||
let _ = self.tx.send(self.clone());
|
||||
}
|
||||
zext_workspace_manager_v1::Event::Finished => {
|
||||
self.workspace_manager.take();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue