add urgent border color and gradient
Browse files at this commit398bc78ea073e0e61c6ba67ddcbaad0a5d574eebParent: caa61898 changed files +79 -3
- niri-config/src/lib.rs +53 -0
- niri-visual-tests/src/cases/gradient_area.rs +3 -0
- niri-visual-tests/src/cases/layout.rs +2 -0
- resources/default-config.kdl +3 -0
- src/layout/focus_ring.rs +7 -2
- src/layout/insert_hint_element.rs +5 -1
- src/layout/tile.rs +2 -0
- src/window/mod.rs +4 -0
niri-config/src/lib.rsmodified+53 -0
| @@ -583,10 +583,14 @@ pub struct FocusRing { | |||
| 583 | pub active_color: Color, | 583 | pub active_color: Color, |
| 584 | #[knuffel(child, default = Self::default().inactive_color)] | 584 | #[knuffel(child, default = Self::default().inactive_color)] |
| 585 | pub inactive_color: Color, | 585 | pub inactive_color: Color, |
| 586 | + #[knuffel(child, default = Self::default().urgent_color)] | ||
| 587 | + pub urgent_color: Color, | ||
| 586 | #[knuffel(child)] | 588 | #[knuffel(child)] |
| 587 | pub active_gradient: Option<Gradient>, | 589 | pub active_gradient: Option<Gradient>, |
| 588 | #[knuffel(child)] | 590 | #[knuffel(child)] |
| 589 | pub inactive_gradient: Option<Gradient>, | 591 | pub inactive_gradient: Option<Gradient>, |
| 592 | + #[knuffel(child)] | ||
| 593 | + pub urgent_gradient: Option<Gradient>, | ||
| 590 | } | 594 | } |
| 591 | 595 | ||
| 592 | impl Default for FocusRing { | 596 | impl Default for FocusRing { |
| @@ -596,8 +600,10 @@ impl Default for FocusRing { | |||
| 596 | width: FloatOrInt(4.), | 600 | width: FloatOrInt(4.), |
| 597 | active_color: Color::from_rgba8_unpremul(127, 200, 255, 255), | 601 | active_color: Color::from_rgba8_unpremul(127, 200, 255, 255), |
| 598 | inactive_color: Color::from_rgba8_unpremul(80, 80, 80, 255), | 602 | inactive_color: Color::from_rgba8_unpremul(80, 80, 80, 255), |
| 603 | + urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255), | ||
| 599 | active_gradient: None, | 604 | active_gradient: None, |
| 600 | inactive_gradient: None, | 605 | inactive_gradient: None, |
| 606 | + urgent_gradient: None, | ||
| 601 | } | 607 | } |
| 602 | } | 608 | } |
| 603 | } | 609 | } |
| @@ -669,10 +675,14 @@ pub struct Border { | |||
| 669 | pub active_color: Color, | 675 | pub active_color: Color, |
| 670 | #[knuffel(child, default = Self::default().inactive_color)] | 676 | #[knuffel(child, default = Self::default().inactive_color)] |
| 671 | pub inactive_color: Color, | 677 | pub inactive_color: Color, |
| 678 | + #[knuffel(child, default = Self::default().urgent_color)] | ||
| 679 | + pub urgent_color: Color, | ||
| 672 | #[knuffel(child)] | 680 | #[knuffel(child)] |
| 673 | pub active_gradient: Option<Gradient>, | 681 | pub active_gradient: Option<Gradient>, |
| 674 | #[knuffel(child)] | 682 | #[knuffel(child)] |
| 675 | pub inactive_gradient: Option<Gradient>, | 683 | pub inactive_gradient: Option<Gradient>, |
| 684 | + #[knuffel(child)] | ||
| 685 | + pub urgent_gradient: Option<Gradient>, | ||
| 676 | } | 686 | } |
| 677 | 687 | ||
| 678 | impl Default for Border { | 688 | impl Default for Border { |
| @@ -682,8 +692,10 @@ impl Default for Border { | |||
| 682 | width: FloatOrInt(4.), | 692 | width: FloatOrInt(4.), |
| 683 | active_color: Color::from_rgba8_unpremul(255, 200, 127, 255), | 693 | active_color: Color::from_rgba8_unpremul(255, 200, 127, 255), |
| 684 | inactive_color: Color::from_rgba8_unpremul(80, 80, 80, 255), | 694 | inactive_color: Color::from_rgba8_unpremul(80, 80, 80, 255), |
| 695 | + urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255), | ||
| 685 | active_gradient: None, | 696 | active_gradient: None, |
| 686 | inactive_gradient: None, | 697 | inactive_gradient: None, |
| 698 | + urgent_gradient: None, | ||
| 687 | } | 699 | } |
| 688 | } | 700 | } |
| 689 | } | 701 | } |
| @@ -695,8 +707,10 @@ impl From<Border> for FocusRing { | |||
| 695 | width: value.width, | 707 | width: value.width, |
| 696 | active_color: value.active_color, | 708 | active_color: value.active_color, |
| 697 | inactive_color: value.inactive_color, | 709 | inactive_color: value.inactive_color, |
| 710 | + urgent_color: value.urgent_color, | ||
| 698 | active_gradient: value.active_gradient, | 711 | active_gradient: value.active_gradient, |
| 699 | inactive_gradient: value.inactive_gradient, | 712 | inactive_gradient: value.inactive_gradient, |
| 713 | + urgent_gradient: value.urgent_gradient, | ||
| 700 | } | 714 | } |
| 701 | } | 715 | } |
| 702 | } | 716 | } |
| @@ -708,8 +722,10 @@ impl From<FocusRing> for Border { | |||
| 708 | width: value.width, | 722 | width: value.width, |
| 709 | active_color: value.active_color, | 723 | active_color: value.active_color, |
| 710 | inactive_color: value.inactive_color, | 724 | inactive_color: value.inactive_color, |
| 725 | + urgent_color: value.urgent_color, | ||
| 711 | active_gradient: value.active_gradient, | 726 | active_gradient: value.active_gradient, |
| 712 | inactive_gradient: value.inactive_gradient, | 727 | inactive_gradient: value.inactive_gradient, |
| 728 | + urgent_gradient: value.urgent_gradient, | ||
| 713 | } | 729 | } |
| 714 | } | 730 | } |
| 715 | } | 731 | } |
| @@ -1487,9 +1503,13 @@ pub struct BorderRule { | |||
| 1487 | #[knuffel(child)] | 1503 | #[knuffel(child)] |
| 1488 | pub inactive_color: Option<Color>, | 1504 | pub inactive_color: Option<Color>, |
| 1489 | #[knuffel(child)] | 1505 | #[knuffel(child)] |
| 1506 | + pub urgent_color: Option<Color>, | ||
| 1507 | + #[knuffel(child)] | ||
| 1490 | pub active_gradient: Option<Gradient>, | 1508 | pub active_gradient: Option<Gradient>, |
| 1491 | #[knuffel(child)] | 1509 | #[knuffel(child)] |
| 1492 | pub inactive_gradient: Option<Gradient>, | 1510 | pub inactive_gradient: Option<Gradient>, |
| 1511 | + #[knuffel(child)] | ||
| 1512 | + pub urgent_gradient: Option<Gradient>, | ||
| 1493 | } | 1513 | } |
| 1494 | 1514 | ||
| 1495 | #[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)] | 1515 | #[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)] |
| @@ -2353,12 +2373,18 @@ impl BorderRule { | |||
| 2353 | if let Some(x) = other.inactive_color { | 2373 | if let Some(x) = other.inactive_color { |
| 2354 | self.inactive_color = Some(x); | 2374 | self.inactive_color = Some(x); |
| 2355 | } | 2375 | } |
| 2376 | + if let Some(x) = other.urgent_color { | ||
| 2377 | + self.urgent_color = Some(x); | ||
| 2378 | + } | ||
| 2356 | if let Some(x) = other.active_gradient { | 2379 | if let Some(x) = other.active_gradient { |
| 2357 | self.active_gradient = Some(x); | 2380 | self.active_gradient = Some(x); |
| 2358 | } | 2381 | } |
| 2359 | if let Some(x) = other.inactive_gradient { | 2382 | if let Some(x) = other.inactive_gradient { |
| 2360 | self.inactive_gradient = Some(x); | 2383 | self.inactive_gradient = Some(x); |
| 2361 | } | 2384 | } |
| 2385 | + if let Some(x) = other.urgent_gradient { | ||
| 2386 | + self.urgent_gradient = Some(x); | ||
| 2387 | + } | ||
| 2362 | } | 2388 | } |
| 2363 | 2389 | ||
| 2364 | pub fn resolve_against(&self, mut config: Border) -> Border { | 2390 | pub fn resolve_against(&self, mut config: Border) -> Border { |
| @@ -2378,12 +2404,19 @@ impl BorderRule { | |||
| 2378 | config.inactive_color = x; | 2404 | config.inactive_color = x; |
| 2379 | config.inactive_gradient = None; | 2405 | config.inactive_gradient = None; |
| 2380 | } | 2406 | } |
| 2407 | + if let Some(x) = self.urgent_color { | ||
| 2408 | + config.urgent_color = x; | ||
| 2409 | + config.urgent_gradient = None; | ||
| 2410 | + } | ||
| 2381 | if let Some(x) = self.active_gradient { | 2411 | if let Some(x) = self.active_gradient { |
| 2382 | config.active_gradient = Some(x); | 2412 | config.active_gradient = Some(x); |
| 2383 | } | 2413 | } |
| 2384 | if let Some(x) = self.inactive_gradient { | 2414 | if let Some(x) = self.inactive_gradient { |
| 2385 | config.inactive_gradient = Some(x); | 2415 | config.inactive_gradient = Some(x); |
| 2386 | } | 2416 | } |
| 2417 | + if let Some(x) = self.urgent_gradient { | ||
| 2418 | + config.urgent_gradient = Some(x); | ||
| 2419 | + } | ||
| 2387 | 2420 | ||
| 2388 | config | 2421 | config |
| 2389 | } | 2422 | } |
| @@ -4321,6 +4354,12 @@ mod tests { | |||
| 4321 | b: 0.39215687, | 4354 | b: 0.39215687, |
| 4322 | a: 0.0, | 4355 | a: 0.0, |
| 4323 | }, | 4356 | }, |
| 4357 | + urgent_color: Color { | ||
| 4358 | + r: 0.60784316, | ||
| 4359 | + g: 0.0, | ||
| 4360 | + b: 0.0, | ||
| 4361 | + a: 1.0, | ||
| 4362 | + }, | ||
| 4324 | active_gradient: Some( | 4363 | active_gradient: Some( |
| 4325 | Gradient { | 4364 | Gradient { |
| 4326 | from: Color { | 4365 | from: Color { |
| @@ -4344,6 +4383,7 @@ mod tests { | |||
| 4344 | }, | 4383 | }, |
| 4345 | ), | 4384 | ), |
| 4346 | inactive_gradient: None, | 4385 | inactive_gradient: None, |
| 4386 | + urgent_gradient: None, | ||
| 4347 | }, | 4387 | }, |
| 4348 | border: Border { | 4388 | border: Border { |
| 4349 | off: false, | 4389 | off: false, |
| @@ -4362,8 +4402,15 @@ mod tests { | |||
| 4362 | b: 0.39215687, | 4402 | b: 0.39215687, |
| 4363 | a: 0.0, | 4403 | a: 0.0, |
| 4364 | }, | 4404 | }, |
| 4405 | + urgent_color: Color { | ||
| 4406 | + r: 0.60784316, | ||
| 4407 | + g: 0.0, | ||
| 4408 | + b: 0.0, | ||
| 4409 | + a: 1.0, | ||
| 4410 | + }, | ||
| 4365 | active_gradient: None, | 4411 | active_gradient: None, |
| 4366 | inactive_gradient: None, | 4412 | inactive_gradient: None, |
| 4413 | + urgent_gradient: None, | ||
| 4367 | }, | 4414 | }, |
| 4368 | shadow: Shadow { | 4415 | shadow: Shadow { |
| 4369 | on: false, | 4416 | on: false, |
| @@ -4805,8 +4852,10 @@ mod tests { | |||
| 4805 | ), | 4852 | ), |
| 4806 | active_color: None, | 4853 | active_color: None, |
| 4807 | inactive_color: None, | 4854 | inactive_color: None, |
| 4855 | + urgent_color: None, | ||
| 4808 | active_gradient: None, | 4856 | active_gradient: None, |
| 4809 | inactive_gradient: None, | 4857 | inactive_gradient: None, |
| 4858 | + urgent_gradient: None, | ||
| 4810 | }, | 4859 | }, |
| 4811 | border: BorderRule { | 4860 | border: BorderRule { |
| 4812 | off: false, | 4861 | off: false, |
| @@ -4818,8 +4867,10 @@ mod tests { | |||
| 4818 | ), | 4867 | ), |
| 4819 | active_color: None, | 4868 | active_color: None, |
| 4820 | inactive_color: None, | 4869 | inactive_color: None, |
| 4870 | + urgent_color: None, | ||
| 4821 | active_gradient: None, | 4871 | active_gradient: None, |
| 4822 | inactive_gradient: None, | 4872 | inactive_gradient: None, |
| 4873 | + urgent_gradient: None, | ||
| 4823 | }, | 4874 | }, |
| 4824 | shadow: ShadowRule { | 4875 | shadow: ShadowRule { |
| 4825 | off: false, | 4876 | off: false, |
| @@ -5552,8 +5603,10 @@ mod tests { | |||
| 5552 | width: None, | 5603 | width: None, |
| 5553 | active_color: None, | 5604 | active_color: None, |
| 5554 | inactive_color: None, | 5605 | inactive_color: None, |
| 5606 | + urgent_color: None, | ||
| 5555 | active_gradient: None, | 5607 | active_gradient: None, |
| 5556 | inactive_gradient: None, | 5608 | inactive_gradient: None, |
| 5609 | + urgent_gradient: None, | ||
| 5557 | }; | 5610 | }; |
| 5558 | 5611 | ||
| 5559 | for rule in rules.iter().copied() { | 5612 | for rule in rules.iter().copied() { |
niri-visual-tests/src/cases/gradient_area.rsmodified+3 -0
| @@ -23,8 +23,10 @@ impl GradientArea { | |||
| 23 | width: FloatOrInt(1.), | 23 | width: FloatOrInt(1.), |
| 24 | active_color: Color::from_rgba8_unpremul(255, 255, 255, 128), | 24 | active_color: Color::from_rgba8_unpremul(255, 255, 255, 128), |
| 25 | inactive_color: Color::default(), | 25 | inactive_color: Color::default(), |
| 26 | + urgent_color: Color::default(), | ||
| 26 | active_gradient: None, | 27 | active_gradient: None, |
| 27 | inactive_gradient: None, | 28 | inactive_gradient: None, |
| 29 | + urgent_gradient: None, | ||
| 28 | }); | 30 | }); |
| 29 | 31 | ||
| 30 | Self { | 32 | Self { |
| @@ -81,6 +83,7 @@ impl TestCase for GradientArea { | |||
| 81 | g_size, | 83 | g_size, |
| 82 | true, | 84 | true, |
| 83 | true, | 85 | true, |
| 86 | + false, | ||
| 84 | Rectangle::default(), | 87 | Rectangle::default(), |
| 85 | CornerRadius::default(), | 88 | CornerRadius::default(), |
| 86 | 1., | 89 | 1., |
niri-visual-tests/src/cases/layout.rsmodified+2 -0
| @@ -60,8 +60,10 @@ impl Layout { | |||
| 60 | width: FloatOrInt(4.), | 60 | width: FloatOrInt(4.), |
| 61 | active_color: Color::from_rgba8_unpremul(255, 163, 72, 255), | 61 | active_color: Color::from_rgba8_unpremul(255, 163, 72, 255), |
| 62 | inactive_color: Color::from_rgba8_unpremul(50, 50, 50, 255), | 62 | inactive_color: Color::from_rgba8_unpremul(50, 50, 50, 255), |
| 63 | + urgent_color: Color::from_rgba8_unpremul(155, 0, 0, 255), | ||
| 63 | active_gradient: None, | 64 | active_gradient: None, |
| 64 | inactive_gradient: None, | 65 | inactive_gradient: None, |
| 66 | + urgent_gradient: None, | ||
| 65 | }, | 67 | }, |
| 66 | ..Default::default() | 68 | ..Default::default() |
| 67 | }; | 69 | }; |
resources/default-config.kdlmodified+3 -0
| @@ -192,6 +192,9 @@ layout { | |||
| 192 | active-color "#ffc87f" | 192 | active-color "#ffc87f" |
| 193 | inactive-color "#505050" | 193 | inactive-color "#505050" |
| 194 | 194 | ||
| 195 | + // Color of the border around windows that request your attention. | ||
| 196 | + urgent-color "#9b0000" | ||
| 197 | + | ||
| 195 | // active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view" | 198 | // active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view" |
| 196 | // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" | 199 | // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" |
| 197 | } | 200 | } |
src/layout/focus_ring.rsmodified+7 -2
| @@ -59,6 +59,7 @@ impl FocusRing { | |||
| 59 | win_size: Size<f64, Logical>, | 59 | win_size: Size<f64, Logical>, |
| 60 | is_active: bool, | 60 | is_active: bool, |
| 61 | is_border: bool, | 61 | is_border: bool, |
| 62 | + is_urgent: bool, | ||
| 62 | view_rect: Rectangle<f64, Logical>, | 63 | view_rect: Rectangle<f64, Logical>, |
| 63 | radius: CornerRadius, | 64 | radius: CornerRadius, |
| 64 | scale: f64, | 65 | scale: f64, |
| @@ -67,7 +68,9 @@ impl FocusRing { | |||
| 67 | let width = self.config.width.0; | 68 | let width = self.config.width.0; |
| 68 | self.full_size = win_size + Size::from((width, width)).upscale(2.); | 69 | self.full_size = win_size + Size::from((width, width)).upscale(2.); |
| 69 | 70 | ||
| 70 | - let color = if is_active { | 71 | + let color = if is_urgent { |
| 72 | + self.config.urgent_color | ||
| 73 | + } else if is_active { | ||
| 71 | self.config.active_color | 74 | self.config.active_color |
| 72 | } else { | 75 | } else { |
| 73 | self.config.inactive_color | 76 | self.config.inactive_color |
| @@ -79,7 +82,9 @@ impl FocusRing { | |||
| 79 | 82 | ||
| 80 | let radius = radius.fit_to(self.full_size.w as f32, self.full_size.h as f32); | 83 | let radius = radius.fit_to(self.full_size.w as f32, self.full_size.h as f32); |
| 81 | 84 | ||
| 82 | - let gradient = if is_active { | 85 | + let gradient = if is_urgent { |
| 86 | + self.config.urgent_gradient | ||
| 87 | + } else if is_active { | ||
| 83 | self.config.active_gradient | 88 | self.config.active_gradient |
| 84 | } else { | 89 | } else { |
| 85 | self.config.inactive_gradient | 90 | self.config.inactive_gradient |
src/layout/insert_hint_element.rsmodified+5 -1
| @@ -19,8 +19,10 @@ impl InsertHintElement { | |||
| 19 | width: FloatOrInt(0.), | 19 | width: FloatOrInt(0.), |
| 20 | active_color: config.color, | 20 | active_color: config.color, |
| 21 | inactive_color: config.color, | 21 | inactive_color: config.color, |
| 22 | + urgent_color: config.color, | ||
| 22 | active_gradient: config.gradient, | 23 | active_gradient: config.gradient, |
| 23 | inactive_gradient: config.gradient, | 24 | inactive_gradient: config.gradient, |
| 25 | + urgent_gradient: config.gradient, | ||
| 24 | }), | 26 | }), |
| 25 | } | 27 | } |
| 26 | } | 28 | } |
| @@ -31,8 +33,10 @@ impl InsertHintElement { | |||
| 31 | width: FloatOrInt(0.), | 33 | width: FloatOrInt(0.), |
| 32 | active_color: config.color, | 34 | active_color: config.color, |
| 33 | inactive_color: config.color, | 35 | inactive_color: config.color, |
| 36 | + urgent_color: config.color, | ||
| 34 | active_gradient: config.gradient, | 37 | active_gradient: config.gradient, |
| 35 | inactive_gradient: config.gradient, | 38 | inactive_gradient: config.gradient, |
| 39 | + urgent_gradient: config.gradient, | ||
| 36 | }); | 40 | }); |
| 37 | } | 41 | } |
| 38 | 42 | ||
| @@ -48,7 +52,7 @@ impl InsertHintElement { | |||
| 48 | scale: f64, | 52 | scale: f64, |
| 49 | ) { | 53 | ) { |
| 50 | self.inner | 54 | 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.); |
| 52 | } | 56 | } |
| 53 | 57 | ||
| 54 | pub fn render( | 58 | pub fn render( |
src/layout/tile.rsmodified+2 -0
| @@ -366,6 +366,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 366 | self.animated_window_size(), | 366 | self.animated_window_size(), |
| 367 | is_active, | 367 | is_active, |
| 368 | !draw_border_with_background, | 368 | !draw_border_with_background, |
| 369 | + self.window.is_urgent(), | ||
| 369 | Rectangle::new( | 370 | Rectangle::new( |
| 370 | view_rect.loc - Point::from((border_width, border_width)), | 371 | view_rect.loc - Point::from((border_width, border_width)), |
| 371 | view_rect.size, | 372 | view_rect.size, |
| @@ -400,6 +401,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 400 | self.animated_tile_size(), | 401 | self.animated_tile_size(), |
| 401 | is_active, | 402 | is_active, |
| 402 | !draw_focus_ring_with_background, | 403 | !draw_focus_ring_with_background, |
| 404 | + self.window.is_urgent(), | ||
| 403 | view_rect, | 405 | view_rect, |
| 404 | radius, | 406 | radius, |
| 405 | self.scale, | 407 | self.scale, |
src/window/mod.rsmodified+4 -0
| @@ -191,8 +191,10 @@ impl ResolvedWindowRules { | |||
| 191 | width: None, | 191 | width: None, |
| 192 | active_color: None, | 192 | active_color: None, |
| 193 | inactive_color: None, | 193 | inactive_color: None, |
| 194 | + urgent_color: None, | ||
| 194 | active_gradient: None, | 195 | active_gradient: None, |
| 195 | inactive_gradient: None, | 196 | inactive_gradient: None, |
| 197 | + urgent_gradient: None, | ||
| 196 | }, | 198 | }, |
| 197 | border: BorderRule { | 199 | border: BorderRule { |
| 198 | off: false, | 200 | off: false, |
| @@ -200,8 +202,10 @@ impl ResolvedWindowRules { | |||
| 200 | width: None, | 202 | width: None, |
| 201 | active_color: None, | 203 | active_color: None, |
| 202 | inactive_color: None, | 204 | inactive_color: None, |
| 205 | + urgent_color: None, | ||
| 203 | active_gradient: None, | 206 | active_gradient: None, |
| 204 | inactive_gradient: None, | 207 | inactive_gradient: None, |
| 208 | + urgent_gradient: None, | ||
| 205 | }, | 209 | }, |
| 206 | shadow: ShadowRule { | 210 | shadow: ShadowRule { |
| 207 | off: false, | 211 | off: false, |