diff --git a/.github/workflows/ci.pinnacle.yml b/.github/workflows/ci.pinnacle.yml index cab4467..2c0b653 100644 --- a/.github/workflows/ci.pinnacle.yml +++ b/.github/workflows/ci.pinnacle.yml @@ -55,10 +55,10 @@ jobs: uses: extractions/setup-just@v1 - name: Test if: ${{ runner.debug != '1' }} - run: just install test -- --test-threads=1 + run: just install test --no-default-features -- --test-threads=1 - name: Test (debug) if: ${{ runner.debug == '1' }} - run: RUST_LOG=debug RUST_BACKTRACE=1 just install test -- --nocapture --test-threads=1 + run: RUST_LOG=debug RUST_BACKTRACE=1 just install test --no-default-features -- --nocapture --test-threads=1 check-format: runs-on: ubuntu-24.04 name: Check formatting diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..529c900 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "snowcap"] + path = snowcap + url = https://github.com/pinnacle-comp/snowcap diff --git a/Cargo.lock b/Cargo.lock index 9945895..9d4ae9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3588,7 +3588,6 @@ dependencies = [ [[package]] name = "snowcap" version = "0.0.1" -source = "git+https://github.com/pinnacle-comp/snowcap?rev=acb0e29#acb0e29b3da3cdc9a701a6e3819afe56cce58e34" dependencies = [ "anyhow", "futures", @@ -3614,7 +3613,6 @@ dependencies = [ [[package]] name = "snowcap-api" version = "0.1.0" -source = "git+https://github.com/pinnacle-comp/snowcap?rev=acb0e29#acb0e29b3da3cdc9a701a6e3819afe56cce58e34" dependencies = [ "futures", "snowcap-api-defs", @@ -3629,7 +3627,6 @@ dependencies = [ [[package]] name = "snowcap-api-defs" version = "0.1.0" -source = "git+https://github.com/pinnacle-comp/snowcap?rev=acb0e29#acb0e29b3da3cdc9a701a6e3819afe56cce58e34" dependencies = [ "prost", "tonic", diff --git a/Cargo.toml b/Cargo.toml index e7d0b1e..71f05ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ members = [ "api/rust/pinnacle-api-macros", "wlcs_pinnacle", ] +exclude = ["snowcap"] [workspace.package] authors = ["Ottatop "] @@ -118,8 +119,8 @@ gag = "1.0.0" drm-sys = "0.7.0" libdisplay-info-sys = { git = "https://github.com/Smithay/libdisplay-info-rs", rev = "a482d0d" } indexmap = "2.2.6" -snowcap = { git = "https://github.com/pinnacle-comp/snowcap", rev = "acb0e29", optional = true } -snowcap-api = { git = "https://github.com/pinnacle-comp/snowcap", rev = "acb0e29", optional = true } +snowcap = { path = "./snowcap", optional = true } +snowcap-api = { path = "./snowcap/api/rust", optional = true } [build-dependencies] vergen = { version = "8.3.1", features = ["git", "gitcl", "rustc", "cargo", "si"] } diff --git a/api/rust/Cargo.toml b/api/rust/Cargo.toml index ae0b246..393c2b0 100644 --- a/api/rust/Cargo.toml +++ b/api/rust/Cargo.toml @@ -21,7 +21,7 @@ num_enum = "0.7.2" xkbcommon = { workspace = true } rand = "0.8.5" bitflags = { workspace = true } -snowcap-api = { git = "https://github.com/pinnacle-comp/snowcap", rev = "acb0e29", optional = true } +snowcap-api = { path = "../../snowcap/api/rust", optional = true } [features] default = ["snowcap"] diff --git a/api/rust/examples/default_config/main.rs b/api/rust/examples/default_config/main.rs index 3583069..addc8de 100644 --- a/api/rust/examples/default_config/main.rs +++ b/api/rust/examples/default_config/main.rs @@ -19,11 +19,8 @@ use snowcap_api::widget::{Alignment, Column, Container, Length, Text}; // Pinnacle needs to perform some setup before and after your config. // The `#[pinnacle_api::config(modules)]` attribute does so and // will bind all the config structs to the provided identifier. -// #[pinnacle_api::config(modules)] -#[pinnacle_api::tokio::main] +#[pinnacle_api::config(modules)] async fn main() { - let (modules, __recv) = pinnacle_api::connect().await.unwrap(); - // Deconstruct to get all the APIs. #[cfg(feature = "snowcap")] #[allow(unused_variables)] @@ -38,7 +35,7 @@ async fn main() { render, snowcap, .. - } = modules.clone(); + } = modules; #[cfg(not(feature = "snowcap"))] #[allow(unused_variables)] @@ -52,7 +49,7 @@ async fn main() { layout, render, .. - } = modules.clone(); + } = modules; let mod_key = Mod::Ctrl; @@ -314,6 +311,4 @@ async fn main() { }))); process.spawn_once([terminal]); - - pinnacle_api::listen(modules, __recv).await; } diff --git a/api/rust/src/lib.rs b/api/rust/src/lib.rs index 8c93216..df9f1a4 100644 --- a/api/rust/src/lib.rs +++ b/api/rust/src/lib.rs @@ -113,6 +113,8 @@ pub mod util; pub mod window; pub use pinnacle_api_macros::config; +#[cfg(feature = "snowcap")] +pub use snowcap_api; pub use tokio; pub use xkbcommon; diff --git a/api/rust/src/signal.rs b/api/rust/src/signal.rs index de4e8d9..cb4da5c 100644 --- a/api/rust/src/signal.rs +++ b/api/rust/src/signal.rs @@ -74,6 +74,8 @@ macro_rules! signals { .send((self.current_id, callback)) .expect("failed to send callback"); + self.callback_count.fetch_add(1, Ordering::SeqCst); + let handle = SignalHandle::new(self.current_id, remove_callback_sender); self.current_id.0 += 1; @@ -376,6 +378,10 @@ where control_sender .send(Req::from_control(StreamControl::Ready)) + .map_err(|err| { + println!("{err}"); + err + }) .expect("send failed"); loop { @@ -407,7 +413,8 @@ where callback = callback_recv_recv => { if let Some((id, callback)) = callback { callbacks.insert(id, callback); - callback_count.fetch_add(1, Ordering::SeqCst); + // Added in `add_callback` in the macro above + // callback_count.fetch_add(1, Ordering::SeqCst); } } remove = remove_callback_recv_recv => { diff --git a/snowcap b/snowcap new file mode 160000 index 0000000..81f61f7 --- /dev/null +++ b/snowcap @@ -0,0 +1 @@ +Subproject commit 81f61f7fbbec91673caf6c56df438b64eab90181 diff --git a/src/main.rs b/src/main.rs index 8397800..7085e82 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,14 @@ // #![deny(unused_imports)] // this has remained commented out for months lol #![warn(clippy::unwrap_used)] -use std::io::{BufRead, BufReader}; +use std::{ + io::{BufRead, BufReader}, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, + time::Duration, +}; use anyhow::Context; use pinnacle::{ @@ -54,7 +61,8 @@ async fn main() -> anyhow::Result<()> { .with_writer(appender) .with_filter(file_log_env_filter); - let stdout_env_filter = env_filter.unwrap_or_else(|_| EnvFilter::new("warn,pinnacle=info")); + let stdout_env_filter = + env_filter.unwrap_or_else(|_| EnvFilter::new("warn,pinnacle=info,snowcap=info")); let stdout_layer = tracing_subscriber::fmt::layer() .compact() .with_writer(std::io::stdout) @@ -175,10 +183,17 @@ async fn main() -> anyhow::Result<()> { #[cfg(feature = "snowcap")] { + info!("Starting Snowcap"); let (ping, source) = calloop::ping::make_ping()?; + let ready_flag = Arc::new(AtomicBool::new(false)); + let ready_clone = ready_flag.clone(); tokio::task::spawn_blocking(move || { - snowcap::start(Some(source)); + snowcap::start(Some(source), ready_clone); }); + while !ready_flag.load(Ordering::SeqCst) { + event_loop.dispatch(None, &mut state)?; + state.on_event_loop_cycle_completion(); + } state.pinnacle.snowcap_shutdown_ping = Some(ping); }