aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--niri-config/src/lib.rs48
-rw-r--r--niri-visual-tests/src/cases/layout.rs2
-rw-r--r--niri-visual-tests/src/cases/tile.rs2
-rw-r--r--src/layout/mod.rs19
-rw-r--r--src/layout/tile.rs4
5 files changed, 55 insertions, 20 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index 70dc3909..4587483c 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -281,8 +281,8 @@ pub struct Mode {
pub struct Layout {
#[knuffel(child, default)]
pub focus_ring: FocusRing,
- #[knuffel(child, default = FocusRing::default_border())]
- pub border: FocusRing,
+ #[knuffel(child, default)]
+ pub border: Border,
#[knuffel(child, unwrap(children), default)]
pub preset_column_widths: Vec<PresetWidth>,
#[knuffel(child)]
@@ -305,11 +305,11 @@ pub struct SpawnAtStartup {
pub struct FocusRing {
#[knuffel(child)]
pub off: bool,
- #[knuffel(child, unwrap(argument), default = 4)]
+ #[knuffel(child, unwrap(argument), default = Self::default().width)]
pub width: u16,
- #[knuffel(child, default = Color::new(127, 200, 255, 255))]
+ #[knuffel(child, default = Self::default().active_color)]
pub active_color: Color,
- #[knuffel(child, default = Color::new(80, 80, 80, 255))]
+ #[knuffel(child, default = Self::default().inactive_color)]
pub inactive_color: Color,
}
@@ -324,9 +324,21 @@ impl Default for FocusRing {
}
}
-impl FocusRing {
- pub const fn default_border() -> FocusRing {
- FocusRing {
+#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)]
+pub struct Border {
+ #[knuffel(child)]
+ pub off: bool,
+ #[knuffel(child, unwrap(argument), default = Self::default().width)]
+ pub width: u16,
+ #[knuffel(child, default = Self::default().active_color)]
+ pub active_color: Color,
+ #[knuffel(child, default = Self::default().inactive_color)]
+ pub inactive_color: Color,
+}
+
+impl Default for Border {
+ fn default() -> Self {
+ Self {
off: true,
width: 4,
active_color: Color::new(255, 200, 127, 255),
@@ -335,6 +347,17 @@ impl FocusRing {
}
}
+impl From<Border> for FocusRing {
+ fn from(value: Border) -> Self {
+ Self {
+ off: value.off,
+ width: value.width,
+ active_color: value.active_color,
+ inactive_color: value.inactive_color,
+ }
+ }
+}
+
#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Color {
#[knuffel(argument)]
@@ -881,7 +904,6 @@ mod tests {
border {
width 3
- active-color 0 100 200 255
inactive-color 255 200 100 0
}
@@ -1005,13 +1027,13 @@ mod tests {
a: 0,
},
},
- border: FocusRing {
+ border: Border {
off: false,
width: 3,
active_color: Color {
- r: 0,
- g: 100,
- b: 200,
+ r: 255,
+ g: 200,
+ b: 127,
a: 255,
},
inactive_color: Color {
diff --git a/niri-visual-tests/src/cases/layout.rs b/niri-visual-tests/src/cases/layout.rs
index b12b6745..0bb5f332 100644
--- a/niri-visual-tests/src/cases/layout.rs
+++ b/niri-visual-tests/src/cases/layout.rs
@@ -46,7 +46,7 @@ impl Layout {
off: true,
..Default::default()
},
- border: niri_config::FocusRing {
+ border: niri_config::Border {
off: false,
width: 4,
active_color: Color::new(255, 163, 72, 255),
diff --git a/niri-visual-tests/src/cases/tile.rs b/niri-visual-tests/src/cases/tile.rs
index e3fa8fb1..ff0af227 100644
--- a/niri-visual-tests/src/cases/tile.rs
+++ b/niri-visual-tests/src/cases/tile.rs
@@ -68,7 +68,7 @@ impl Tile {
off: true,
..Default::default()
},
- border: niri_config::FocusRing {
+ border: niri_config::Border {
off: false,
width: 32,
active_color: Color::new(255, 163, 72, 255),
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 9443093f..dfc7ee0a 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -153,7 +153,7 @@ pub struct Options {
/// Extra padding around the working area in logical pixels.
pub struts: Struts,
pub focus_ring: niri_config::FocusRing,
- pub border: niri_config::FocusRing,
+ pub border: niri_config::Border,
pub center_focused_column: CenterFocusedColumn,
/// Column widths that `toggle_width()` switches between.
pub preset_widths: Vec<ColumnWidth>,
@@ -168,7 +168,7 @@ impl Default for Options {
gaps: 16,
struts: Default::default(),
focus_ring: Default::default(),
- border: niri_config::FocusRing::default_border(),
+ border: Default::default(),
center_focused_column: Default::default(),
preset_widths: vec![
ColumnWidth::Proportion(1. / 3.),
@@ -2819,11 +2819,24 @@ mod tests {
}
prop_compose! {
+ fn arbitrary_border()(
+ off in any::<bool>(),
+ width in arbitrary_spacing(),
+ ) -> niri_config::Border {
+ niri_config::Border {
+ off,
+ width,
+ ..Default::default()
+ }
+ }
+ }
+
+ prop_compose! {
fn arbitrary_options()(
gaps in arbitrary_spacing(),
struts in arbitrary_struts(),
focus_ring in arbitrary_focus_ring(),
- border in arbitrary_focus_ring(),
+ border in arbitrary_border(),
center_focused_column in arbitrary_center_focused_column(),
) -> Options {
Options {
diff --git a/src/layout/tile.rs b/src/layout/tile.rs
index 62f79a77..54c38d15 100644
--- a/src/layout/tile.rs
+++ b/src/layout/tile.rs
@@ -62,7 +62,7 @@ impl<W: LayoutElement> Tile<W> {
pub fn new(window: W, options: Rc<Options>) -> Self {
Self {
window,
- border: FocusRing::new(options.border),
+ border: FocusRing::new(options.border.into()),
focus_ring: FocusRing::new(options.focus_ring),
is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size.
fullscreen_backdrop: SolidColorBuffer::new((0, 0), [0., 0., 0., 1.]),
@@ -73,7 +73,7 @@ impl<W: LayoutElement> Tile<W> {
}
pub fn update_config(&mut self, options: Rc<Options>) {
- self.border.update_config(options.border);
+ self.border.update_config(options.border.into());
self.focus_ring.update_config(options.focus_ring);
self.options = options;
}