Add CLI arg parsing with color customization

This commit is contained in:
Val Packett 2026-03-06 03:52:25 -03:00
parent 8dce5e323a
commit 9685398371
4 changed files with 132 additions and 9 deletions

View file

@ -133,6 +133,7 @@ impl Deco {
subsurface.set_forward_to_client(false);
subsurface.send_place_below(&host_surface);
let pool = SimpleBufferPool::new(globals, 1, 1).unwrap();
let args = crate::ARGS.get().unwrap();
let deco = Rc::new(Deco {
bounds: RefCell::new(Bounds {
x: 0,
@ -140,8 +141,8 @@ impl Deco {
width: 10,
height: 10,
}),
top_size: 24,
border_size: 8,
top_size: args.thickness as i32, // TODO: title
border_size: args.thickness as i32,
wl_surface: wl_surface.clone(),
subsurface,
toplevel: toplevel.clone(),
@ -192,13 +193,21 @@ impl Deco {
fn draw(&self) -> eyre::Result<Rc<WlBuffer>> {
let bounds = self.bounds.borrow();
let (width, height) = self.transform_size(bounds.width, bounds.height);
log::info!("{:?} -> {}x{}", bounds, width, height);
let mut pool = self.pool.borrow_mut();
let (buf, map) = pool.buffer(width, height)?;
let (pre, pix, post) = unsafe { map.align_to_mut::<u32>() };
assert!(pre.len() == 0 && post.len() == 0);
let bg = crate::ARGS
.get()
.unwrap()
.background
.premultiply()
.to_rgba8();
let bg_argb = u32::from_be_bytes([bg.a, bg.r, bg.g, bg.b]);
for y in 0..height {
for x in 0..width * 4 {
map[(y * (width * 4) + x) as usize] = 0xaf;
for x in 0..width {
pix[(y * width + x) as usize] = bg_argb;
}
}