Skip to content

Commit 972eefc

Browse files
committed
add urgent border color and gradient
1 parent b9baa93 commit 972eefc

File tree

7 files changed

+48
-1
lines changed

7 files changed

+48
-1
lines changed

niri-config/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,14 @@ pub struct FocusRing {
568568
pub active_color: Color,
569569
#[knuffel(child, default = Self::default().inactive_color)]
570570
pub inactive_color: Color,
571+
#[knuffel(child, default = Self::default().urgent_color)]
572+
pub urgent_color: Color,
571573
#[knuffel(child)]
572574
pub active_gradient: Option<Gradient>,
573575
#[knuffel(child)]
574576
pub inactive_gradient: Option<Gradient>,
577+
#[knuffel(child)]
578+
pub urgent_gradient: Option<Gradient>,
575579
}
576580

577581
impl Default for FocusRing {
@@ -581,8 +585,10 @@ impl Default for FocusRing {
581585
width: FloatOrInt(4.),
582586
active_color: Color::from_rgba8_unpremul(127, 200, 255, 255),
583587
inactive_color: Color::from_rgba8_unpremul(80, 80, 80, 255),
588+
urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255),
584589
active_gradient: None,
585590
inactive_gradient: None,
591+
urgent_gradient: None,
586592
}
587593
}
588594
}
@@ -654,10 +660,14 @@ pub struct Border {
654660
pub active_color: Color,
655661
#[knuffel(child, default = Self::default().inactive_color)]
656662
pub inactive_color: Color,
663+
#[knuffel(child, default = Self::default().urgent_color)]
664+
pub urgent_color: Color,
657665
#[knuffel(child)]
658666
pub active_gradient: Option<Gradient>,
659667
#[knuffel(child)]
660668
pub inactive_gradient: Option<Gradient>,
669+
#[knuffel(child)]
670+
pub urgent_gradient: Option<Gradient>,
661671
}
662672

663673
impl Default for Border {
@@ -667,8 +677,10 @@ impl Default for Border {
667677
width: FloatOrInt(4.),
668678
active_color: Color::from_rgba8_unpremul(255, 200, 127, 255),
669679
inactive_color: Color::from_rgba8_unpremul(80, 80, 80, 255),
680+
urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255),
670681
active_gradient: None,
671682
inactive_gradient: None,
683+
urgent_gradient: None,
672684
}
673685
}
674686
}
@@ -680,8 +692,10 @@ impl From<Border> for FocusRing {
680692
width: value.width,
681693
active_color: value.active_color,
682694
inactive_color: value.inactive_color,
695+
urgent_color: value.urgent_color,
683696
active_gradient: value.active_gradient,
684697
inactive_gradient: value.inactive_gradient,
698+
urgent_gradient: value.urgent_gradient,
685699
}
686700
}
687701
}
@@ -693,8 +707,10 @@ impl From<FocusRing> for Border {
693707
width: value.width,
694708
active_color: value.active_color,
695709
inactive_color: value.inactive_color,
710+
urgent_color: value.urgent_color,
696711
active_gradient: value.active_gradient,
697712
inactive_gradient: value.inactive_gradient,
713+
urgent_gradient: value.urgent_gradient,
698714
}
699715
}
700716
}
@@ -4134,6 +4150,12 @@ mod tests {
41344150
b: 0.39215687,
41354151
a: 0.0,
41364152
},
4153+
urgent_color: Color {
4154+
r: 0.60784316,
4155+
g: 0.0,
4156+
b: 0.0,
4157+
a: 1.0,
4158+
},
41374159
active_gradient: Some(
41384160
Gradient {
41394161
from: Color {
@@ -4157,6 +4179,7 @@ mod tests {
41574179
},
41584180
),
41594181
inactive_gradient: None,
4182+
urgent_gradient: None,
41604183
},
41614184
border: Border {
41624185
off: false,
@@ -4175,8 +4198,15 @@ mod tests {
41754198
b: 0.39215687,
41764199
a: 0.0,
41774200
},
4201+
urgent_color: Color {
4202+
r: 0.60784316,
4203+
g: 0.0,
4204+
b: 0.0,
4205+
a: 1.0,
4206+
},
41784207
active_gradient: None,
41794208
inactive_gradient: None,
4209+
urgent_gradient: None,
41804210
},
41814211
shadow: Shadow {
41824212
on: false,

niri-visual-tests/src/cases/gradient_area.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ impl GradientArea {
2323
width: FloatOrInt(1.),
2424
active_color: Color::from_rgba8_unpremul(255, 255, 255, 128),
2525
inactive_color: Color::default(),
26+
urgent_color: Color::default(),
2627
active_gradient: None,
2728
inactive_gradient: None,
29+
urgent_gradient: None,
2830
});
2931

3032
Self {
@@ -81,6 +83,7 @@ impl TestCase for GradientArea {
8183
g_size,
8284
true,
8385
true,
86+
false,
8487
Rectangle::default(),
8588
CornerRadius::default(),
8689
1.,

niri-visual-tests/src/cases/layout.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ impl Layout {
6060
width: FloatOrInt(4.),
6161
active_color: Color::from_rgba8_unpremul(255, 163, 72, 255),
6262
inactive_color: Color::from_rgba8_unpremul(50, 50, 50, 255),
63+
urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255),
6364
active_gradient: None,
6465
inactive_gradient: None,
66+
urgent_gradient: None,
6567
},
6668
..Default::default()
6769
};

resources/default-config.kdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ layout {
188188
width 4
189189
active-color "#ffc87f"
190190
inactive-color "#505050"
191+
urgent-color "#9b0000"
191192

192193
// active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view"
193194
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"

src/layout/focus_ring.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl FocusRing {
5959
win_size: Size<f64, Logical>,
6060
is_active: bool,
6161
is_border: bool,
62+
is_urgent: bool,
6263
view_rect: Rectangle<f64, Logical>,
6364
radius: CornerRadius,
6465
scale: f64,
@@ -69,6 +70,8 @@ impl FocusRing {
6970

7071
let color = if is_active {
7172
self.config.active_color
73+
} else if is_urgent {
74+
self.config.urgent_color
7275
} else {
7376
self.config.inactive_color
7477
};
@@ -81,6 +84,8 @@ impl FocusRing {
8184

8285
let gradient = if is_active {
8386
self.config.active_gradient
87+
} else if is_urgent {
88+
self.config.urgent_gradient
8489
} else {
8590
self.config.inactive_gradient
8691
};

src/layout/insert_hint_element.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ impl InsertHintElement {
1919
width: FloatOrInt(0.),
2020
active_color: config.color,
2121
inactive_color: config.color,
22+
urgent_color: config.color,
2223
active_gradient: config.gradient,
2324
inactive_gradient: config.gradient,
25+
urgent_gradient: config.gradient,
2426
}),
2527
}
2628
}
@@ -31,8 +33,10 @@ impl InsertHintElement {
3133
width: FloatOrInt(0.),
3234
active_color: config.color,
3335
inactive_color: config.color,
36+
urgent_color: config.color,
3437
active_gradient: config.gradient,
3538
inactive_gradient: config.gradient,
39+
urgent_gradient: config.gradient,
3640
});
3741
}
3842

@@ -48,7 +52,7 @@ impl InsertHintElement {
4852
scale: f64,
4953
) {
5054
self.inner
51-
.update_render_elements(size, true, false, view_rect, radius, scale, 1.);
55+
.update_render_elements(size, true, false, false, view_rect, radius, scale, 1.);
5256
}
5357

5458
pub fn render(

src/layout/tile.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ impl<W: LayoutElement> Tile<W> {
366366
self.animated_window_size(),
367367
is_active,
368368
!draw_border_with_background,
369+
self.window.is_urgent(),
369370
Rectangle::new(
370371
view_rect.loc - Point::from((border_width, border_width)),
371372
view_rect.size,
@@ -400,6 +401,7 @@ impl<W: LayoutElement> Tile<W> {
400401
self.animated_tile_size(),
401402
is_active,
402403
!draw_focus_ring_with_background,
404+
self.window.is_urgent(),
403405
view_rect,
404406
radius,
405407
self.scale,

0 commit comments

Comments
 (0)