diff --git a/README.md b/README.md index 9176834..43daae0 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Sample configuration: # ~~Global values, used as fallback if needed width = 400 height = 512 +# if unset, places window at the center +# window_offsets = [500, -50] # in format [top_offset, left_offset] # font = "DejaVu Sans" bg_color = 0x272822ee # ~~colors are specified in 0xRRGGBBAA format # font_color = 0xf8f8f2ff diff --git a/src/config.rs b/src/config.rs index 9744b62..6970a3d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -11,6 +11,7 @@ mod params; pub struct Config { width: Option, height: Option, + window_offsets: Option<(i32, i32)>, term: Option, font: Option, bg_color: Option, diff --git a/src/config/params.rs b/src/config/params.rs index 12d48fb..618c095 100644 --- a/src/config/params.rs +++ b/src/config/params.rs @@ -79,6 +79,7 @@ impl<'a> From<&'a Config> for SurfaceParams { SurfaceParams { width: config.width.unwrap_or(400), height: config.height.unwrap_or(512), + window_offsets: config.window_offsets, } } } diff --git a/src/surface.rs b/src/surface.rs index 01238ce..9716249 100644 --- a/src/surface.rs +++ b/src/surface.rs @@ -24,6 +24,7 @@ pub enum EventStatus { pub struct Params { pub width: u32, pub height: u32, + pub window_offsets: Option<(i32, i32)>, } pub struct Surface { @@ -53,6 +54,12 @@ impl Surface { let width = params.width; let height = params.height; + if let Some((top_offset, left_offset)) = params.window_offsets { + let mut anchor = zwlr_layer_surface_v1::Anchor::Left; + anchor.insert(zwlr_layer_surface_v1::Anchor::Top); + layer_surface.set_anchor(anchor); + layer_surface.set_margin(top_offset, 0, 0, left_offset); + } layer_surface.set_size(width, height); layer_surface.set_keyboard_interactivity(1);