mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
add urgent border color and gradient
This commit is contained in:
committed by
Ivan Molodetskikh
parent
caa6189448
commit
398bc78ea0
@@ -583,10 +583,14 @@ pub struct FocusRing {
|
|||||||
pub active_color: Color,
|
pub active_color: Color,
|
||||||
#[knuffel(child, default = Self::default().inactive_color)]
|
#[knuffel(child, default = Self::default().inactive_color)]
|
||||||
pub inactive_color: Color,
|
pub inactive_color: Color,
|
||||||
|
#[knuffel(child, default = Self::default().urgent_color)]
|
||||||
|
pub urgent_color: Color,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub active_gradient: Option<Gradient>,
|
pub active_gradient: Option<Gradient>,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub inactive_gradient: Option<Gradient>,
|
pub inactive_gradient: Option<Gradient>,
|
||||||
|
#[knuffel(child)]
|
||||||
|
pub urgent_gradient: Option<Gradient>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FocusRing {
|
impl Default for FocusRing {
|
||||||
@@ -596,8 +600,10 @@ impl Default for FocusRing {
|
|||||||
width: FloatOrInt(4.),
|
width: FloatOrInt(4.),
|
||||||
active_color: Color::from_rgba8_unpremul(127, 200, 255, 255),
|
active_color: Color::from_rgba8_unpremul(127, 200, 255, 255),
|
||||||
inactive_color: Color::from_rgba8_unpremul(80, 80, 80, 255),
|
inactive_color: Color::from_rgba8_unpremul(80, 80, 80, 255),
|
||||||
|
urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255),
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -669,10 +675,14 @@ pub struct Border {
|
|||||||
pub active_color: Color,
|
pub active_color: Color,
|
||||||
#[knuffel(child, default = Self::default().inactive_color)]
|
#[knuffel(child, default = Self::default().inactive_color)]
|
||||||
pub inactive_color: Color,
|
pub inactive_color: Color,
|
||||||
|
#[knuffel(child, default = Self::default().urgent_color)]
|
||||||
|
pub urgent_color: Color,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub active_gradient: Option<Gradient>,
|
pub active_gradient: Option<Gradient>,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub inactive_gradient: Option<Gradient>,
|
pub inactive_gradient: Option<Gradient>,
|
||||||
|
#[knuffel(child)]
|
||||||
|
pub urgent_gradient: Option<Gradient>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Border {
|
impl Default for Border {
|
||||||
@@ -682,8 +692,10 @@ impl Default for Border {
|
|||||||
width: FloatOrInt(4.),
|
width: FloatOrInt(4.),
|
||||||
active_color: Color::from_rgba8_unpremul(255, 200, 127, 255),
|
active_color: Color::from_rgba8_unpremul(255, 200, 127, 255),
|
||||||
inactive_color: Color::from_rgba8_unpremul(80, 80, 80, 255),
|
inactive_color: Color::from_rgba8_unpremul(80, 80, 80, 255),
|
||||||
|
urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255),
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -695,8 +707,10 @@ impl From<Border> for FocusRing {
|
|||||||
width: value.width,
|
width: value.width,
|
||||||
active_color: value.active_color,
|
active_color: value.active_color,
|
||||||
inactive_color: value.inactive_color,
|
inactive_color: value.inactive_color,
|
||||||
|
urgent_color: value.urgent_color,
|
||||||
active_gradient: value.active_gradient,
|
active_gradient: value.active_gradient,
|
||||||
inactive_gradient: value.inactive_gradient,
|
inactive_gradient: value.inactive_gradient,
|
||||||
|
urgent_gradient: value.urgent_gradient,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -708,8 +722,10 @@ impl From<FocusRing> for Border {
|
|||||||
width: value.width,
|
width: value.width,
|
||||||
active_color: value.active_color,
|
active_color: value.active_color,
|
||||||
inactive_color: value.inactive_color,
|
inactive_color: value.inactive_color,
|
||||||
|
urgent_color: value.urgent_color,
|
||||||
active_gradient: value.active_gradient,
|
active_gradient: value.active_gradient,
|
||||||
inactive_gradient: value.inactive_gradient,
|
inactive_gradient: value.inactive_gradient,
|
||||||
|
urgent_gradient: value.urgent_gradient,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1487,9 +1503,13 @@ pub struct BorderRule {
|
|||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub inactive_color: Option<Color>,
|
pub inactive_color: Option<Color>,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
|
pub urgent_color: Option<Color>,
|
||||||
|
#[knuffel(child)]
|
||||||
pub active_gradient: Option<Gradient>,
|
pub active_gradient: Option<Gradient>,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub inactive_gradient: Option<Gradient>,
|
pub inactive_gradient: Option<Gradient>,
|
||||||
|
#[knuffel(child)]
|
||||||
|
pub urgent_gradient: Option<Gradient>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]
|
#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]
|
||||||
@@ -2353,12 +2373,18 @@ impl BorderRule {
|
|||||||
if let Some(x) = other.inactive_color {
|
if let Some(x) = other.inactive_color {
|
||||||
self.inactive_color = Some(x);
|
self.inactive_color = Some(x);
|
||||||
}
|
}
|
||||||
|
if let Some(x) = other.urgent_color {
|
||||||
|
self.urgent_color = Some(x);
|
||||||
|
}
|
||||||
if let Some(x) = other.active_gradient {
|
if let Some(x) = other.active_gradient {
|
||||||
self.active_gradient = Some(x);
|
self.active_gradient = Some(x);
|
||||||
}
|
}
|
||||||
if let Some(x) = other.inactive_gradient {
|
if let Some(x) = other.inactive_gradient {
|
||||||
self.inactive_gradient = Some(x);
|
self.inactive_gradient = Some(x);
|
||||||
}
|
}
|
||||||
|
if let Some(x) = other.urgent_gradient {
|
||||||
|
self.urgent_gradient = Some(x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolve_against(&self, mut config: Border) -> Border {
|
pub fn resolve_against(&self, mut config: Border) -> Border {
|
||||||
@@ -2378,12 +2404,19 @@ impl BorderRule {
|
|||||||
config.inactive_color = x;
|
config.inactive_color = x;
|
||||||
config.inactive_gradient = None;
|
config.inactive_gradient = None;
|
||||||
}
|
}
|
||||||
|
if let Some(x) = self.urgent_color {
|
||||||
|
config.urgent_color = x;
|
||||||
|
config.urgent_gradient = None;
|
||||||
|
}
|
||||||
if let Some(x) = self.active_gradient {
|
if let Some(x) = self.active_gradient {
|
||||||
config.active_gradient = Some(x);
|
config.active_gradient = Some(x);
|
||||||
}
|
}
|
||||||
if let Some(x) = self.inactive_gradient {
|
if let Some(x) = self.inactive_gradient {
|
||||||
config.inactive_gradient = Some(x);
|
config.inactive_gradient = Some(x);
|
||||||
}
|
}
|
||||||
|
if let Some(x) = self.urgent_gradient {
|
||||||
|
config.urgent_gradient = Some(x);
|
||||||
|
}
|
||||||
|
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
@@ -4321,6 +4354,12 @@ mod tests {
|
|||||||
b: 0.39215687,
|
b: 0.39215687,
|
||||||
a: 0.0,
|
a: 0.0,
|
||||||
},
|
},
|
||||||
|
urgent_color: Color {
|
||||||
|
r: 0.60784316,
|
||||||
|
g: 0.0,
|
||||||
|
b: 0.0,
|
||||||
|
a: 1.0,
|
||||||
|
},
|
||||||
active_gradient: Some(
|
active_gradient: Some(
|
||||||
Gradient {
|
Gradient {
|
||||||
from: Color {
|
from: Color {
|
||||||
@@ -4344,6 +4383,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
},
|
},
|
||||||
border: Border {
|
border: Border {
|
||||||
off: false,
|
off: false,
|
||||||
@@ -4362,8 +4402,15 @@ mod tests {
|
|||||||
b: 0.39215687,
|
b: 0.39215687,
|
||||||
a: 0.0,
|
a: 0.0,
|
||||||
},
|
},
|
||||||
|
urgent_color: Color {
|
||||||
|
r: 0.60784316,
|
||||||
|
g: 0.0,
|
||||||
|
b: 0.0,
|
||||||
|
a: 1.0,
|
||||||
|
},
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
},
|
},
|
||||||
shadow: Shadow {
|
shadow: Shadow {
|
||||||
on: false,
|
on: false,
|
||||||
@@ -4805,8 +4852,10 @@ mod tests {
|
|||||||
),
|
),
|
||||||
active_color: None,
|
active_color: None,
|
||||||
inactive_color: None,
|
inactive_color: None,
|
||||||
|
urgent_color: None,
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
},
|
},
|
||||||
border: BorderRule {
|
border: BorderRule {
|
||||||
off: false,
|
off: false,
|
||||||
@@ -4818,8 +4867,10 @@ mod tests {
|
|||||||
),
|
),
|
||||||
active_color: None,
|
active_color: None,
|
||||||
inactive_color: None,
|
inactive_color: None,
|
||||||
|
urgent_color: None,
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
},
|
},
|
||||||
shadow: ShadowRule {
|
shadow: ShadowRule {
|
||||||
off: false,
|
off: false,
|
||||||
@@ -5552,8 +5603,10 @@ mod tests {
|
|||||||
width: None,
|
width: None,
|
||||||
active_color: None,
|
active_color: None,
|
||||||
inactive_color: None,
|
inactive_color: None,
|
||||||
|
urgent_color: None,
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
for rule in rules.iter().copied() {
|
for rule in rules.iter().copied() {
|
||||||
|
|||||||
@@ -23,8 +23,10 @@ impl GradientArea {
|
|||||||
width: FloatOrInt(1.),
|
width: FloatOrInt(1.),
|
||||||
active_color: Color::from_rgba8_unpremul(255, 255, 255, 128),
|
active_color: Color::from_rgba8_unpremul(255, 255, 255, 128),
|
||||||
inactive_color: Color::default(),
|
inactive_color: Color::default(),
|
||||||
|
urgent_color: Color::default(),
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@@ -81,6 +83,7 @@ impl TestCase for GradientArea {
|
|||||||
g_size,
|
g_size,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
Rectangle::default(),
|
Rectangle::default(),
|
||||||
CornerRadius::default(),
|
CornerRadius::default(),
|
||||||
1.,
|
1.,
|
||||||
|
|||||||
@@ -60,8 +60,10 @@ impl Layout {
|
|||||||
width: FloatOrInt(4.),
|
width: FloatOrInt(4.),
|
||||||
active_color: Color::from_rgba8_unpremul(255, 163, 72, 255),
|
active_color: Color::from_rgba8_unpremul(255, 163, 72, 255),
|
||||||
inactive_color: Color::from_rgba8_unpremul(50, 50, 50, 255),
|
inactive_color: Color::from_rgba8_unpremul(50, 50, 50, 255),
|
||||||
|
urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255),
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -192,6 +192,9 @@ layout {
|
|||||||
active-color "#ffc87f"
|
active-color "#ffc87f"
|
||||||
inactive-color "#505050"
|
inactive-color "#505050"
|
||||||
|
|
||||||
|
// Color of the border around windows that request your attention.
|
||||||
|
urgent-color "#9b0000"
|
||||||
|
|
||||||
// active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view"
|
// active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view"
|
||||||
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
|
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ impl FocusRing {
|
|||||||
win_size: Size<f64, Logical>,
|
win_size: Size<f64, Logical>,
|
||||||
is_active: bool,
|
is_active: bool,
|
||||||
is_border: bool,
|
is_border: bool,
|
||||||
|
is_urgent: bool,
|
||||||
view_rect: Rectangle<f64, Logical>,
|
view_rect: Rectangle<f64, Logical>,
|
||||||
radius: CornerRadius,
|
radius: CornerRadius,
|
||||||
scale: f64,
|
scale: f64,
|
||||||
@@ -67,7 +68,9 @@ impl FocusRing {
|
|||||||
let width = self.config.width.0;
|
let width = self.config.width.0;
|
||||||
self.full_size = win_size + Size::from((width, width)).upscale(2.);
|
self.full_size = win_size + Size::from((width, width)).upscale(2.);
|
||||||
|
|
||||||
let color = if is_active {
|
let color = if is_urgent {
|
||||||
|
self.config.urgent_color
|
||||||
|
} else if is_active {
|
||||||
self.config.active_color
|
self.config.active_color
|
||||||
} else {
|
} else {
|
||||||
self.config.inactive_color
|
self.config.inactive_color
|
||||||
@@ -79,7 +82,9 @@ impl FocusRing {
|
|||||||
|
|
||||||
let radius = radius.fit_to(self.full_size.w as f32, self.full_size.h as f32);
|
let radius = radius.fit_to(self.full_size.w as f32, self.full_size.h as f32);
|
||||||
|
|
||||||
let gradient = if is_active {
|
let gradient = if is_urgent {
|
||||||
|
self.config.urgent_gradient
|
||||||
|
} else if is_active {
|
||||||
self.config.active_gradient
|
self.config.active_gradient
|
||||||
} else {
|
} else {
|
||||||
self.config.inactive_gradient
|
self.config.inactive_gradient
|
||||||
|
|||||||
@@ -19,8 +19,10 @@ impl InsertHintElement {
|
|||||||
width: FloatOrInt(0.),
|
width: FloatOrInt(0.),
|
||||||
active_color: config.color,
|
active_color: config.color,
|
||||||
inactive_color: config.color,
|
inactive_color: config.color,
|
||||||
|
urgent_color: config.color,
|
||||||
active_gradient: config.gradient,
|
active_gradient: config.gradient,
|
||||||
inactive_gradient: config.gradient,
|
inactive_gradient: config.gradient,
|
||||||
|
urgent_gradient: config.gradient,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,8 +33,10 @@ impl InsertHintElement {
|
|||||||
width: FloatOrInt(0.),
|
width: FloatOrInt(0.),
|
||||||
active_color: config.color,
|
active_color: config.color,
|
||||||
inactive_color: config.color,
|
inactive_color: config.color,
|
||||||
|
urgent_color: config.color,
|
||||||
active_gradient: config.gradient,
|
active_gradient: config.gradient,
|
||||||
inactive_gradient: config.gradient,
|
inactive_gradient: config.gradient,
|
||||||
|
urgent_gradient: config.gradient,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +52,7 @@ impl InsertHintElement {
|
|||||||
scale: f64,
|
scale: f64,
|
||||||
) {
|
) {
|
||||||
self.inner
|
self.inner
|
||||||
.update_render_elements(size, true, false, view_rect, radius, scale, 1.);
|
.update_render_elements(size, true, false, false, view_rect, radius, scale, 1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(
|
pub fn render(
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ impl<W: LayoutElement> Tile<W> {
|
|||||||
self.animated_window_size(),
|
self.animated_window_size(),
|
||||||
is_active,
|
is_active,
|
||||||
!draw_border_with_background,
|
!draw_border_with_background,
|
||||||
|
self.window.is_urgent(),
|
||||||
Rectangle::new(
|
Rectangle::new(
|
||||||
view_rect.loc - Point::from((border_width, border_width)),
|
view_rect.loc - Point::from((border_width, border_width)),
|
||||||
view_rect.size,
|
view_rect.size,
|
||||||
@@ -400,6 +401,7 @@ impl<W: LayoutElement> Tile<W> {
|
|||||||
self.animated_tile_size(),
|
self.animated_tile_size(),
|
||||||
is_active,
|
is_active,
|
||||||
!draw_focus_ring_with_background,
|
!draw_focus_ring_with_background,
|
||||||
|
self.window.is_urgent(),
|
||||||
view_rect,
|
view_rect,
|
||||||
radius,
|
radius,
|
||||||
self.scale,
|
self.scale,
|
||||||
|
|||||||
@@ -191,8 +191,10 @@ impl ResolvedWindowRules {
|
|||||||
width: None,
|
width: None,
|
||||||
active_color: None,
|
active_color: None,
|
||||||
inactive_color: None,
|
inactive_color: None,
|
||||||
|
urgent_color: None,
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
},
|
},
|
||||||
border: BorderRule {
|
border: BorderRule {
|
||||||
off: false,
|
off: false,
|
||||||
@@ -200,8 +202,10 @@ impl ResolvedWindowRules {
|
|||||||
width: None,
|
width: None,
|
||||||
active_color: None,
|
active_color: None,
|
||||||
inactive_color: None,
|
inactive_color: None,
|
||||||
|
urgent_color: None,
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
},
|
},
|
||||||
shadow: ShadowRule {
|
shadow: ShadowRule {
|
||||||
off: false,
|
off: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user