Make background configurable
This commit is contained in:
@@ -80,6 +80,7 @@ pub struct Config {
|
|||||||
pub font_paths: Option<HashMap<String, String>>,
|
pub font_paths: Option<HashMap<String, String>>,
|
||||||
pub widget: Widget,
|
pub widget: Widget,
|
||||||
pub mode: OperationMode,
|
pub mode: OperationMode,
|
||||||
|
pub background: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
@@ -159,6 +160,7 @@ impl Config {
|
|||||||
font_paths: Some(map),
|
font_paths: Some(map),
|
||||||
widget: widget,
|
widget: widget,
|
||||||
mode: OperationMode::LayerSurface((1024, 768)),
|
mode: OperationMode::LayerSurface((1024, 768)),
|
||||||
|
background: Some(0xFAFAFAFA),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,6 +252,7 @@ impl Config {
|
|||||||
} else {
|
} else {
|
||||||
OperationMode::LayerSurface((1024, 1))
|
OperationMode::LayerSurface((1024, 1))
|
||||||
},
|
},
|
||||||
|
background: Some(0xFAFAFAFA),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ fn main() {
|
|||||||
|
|
||||||
let mut state = State::new(
|
let mut state = State::new(
|
||||||
config.mode,
|
config.mode,
|
||||||
|
config.background,
|
||||||
widgets,
|
widgets,
|
||||||
layout,
|
layout,
|
||||||
MaybeFontMap::Waiting(font_thread),
|
MaybeFontMap::Waiting(font_thread),
|
||||||
|
|||||||
+5
-2
@@ -61,6 +61,7 @@ pub struct Protocols {
|
|||||||
|
|
||||||
pub struct State {
|
pub struct State {
|
||||||
mode: OperationMode,
|
mode: OperationMode,
|
||||||
|
background: Option<u32>,
|
||||||
pub main_surface: MainSurface,
|
pub main_surface: MainSurface,
|
||||||
pub bg_surface: BackgroundSurface,
|
pub bg_surface: BackgroundSurface,
|
||||||
pub protocols: Protocols,
|
pub protocols: Protocols,
|
||||||
@@ -82,6 +83,7 @@ pub struct State {
|
|||||||
impl State {
|
impl State {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
mode: OperationMode,
|
mode: OperationMode,
|
||||||
|
background: Option<u32>,
|
||||||
widgets: Vec<Box<dyn Widget>>,
|
widgets: Vec<Box<dyn Widget>>,
|
||||||
layout: Rc<Box<dyn Layout>>,
|
layout: Rc<Box<dyn Layout>>,
|
||||||
fonts: MaybeFontMap,
|
fonts: MaybeFontMap,
|
||||||
@@ -102,6 +104,7 @@ impl State {
|
|||||||
pointer: None,
|
pointer: None,
|
||||||
keyrepeat_sender,
|
keyrepeat_sender,
|
||||||
mode,
|
mode,
|
||||||
|
background,
|
||||||
widgets,
|
widgets,
|
||||||
fonts,
|
fonts,
|
||||||
events,
|
events,
|
||||||
@@ -264,12 +267,12 @@ impl Dispatch<wl_registry::WlRegistry, ()> for State {
|
|||||||
}
|
}
|
||||||
state.protocols.viewporter = Some(viewporter);
|
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, ());
|
let singlepixel = registry.bind::<wp_single_pixel_buffer_manager_v1::WpSinglePixelBufferManagerV1, _, _>(name, 1, qh, ());
|
||||||
match &state.bg_surface.wl_surface {
|
match &state.bg_surface.wl_surface {
|
||||||
Some(surface) => {
|
Some(surface) => {
|
||||||
let buffer =
|
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.attach(Some(&buffer), 0, 0);
|
||||||
surface.damage_buffer(0, 0, 1, 1);
|
surface.damage_buffer(0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user