use handlers::store::{Store, StoreKey};
use wlc::{Callback, Geometry, Output, Point, Size, View};
mod gaps;
pub use self::gaps::*;
pub struct UsableScreenGeometry;
impl StoreKey for UsableScreenGeometry {
type Value = Geometry;
}
pub struct UsableViewGeometry;
impl StoreKey for UsableViewGeometry {
type Value = ViewScissor;
}
pub struct ViewScissor {
pub up: usize,
pub right: usize,
pub down: usize,
pub left: usize,
}
pub struct InitialViewGeometry;
impl StoreKey for InitialViewGeometry {
type Value = Geometry;
}
#[derive(Default)]
pub struct GeometryHandler;
impl GeometryHandler {
pub fn new() -> GeometryHandler {
GeometryHandler
}
}
impl Callback for GeometryHandler {
fn output_created(&mut self, output: &Output) -> bool {
output.insert::<UsableScreenGeometry>(Geometry {
origin: Point { x: 0, y: 0 },
size: output.resolution(),
});
true
}
fn output_resolution(&mut self, output: &Output, _from: Size, to: Size) {
output.insert::<UsableScreenGeometry>(Geometry {
origin: Point { x: 0, y: 0 },
size: to,
});
}
fn view_created(&mut self, view: &View) -> bool {
view.insert::<InitialViewGeometry>(view.geometry());
view.insert::<UsableViewGeometry>(ViewScissor {
up: 0,
right: 0,
down: 0,
left: 0,
});
true
}
}