mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-25 09:59:21 +01:00
Wait for Snowcap to start, rust-api: Fix signals
Test with --no-default-features, add Snowcap submodule
This commit is contained in:
parent
8fd1606557
commit
df96838c51
10 changed files with 41 additions and 20 deletions
4
.github/workflows/ci.pinnacle.yml
vendored
4
.github/workflows/ci.pinnacle.yml
vendored
|
@ -55,10 +55,10 @@ jobs:
|
||||||
uses: extractions/setup-just@v1
|
uses: extractions/setup-just@v1
|
||||||
- name: Test
|
- name: Test
|
||||||
if: ${{ runner.debug != '1' }}
|
if: ${{ runner.debug != '1' }}
|
||||||
run: just install test -- --test-threads=1
|
run: just install test --no-default-features -- --test-threads=1
|
||||||
- name: Test (debug)
|
- name: Test (debug)
|
||||||
if: ${{ runner.debug == '1' }}
|
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:
|
check-format:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
name: Check formatting
|
name: Check formatting
|
||||||
|
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "snowcap"]
|
||||||
|
path = snowcap
|
||||||
|
url = https://github.com/pinnacle-comp/snowcap
|
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -3588,7 +3588,6 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "snowcap"
|
name = "snowcap"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/pinnacle-comp/snowcap?rev=acb0e29#acb0e29b3da3cdc9a701a6e3819afe56cce58e34"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"futures",
|
"futures",
|
||||||
|
@ -3614,7 +3613,6 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "snowcap-api"
|
name = "snowcap-api"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pinnacle-comp/snowcap?rev=acb0e29#acb0e29b3da3cdc9a701a6e3819afe56cce58e34"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"snowcap-api-defs",
|
"snowcap-api-defs",
|
||||||
|
@ -3629,7 +3627,6 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "snowcap-api-defs"
|
name = "snowcap-api-defs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pinnacle-comp/snowcap?rev=acb0e29#acb0e29b3da3cdc9a701a6e3819afe56cce58e34"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"prost",
|
"prost",
|
||||||
"tonic",
|
"tonic",
|
||||||
|
|
|
@ -5,6 +5,7 @@ members = [
|
||||||
"api/rust/pinnacle-api-macros",
|
"api/rust/pinnacle-api-macros",
|
||||||
"wlcs_pinnacle",
|
"wlcs_pinnacle",
|
||||||
]
|
]
|
||||||
|
exclude = ["snowcap"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
authors = ["Ottatop <ottatop1227@gmail.com>"]
|
authors = ["Ottatop <ottatop1227@gmail.com>"]
|
||||||
|
@ -118,8 +119,8 @@ gag = "1.0.0"
|
||||||
drm-sys = "0.7.0"
|
drm-sys = "0.7.0"
|
||||||
libdisplay-info-sys = { git = "https://github.com/Smithay/libdisplay-info-rs", rev = "a482d0d" }
|
libdisplay-info-sys = { git = "https://github.com/Smithay/libdisplay-info-rs", rev = "a482d0d" }
|
||||||
indexmap = "2.2.6"
|
indexmap = "2.2.6"
|
||||||
snowcap = { git = "https://github.com/pinnacle-comp/snowcap", rev = "acb0e29", optional = true }
|
snowcap = { path = "./snowcap", optional = true }
|
||||||
snowcap-api = { git = "https://github.com/pinnacle-comp/snowcap", rev = "acb0e29", optional = true }
|
snowcap-api = { path = "./snowcap/api/rust", optional = true }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
vergen = { version = "8.3.1", features = ["git", "gitcl", "rustc", "cargo", "si"] }
|
vergen = { version = "8.3.1", features = ["git", "gitcl", "rustc", "cargo", "si"] }
|
||||||
|
|
|
@ -21,7 +21,7 @@ num_enum = "0.7.2"
|
||||||
xkbcommon = { workspace = true }
|
xkbcommon = { workspace = true }
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
bitflags = { workspace = true }
|
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]
|
[features]
|
||||||
default = ["snowcap"]
|
default = ["snowcap"]
|
||||||
|
|
|
@ -19,11 +19,8 @@ use snowcap_api::widget::{Alignment, Column, Container, Length, Text};
|
||||||
// Pinnacle needs to perform some setup before and after your config.
|
// Pinnacle needs to perform some setup before and after your config.
|
||||||
// The `#[pinnacle_api::config(modules)]` attribute does so and
|
// The `#[pinnacle_api::config(modules)]` attribute does so and
|
||||||
// will bind all the config structs to the provided identifier.
|
// will bind all the config structs to the provided identifier.
|
||||||
// #[pinnacle_api::config(modules)]
|
#[pinnacle_api::config(modules)]
|
||||||
#[pinnacle_api::tokio::main]
|
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let (modules, __recv) = pinnacle_api::connect().await.unwrap();
|
|
||||||
|
|
||||||
// Deconstruct to get all the APIs.
|
// Deconstruct to get all the APIs.
|
||||||
#[cfg(feature = "snowcap")]
|
#[cfg(feature = "snowcap")]
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
|
@ -38,7 +35,7 @@ async fn main() {
|
||||||
render,
|
render,
|
||||||
snowcap,
|
snowcap,
|
||||||
..
|
..
|
||||||
} = modules.clone();
|
} = modules;
|
||||||
|
|
||||||
#[cfg(not(feature = "snowcap"))]
|
#[cfg(not(feature = "snowcap"))]
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
|
@ -52,7 +49,7 @@ async fn main() {
|
||||||
layout,
|
layout,
|
||||||
render,
|
render,
|
||||||
..
|
..
|
||||||
} = modules.clone();
|
} = modules;
|
||||||
|
|
||||||
let mod_key = Mod::Ctrl;
|
let mod_key = Mod::Ctrl;
|
||||||
|
|
||||||
|
@ -314,6 +311,4 @@ async fn main() {
|
||||||
})));
|
})));
|
||||||
|
|
||||||
process.spawn_once([terminal]);
|
process.spawn_once([terminal]);
|
||||||
|
|
||||||
pinnacle_api::listen(modules, __recv).await;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,8 @@ pub mod util;
|
||||||
pub mod window;
|
pub mod window;
|
||||||
|
|
||||||
pub use pinnacle_api_macros::config;
|
pub use pinnacle_api_macros::config;
|
||||||
|
#[cfg(feature = "snowcap")]
|
||||||
|
pub use snowcap_api;
|
||||||
pub use tokio;
|
pub use tokio;
|
||||||
pub use xkbcommon;
|
pub use xkbcommon;
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,8 @@ macro_rules! signals {
|
||||||
.send((self.current_id, callback))
|
.send((self.current_id, callback))
|
||||||
.expect("failed to send callback");
|
.expect("failed to send callback");
|
||||||
|
|
||||||
|
self.callback_count.fetch_add(1, Ordering::SeqCst);
|
||||||
|
|
||||||
let handle = SignalHandle::new(self.current_id, remove_callback_sender);
|
let handle = SignalHandle::new(self.current_id, remove_callback_sender);
|
||||||
|
|
||||||
self.current_id.0 += 1;
|
self.current_id.0 += 1;
|
||||||
|
@ -376,6 +378,10 @@ where
|
||||||
|
|
||||||
control_sender
|
control_sender
|
||||||
.send(Req::from_control(StreamControl::Ready))
|
.send(Req::from_control(StreamControl::Ready))
|
||||||
|
.map_err(|err| {
|
||||||
|
println!("{err}");
|
||||||
|
err
|
||||||
|
})
|
||||||
.expect("send failed");
|
.expect("send failed");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -407,7 +413,8 @@ where
|
||||||
callback = callback_recv_recv => {
|
callback = callback_recv_recv => {
|
||||||
if let Some((id, callback)) = callback {
|
if let Some((id, callback)) = callback {
|
||||||
callbacks.insert(id, 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 => {
|
remove = remove_callback_recv_recv => {
|
||||||
|
|
1
snowcap
Submodule
1
snowcap
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 81f61f7fbbec91673caf6c56df438b64eab90181
|
21
src/main.rs
21
src/main.rs
|
@ -11,7 +11,14 @@
|
||||||
// #![deny(unused_imports)] // this has remained commented out for months lol
|
// #![deny(unused_imports)] // this has remained commented out for months lol
|
||||||
#![warn(clippy::unwrap_used)]
|
#![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 anyhow::Context;
|
||||||
use pinnacle::{
|
use pinnacle::{
|
||||||
|
@ -54,7 +61,8 @@ async fn main() -> anyhow::Result<()> {
|
||||||
.with_writer(appender)
|
.with_writer(appender)
|
||||||
.with_filter(file_log_env_filter);
|
.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()
|
let stdout_layer = tracing_subscriber::fmt::layer()
|
||||||
.compact()
|
.compact()
|
||||||
.with_writer(std::io::stdout)
|
.with_writer(std::io::stdout)
|
||||||
|
@ -175,10 +183,17 @@ async fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
#[cfg(feature = "snowcap")]
|
#[cfg(feature = "snowcap")]
|
||||||
{
|
{
|
||||||
|
info!("Starting Snowcap");
|
||||||
let (ping, source) = calloop::ping::make_ping()?;
|
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 || {
|
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);
|
state.pinnacle.snowcap_shutdown_ping = Some(ping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue