use glib channel
This commit is contained in:
parent
8aee896d38
commit
0d93231453
3 changed files with 10 additions and 9 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",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use gtk4::{
|
||||
gdk::Display,
|
||||
gio::{self, ApplicationFlags},
|
||||
glib,
|
||||
glib::{self, MainContext, Priority},
|
||||
prelude::*,
|
||||
CssProvider, StyleContext,
|
||||
};
|
||||
|
|
@ -57,18 +57,18 @@ fn main() {
|
|||
|
||||
app.connect_activate(|app| {
|
||||
load_css();
|
||||
let (tx, mut rx) = mpsc::channel::<State>(100);
|
||||
let (tx, mut rx) = MainContext::channel(Priority::default());
|
||||
|
||||
let wayland_tx = wayland::spawn_workspaces(tx.clone());
|
||||
let window = CosmicWorkspacesWindow::new(app);
|
||||
|
||||
TX.set(wayland_tx).unwrap();
|
||||
|
||||
let _ = glib::MainContext::default().spawn_local(async move {
|
||||
while let Some(workspace_list) = rx.recv().await {
|
||||
// TODO update the model with the new workspace list
|
||||
}
|
||||
rx.attach(None, |workspace_event| {
|
||||
dbg!(workspace_event);
|
||||
glib::prelude::Continue(true)
|
||||
});
|
||||
|
||||
window.show();
|
||||
});
|
||||
app.run();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use crate::{utils::{Activate}, wayland::generated::client::zext_workspace_manager_v1::ZextWorkspaceManagerV1};
|
||||
use std::{env, os::unix::net::UnixStream, path::PathBuf, sync::Arc};
|
||||
use gtk4::glib;
|
||||
use tokio::sync::mpsc;
|
||||
use wayland_backend::client::ObjectData;
|
||||
use wayland_client::{
|
||||
|
|
@ -37,7 +38,7 @@ use self::generated::client::{
|
|||
zext_workspace_handle_v1::{self, ZextWorkspaceHandleV1},
|
||||
};
|
||||
|
||||
pub fn spawn_workspaces(tx: mpsc::Sender<State>) -> mpsc::Sender<Activate> {
|
||||
pub fn spawn_workspaces(tx: glib::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)
|
||||
|
|
@ -80,7 +81,7 @@ pub fn spawn_workspaces(tx: mpsc::Sender<State>) -> mpsc::Sender<Activate> {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct State {
|
||||
running: bool,
|
||||
tx: mpsc::Sender<State>,
|
||||
tx: glib::Sender<State>,
|
||||
workspace_manager: Option<zext_workspace_manager_v1::ZextWorkspaceManagerV1>,
|
||||
workspace_groups: Vec<WorkspaceGroup>,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue