diff --git a/src/config.rs b/src/config.rs index ecbaa41..1015846 100644 --- a/src/config.rs +++ b/src/config.rs @@ -80,6 +80,7 @@ pub struct Config { pub font_paths: Option>, pub widget: Widget, pub mode: OperationMode, + pub background: Option, } impl Config { @@ -159,6 +160,7 @@ impl Config { font_paths: Some(map), widget: widget, mode: OperationMode::LayerSurface((1024, 768)), + background: Some(0xFAFAFAFA), } } @@ -250,6 +252,7 @@ impl Config { } else { OperationMode::LayerSurface((1024, 1)) }, + background: Some(0xFAFAFAFA), } } } diff --git a/src/main.rs b/src/main.rs index 2270edf..e8b8340 100644 --- a/src/main.rs +++ b/src/main.rs @@ -166,6 +166,7 @@ fn main() { let mut state = State::new( config.mode, + config.background, widgets, layout, MaybeFontMap::Waiting(font_thread), diff --git a/src/state.rs b/src/state.rs index 3647a07..0aea95d 100644 --- a/src/state.rs +++ b/src/state.rs @@ -61,6 +61,7 @@ pub struct Protocols { pub struct State { mode: OperationMode, + background: Option, pub main_surface: MainSurface, pub bg_surface: BackgroundSurface, pub protocols: Protocols, @@ -82,6 +83,7 @@ pub struct State { impl State { pub fn new( mode: OperationMode, + background: Option, widgets: Vec>, layout: Rc>, fonts: MaybeFontMap, @@ -102,6 +104,7 @@ impl State { pointer: None, keyrepeat_sender, mode, + background, widgets, fonts, events, @@ -264,12 +267,12 @@ impl Dispatch for State { } state.protocols.viewporter = Some(viewporter); } - "wp_single_pixel_buffer_manager_v1" => { + "wp_single_pixel_buffer_manager_v1" if state.background.is_some() => { let singlepixel = registry.bind::(name, 1, qh, ()); match &state.bg_surface.wl_surface { Some(surface) => { let buffer = - singlepixel.create_u32_rgba_buffer(0, 0, 0, 0xFAFAFAFA, qh, ()); + singlepixel.create_u32_rgba_buffer(0, 0, 0, state.background.unwrap(), qh, ()); surface.attach(Some(&buffer), 0, 0); surface.damage_buffer(0, 0, 1, 1); }