Dynamic widget configuration and layout
1. Implement new layout API, replacing previous hard-coded layout. 2. Make the widgets (previously modules) configurable. 3. Split some widgets into smaller modules. 4. Configuration file (reluctantly JSON at time of writing). 5. More correct damage handling, copying damage to next buffer.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
use smithay_client_toolkit::utils::MemPool;
|
||||
use wayland_client::protocol::wl_shm;
|
||||
|
||||
pub struct DoubleMemPool {
|
||||
pool1: MemPool,
|
||||
pool2: MemPool,
|
||||
switch: bool,
|
||||
}
|
||||
|
||||
impl DoubleMemPool {
|
||||
pub fn new(shm: &wl_shm::WlShm) -> ::std::io::Result<DoubleMemPool> {
|
||||
Ok(DoubleMemPool {
|
||||
pool1: MemPool::new(shm, move || {})?,
|
||||
pool2: MemPool::new(shm, move || {})?,
|
||||
switch: false,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn pool(&mut self) -> Option<(&mut MemPool, &mut MemPool)> {
|
||||
let switch = self.switch;
|
||||
self.switch = !self.switch;
|
||||
let (last, cur) = if switch {
|
||||
(&mut self.pool2, &mut self.pool1)
|
||||
} else {
|
||||
(&mut self.pool1, &mut self.pool2)
|
||||
};
|
||||
|
||||
if cur.is_used() {
|
||||
None
|
||||
} else {
|
||||
Some((last, cur))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user