Make background configurable
This commit is contained in:
@@ -80,6 +80,7 @@ pub struct Config {
|
||||
pub font_paths: Option<HashMap<String, String>>,
|
||||
pub widget: Widget,
|
||||
pub mode: OperationMode,
|
||||
pub background: Option<u32>,
|
||||
}
|
||||
|
||||
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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +166,7 @@ fn main() {
|
||||
|
||||
let mut state = State::new(
|
||||
config.mode,
|
||||
config.background,
|
||||
widgets,
|
||||
layout,
|
||||
MaybeFontMap::Waiting(font_thread),
|
||||
|
||||
+5
-2
@@ -61,6 +61,7 @@ pub struct Protocols {
|
||||
|
||||
pub struct State {
|
||||
mode: OperationMode,
|
||||
background: Option<u32>,
|
||||
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<u32>,
|
||||
widgets: Vec<Box<dyn Widget>>,
|
||||
layout: Rc<Box<dyn Layout>>,
|
||||
fonts: MaybeFontMap,
|
||||
@@ -102,6 +104,7 @@ impl State {
|
||||
pointer: None,
|
||||
keyrepeat_sender,
|
||||
mode,
|
||||
background,
|
||||
widgets,
|
||||
fonts,
|
||||
events,
|
||||
@@ -264,12 +267,12 @@ impl Dispatch<wl_registry::WlRegistry, ()> 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::<wp_single_pixel_buffer_manager_v1::WpSinglePixelBufferManagerV1, _, _>(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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user