Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/wiki/Configuration:-Layer-Rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,25 @@ layer-rule {
}
```

#### `geometry-corner-radius-exponent`

<sup>Since: next release</sup>

Sets the exponent used for corner rounding, using the superellipse equation `x^n + y^n = 1`.

- 2 is the default circular rounding.
- Values greater than 2 produce "squircle" corners.
- Values closer to 1 produce chamfer-like corners.

```kdl
layer-rule {
match namespace="^launcher$"

geometry-corner-radius 12
geometry-corner-radius-exponent 4
}
```

#### `place-within-backdrop`

<sup>Since: 25.05</sup>
Expand Down
10 changes: 10 additions & 0 deletions docs/wiki/Configuration:-Layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ layout {
position "right"
gaps-between-tabs 2
corner-radius 8
corner-radius-exponent 4
active-color "red"
inactive-color "gray"
urgent-color "blue"
Expand Down Expand Up @@ -459,6 +460,15 @@ It can be `left`, `right`, `top`, or `bottom`.
`corner-radius` sets the rounded corner radius for tabs in the indicator in logical pixels.
When `gaps-between-tabs` is zero, only the first and the last tabs have rounded corners, otherwise all tabs do.

`corner-radius-exponent` <sup>Since: next release</sup> sets the shape of the rounded corners.
The default is `2` for normal circular rounding, values greater than `2` make "squircle" corners, and `1` make the corners "chamfered".

Tab corner exponents are picked in this order:

1. `corner-radius-exponent` from the `tab-indicator` window rule, if set.
1. `geometry-corner-radius-exponent` from the window rule, if set.
1. `corner-radius-exponent` from the `tab-indicator` layout options.

`active-color`, `inactive-color`, `urgent-color`, `active-gradient`, `inactive-gradient`, `urgent-gradient` let you override the colors for the tabs.
They have the same semantics as the border and focus ring colors and gradients.

Expand Down
19 changes: 19 additions & 0 deletions docs/wiki/Configuration:-Window-Rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ window-rule {

tab-indicator {
inactive-color "darkred"
corner-radius-exponent 4
}
}
```
Expand Down Expand Up @@ -847,6 +848,23 @@ This way, you can match GTK 3 applications which have square bottom corners:

![A screenshot showing a window with only the top corners rounded](./img/different-corner-radius.png)

#### `geometry-corner-radius-exponent`

<sup>Since: next release</sup>

Sets the exponent used for corner rounding, using the superellipse equation `x^n + y^n = 1`.

- 2 is the default circular rounding.
- Values greater than 2 produce "squircle" corners.
- Values closer to 1 produce chamfer-like corners.

```kdl
window-rule {
geometry-corner-radius 12
geometry-corner-radius-exponent 4
}
```

#### `clip-to-geometry`

<sup>Since: 0.1.6</sup>
Expand Down Expand Up @@ -994,6 +1012,7 @@ window-rule {
popups {
// Matches the default libadwaita pop-up corner radius.
geometry-corner-radius 15
geometry-corner-radius-exponent 2

// Note: it'll look better to set background opacity
// through your GTK theme CSS and not here.
Expand Down
11 changes: 11 additions & 0 deletions niri-config/src/appearance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ pub struct CornerRadius {
pub bottom_left: f32,
}

pub const DEFAULT_CORNER_RADIUS_EXPONENT: f32 = 2.;

impl From<CornerRadius> for [f32; 4] {
fn from(value: CornerRadius) -> Self {
[
Expand Down Expand Up @@ -466,6 +468,7 @@ pub struct TabIndicator {
pub position: TabIndicatorPosition,
pub gaps_between_tabs: f64,
pub corner_radius: f64,
pub corner_radius_exponent: f64,
pub active_color: Option<Color>,
pub inactive_color: Option<Color>,
pub urgent_color: Option<Color>,
Expand All @@ -488,6 +491,7 @@ impl Default for TabIndicator {
position: TabIndicatorPosition::Left,
gaps_between_tabs: 0.,
corner_radius: 0.,
corner_radius_exponent: DEFAULT_CORNER_RADIUS_EXPONENT as f64,
active_color: None,
inactive_color: None,
urgent_color: None,
Expand All @@ -513,6 +517,7 @@ impl MergeWith<TabIndicatorPart> for TabIndicator {
width,
gaps_between_tabs,
corner_radius,
corner_radius_exponent,
);

merge_clone!((self, part), length, position);
Expand Down Expand Up @@ -548,6 +553,8 @@ pub struct TabIndicatorPart {
pub gaps_between_tabs: Option<FloatOrInt<0, 65535>>,
#[knuffel(child, unwrap(argument))]
pub corner_radius: Option<FloatOrInt<0, 65535>>,
#[knuffel(child, unwrap(argument))]
pub corner_radius_exponent: Option<FloatOrInt<1, { i32::MAX }>>,
#[knuffel(child)]
pub active_color: Option<Color>,
#[knuffel(child)]
Expand Down Expand Up @@ -666,6 +673,8 @@ pub struct ShadowRule {

#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]
pub struct TabIndicatorRule {
#[knuffel(child, unwrap(argument))]
pub corner_radius_exponent: Option<FloatOrInt<1, { i32::MAX }>>,
#[knuffel(child)]
pub active_color: Option<Color>,
#[knuffel(child)]
Expand Down Expand Up @@ -713,6 +722,8 @@ impl MergeWith<Self> for ShadowRule {

impl MergeWith<Self> for TabIndicatorRule {
fn merge_with(&mut self, part: &Self) {
merge_clone_opt!((self, part), corner_radius_exponent);

merge_color_gradient_opt!(
(self, part),
(active_color, active_gradient),
Expand Down
3 changes: 3 additions & 0 deletions niri-config/src/layer_rule.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::appearance::{BackgroundEffectRule, BlockOutFrom, CornerRadius, ShadowRule};
use crate::utils::RegexEq;
use crate::window_rule::PopupsRule;
use crate::FloatOrInt;

#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
pub struct LayerRule {
Expand All @@ -18,6 +19,8 @@ pub struct LayerRule {
#[knuffel(child)]
pub geometry_corner_radius: Option<CornerRadius>,
#[knuffel(child, unwrap(argument))]
pub geometry_corner_radius_exponent: Option<FloatOrInt<1, { i32::MAX }>>,
#[knuffel(child, unwrap(argument))]
pub place_within_backdrop: Option<bool>,
#[knuffel(child, unwrap(argument))]
pub baba_is_float: Option<bool>,
Expand Down
6 changes: 6 additions & 0 deletions niri-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ mod tests {
position: Top,
gaps_between_tabs: 0.0,
corner_radius: 0.0,
corner_radius_exponent: 2.0,
active_color: None,
inactive_color: None,
urgent_color: None,
Expand Down Expand Up @@ -1837,6 +1838,7 @@ mod tests {
inactive_color: None,
},
tab_indicator: TabIndicatorRule {
corner_radius_exponent: None,
active_color: Some(
Color {
r: 1.0,
Expand All @@ -1854,6 +1856,7 @@ mod tests {
draw_border_with_background: None,
opacity: None,
geometry_corner_radius: None,
geometry_corner_radius_exponent: None,
clip_to_geometry: None,
baba_is_float: None,
block_out_from: None,
Expand Down Expand Up @@ -1883,6 +1886,7 @@ mod tests {
popups: PopupsRule {
opacity: None,
geometry_corner_radius: None,
geometry_corner_radius_exponent: None,
background_effect: BackgroundEffectRule {
xray: None,
blur: None,
Expand Down Expand Up @@ -1923,6 +1927,7 @@ mod tests {
inactive_color: None,
},
geometry_corner_radius: None,
geometry_corner_radius_exponent: None,
place_within_backdrop: None,
baba_is_float: None,
background_effect: BackgroundEffectRule {
Expand All @@ -1934,6 +1939,7 @@ mod tests {
popups: PopupsRule {
opacity: None,
geometry_corner_radius: None,
geometry_corner_radius_exponent: None,
background_effect: BackgroundEffectRule {
xray: None,
blur: None,
Expand Down
9 changes: 9 additions & 0 deletions niri-config/src/window_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ pub struct WindowRule {
#[knuffel(child)]
pub geometry_corner_radius: Option<CornerRadius>,
#[knuffel(child, unwrap(argument))]
pub geometry_corner_radius_exponent: Option<FloatOrInt<1, { i32::MAX }>>,
#[knuffel(child, unwrap(argument))]
pub clip_to_geometry: Option<bool>,
#[knuffel(child, unwrap(argument))]
pub baba_is_float: Option<bool>,
Expand Down Expand Up @@ -88,6 +90,8 @@ pub struct PopupsRule {
pub opacity: Option<f32>,
#[knuffel(child)]
pub geometry_corner_radius: Option<CornerRadius>,
#[knuffel(child, unwrap(argument))]
pub geometry_corner_radius_exponent: Option<FloatOrInt<1, { i32::MAX }>>,
#[knuffel(child, default)]
pub background_effect: BackgroundEffectRule,
}
Expand All @@ -100,6 +104,8 @@ pub struct ResolvedPopupsRules {

/// Corner radius to assume the popups have.
pub geometry_corner_radius: Option<CornerRadius>,
/// Exponent to use for popup corner rounding.
pub geometry_corner_radius_exponent: Option<f32>,

/// Background effect configuration for popups.
pub background_effect: BackgroundEffect,
Expand All @@ -113,6 +119,9 @@ impl MergeWith<PopupsRule> for ResolvedPopupsRules {
if let Some(x) = part.geometry_corner_radius {
self.geometry_corner_radius = Some(x);
}
if let Some(x) = part.geometry_corner_radius_exponent {
self.geometry_corner_radius_exponent = Some(x.0 as f32);
}
self.background_effect.merge_with(&part.background_effect);
}
}
Expand Down
3 changes: 2 additions & 1 deletion niri-visual-tests/src/cases/gradient_angle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::f32::consts::{FRAC_PI_2, PI};
use std::time::Duration;

use niri::render_helpers::border::BorderRenderElement;
use niri_config::{Color, CornerRadius, GradientInterpolation};
use niri_config::{Color, CornerRadius, GradientInterpolation, DEFAULT_CORNER_RADIUS_EXPONENT};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Physical, Point, Rectangle, Size};
Expand Down Expand Up @@ -62,6 +62,7 @@ impl TestCase for GradientAngle {
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
DEFAULT_CORNER_RADIUS_EXPONENT,
1.,
1.,
)
Expand Down
4 changes: 3 additions & 1 deletion niri-visual-tests/src/cases/gradient_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::time::Duration;

use niri::layout::focus_ring::FocusRing;
use niri::render_helpers::border::BorderRenderElement;
use niri_config::{Color, CornerRadius, GradientInterpolation};
use niri_config::{Color, CornerRadius, GradientInterpolation, DEFAULT_CORNER_RADIUS_EXPONENT};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Physical, Point, Rectangle, Size};
Expand Down Expand Up @@ -86,6 +86,7 @@ impl TestCase for GradientArea {
false,
Rectangle::default(),
CornerRadius::default(),
DEFAULT_CORNER_RADIUS_EXPONENT,
1.,
1.,
);
Expand All @@ -103,6 +104,7 @@ impl TestCase for GradientArea {
Rectangle::from_size(rect_size).to_f64(),
0.,
CornerRadius::default(),
DEFAULT_CORNER_RADIUS_EXPONENT,
1.,
1.,
)
Expand Down
2 changes: 2 additions & 0 deletions niri-visual-tests/src/cases/gradient_oklab.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use niri::render_helpers::border::BorderRenderElement;
use niri_config::{
Color, CornerRadius, GradientColorSpace, GradientInterpolation, HueInterpolation,
DEFAULT_CORNER_RADIUS_EXPONENT,
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
Expand Down Expand Up @@ -43,6 +44,7 @@ impl TestCase for GradientOklab {
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
DEFAULT_CORNER_RADIUS_EXPONENT,
1.,
1.,
)
Expand Down
5 changes: 4 additions & 1 deletion niri-visual-tests/src/cases/gradient_oklab_alpha.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use niri::render_helpers::border::BorderRenderElement;
use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation};
use niri_config::{
Color, CornerRadius, GradientColorSpace, GradientInterpolation, DEFAULT_CORNER_RADIUS_EXPONENT,
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Physical, Point, Rectangle, Size};
Expand Down Expand Up @@ -41,6 +43,7 @@ impl TestCase for GradientOklabAlpha {
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
DEFAULT_CORNER_RADIUS_EXPONENT,
1.,
1.,
)
Expand Down
2 changes: 2 additions & 0 deletions niri-visual-tests/src/cases/gradient_oklch_alpha.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use niri::render_helpers::border::BorderRenderElement;
use niri_config::{
Color, CornerRadius, GradientColorSpace, GradientInterpolation, HueInterpolation,
DEFAULT_CORNER_RADIUS_EXPONENT,
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
Expand Down Expand Up @@ -43,6 +44,7 @@ impl TestCase for GradientOklchAlpha {
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
DEFAULT_CORNER_RADIUS_EXPONENT,
1.,
1.,
)
Expand Down
2 changes: 2 additions & 0 deletions niri-visual-tests/src/cases/gradient_oklch_decreasing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use niri::render_helpers::border::BorderRenderElement;
use niri_config::{
Color, CornerRadius, GradientColorSpace, GradientInterpolation, HueInterpolation,
DEFAULT_CORNER_RADIUS_EXPONENT,
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
Expand Down Expand Up @@ -43,6 +44,7 @@ impl TestCase for GradientOklchDecreasing {
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
DEFAULT_CORNER_RADIUS_EXPONENT,
1.,
1.,
)
Expand Down
2 changes: 2 additions & 0 deletions niri-visual-tests/src/cases/gradient_oklch_increasing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use niri::render_helpers::border::BorderRenderElement;
use niri_config::{
Color, CornerRadius, GradientColorSpace, GradientInterpolation, HueInterpolation,
DEFAULT_CORNER_RADIUS_EXPONENT,
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
Expand Down Expand Up @@ -43,6 +44,7 @@ impl TestCase for GradientOklchIncreasing {
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
DEFAULT_CORNER_RADIUS_EXPONENT,
1.,
1.,
)
Expand Down
2 changes: 2 additions & 0 deletions niri-visual-tests/src/cases/gradient_oklch_longer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use niri::render_helpers::border::BorderRenderElement;
use niri_config::{
Color, CornerRadius, GradientColorSpace, GradientInterpolation, HueInterpolation,
DEFAULT_CORNER_RADIUS_EXPONENT,
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
Expand Down Expand Up @@ -43,6 +44,7 @@ impl TestCase for GradientOklchLonger {
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
DEFAULT_CORNER_RADIUS_EXPONENT,
1.,
1.,
)
Expand Down
Loading
Loading