Add hooks for custom window decorations

This is a first use of the new hooks system, which allows customizing
cosmic-comp at compile-time.
In this case, the view() function of CosmicWindow / CosmicStack is
hooked and the hook can change what is rendered as the header bar.

Signed-off-by: Yureka <yuka@yuka.dev>
This commit is contained in:
Yureka 2025-09-29 17:34:30 +02:00 committed by Victoria Brekenfeld
parent d6e11de1f1
commit a74b6e3a9b
5 changed files with 119 additions and 46 deletions

View file

@ -33,6 +33,7 @@ pub mod config;
pub mod dbus;
#[cfg(feature = "debug")]
pub mod debug;
pub mod hooks;
pub mod input;
mod logger;
pub mod session;
@ -103,7 +104,7 @@ impl State {
}
}
pub fn run() -> Result<(), Box<dyn Error>> {
pub fn run(hooks: crate::hooks::Hooks) -> Result<(), Box<dyn Error>> {
let raw_args = RawArgs::from_args();
let mut cursor = raw_args.cursor();
let git_hash = option_env!("GIT_HASH").unwrap_or("unknown");
@ -137,6 +138,10 @@ pub fn run() -> Result<(), Box<dyn Error>> {
utils::rlimit::increase_nofile_limit();
// init hook globals
hooks::HOOKS.set(hooks)
.expect("Hooks global has already been initialized. Running multiple instances of COSMIC in one process is not supported.");
// init event loop
let mut event_loop = EventLoop::try_new().with_context(|| "Failed to initialize event loop")?;
// init wayland