diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-05-10 22:34:53 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-05-10 22:42:45 +0300 |
| commit | 58166914607025ae9fb20d868138238bebd4c6bc (patch) | |
| tree | 9c1b583ecfd03b98a74288749b682166ceb2c16e | |
| parent | 4b5e9e6cb08d269506cad8273ca7e9c93378034e (diff) | |
| download | niri-58166914607025ae9fb20d868138238bebd4c6bc.tar.gz niri-58166914607025ae9fb20d868138238bebd4c6bc.tar.bz2 niri-58166914607025ae9fb20d868138238bebd4c6bc.zip | |
Add urgent color support to tab indicators
| -rw-r--r-- | niri-config/src/lib.rs | 20 | ||||
| -rw-r--r-- | src/layout/scrolling.rs | 3 | ||||
| -rw-r--r-- | src/layout/tab_indicator.rs | 13 | ||||
| -rw-r--r-- | src/window/mod.rs | 2 | ||||
| -rw-r--r-- | wiki/Configuration:-Layout.md | 4 | ||||
| -rw-r--r-- | wiki/Configuration:-Window-Rules.md | 2 |
6 files changed, 39 insertions, 5 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index b63cdd03..10ed31b5 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -841,9 +841,13 @@ pub struct TabIndicator { #[knuffel(child)] pub inactive_color: Option<Color>, #[knuffel(child)] + pub urgent_color: Option<Color>, + #[knuffel(child)] pub active_gradient: Option<Gradient>, #[knuffel(child)] pub inactive_gradient: Option<Gradient>, + #[knuffel(child)] + pub urgent_gradient: Option<Gradient>, } impl Default for TabIndicator { @@ -862,8 +866,10 @@ impl Default for TabIndicator { corner_radius: FloatOrInt(0.), active_color: None, inactive_color: None, + urgent_color: None, active_gradient: None, inactive_gradient: None, + urgent_gradient: None, } } } @@ -1539,9 +1545,13 @@ pub struct TabIndicatorRule { #[knuffel(child)] pub inactive_color: Option<Color>, #[knuffel(child)] + pub urgent_color: Option<Color>, + #[knuffel(child)] pub active_gradient: Option<Gradient>, #[knuffel(child)] pub inactive_gradient: Option<Gradient>, + #[knuffel(child)] + pub urgent_gradient: Option<Gradient>, } #[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] @@ -2500,12 +2510,18 @@ impl TabIndicatorRule { if let Some(x) = other.inactive_color { self.inactive_color = Some(x); } + if let Some(x) = other.urgent_color { + self.urgent_color = Some(x); + } if let Some(x) = other.active_gradient { self.active_gradient = Some(x); } if let Some(x) = other.inactive_gradient { self.inactive_gradient = Some(x); } + if let Some(x) = other.urgent_gradient { + self.urgent_gradient = Some(x); + } } } @@ -4470,8 +4486,10 @@ mod tests { ), active_color: None, inactive_color: None, + urgent_color: None, active_gradient: None, inactive_gradient: None, + urgent_gradient: None, }, insert_hint: InsertHint { off: false, @@ -4901,8 +4919,10 @@ mod tests { }, ), inactive_color: None, + urgent_color: None, active_gradient: None, inactive_gradient: None, + urgent_gradient: None, }, draw_border_with_background: None, opacity: None, diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index 5f746915..bd68a65a 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -3820,8 +3820,9 @@ impl<W: LayoutElement> Column<W> { .enumerate() .map(|(tile_idx, (tile, tile_off))| { let is_active = tile_idx == active_idx; + let is_urgent = tile.window().is_urgent(); let tile_pos = tile_off + tile.render_offset(); - TabInfo::from_tile(tile, tile_pos, is_active, &config) + TabInfo::from_tile(tile, tile_pos, is_active, is_urgent, &config) }); // Hide the tab indicator in fullscreen. If you have it configured to overlap the window, diff --git a/src/layout/tab_indicator.rs b/src/layout/tab_indicator.rs index dd048469..e35874e8 100644 --- a/src/layout/tab_indicator.rs +++ b/src/layout/tab_indicator.rs @@ -350,13 +350,16 @@ impl TabInfo { tile: &Tile<W>, position: Point<f64, Logical>, is_active: bool, + is_urgent: bool, config: &niri_config::TabIndicator, ) -> Self { let rules = tile.window().rules(); let rule = rules.tab_indicator; let gradient_from_rule = || { - let (color, gradient) = if is_active { + let (color, gradient) = if is_urgent { + (rule.urgent_color, rule.urgent_gradient) + } else if is_active { (rule.active_color, rule.active_gradient) } else { (rule.inactive_color, rule.inactive_gradient) @@ -366,7 +369,9 @@ impl TabInfo { }; let gradient_from_config = || { - let (color, gradient) = if is_active { + let (color, gradient) = if is_urgent { + (config.urgent_color, config.urgent_gradient) + } else if is_active { (config.active_color, config.active_gradient) } else { (config.inactive_color, config.inactive_gradient) @@ -386,7 +391,9 @@ impl TabInfo { focus_ring_config }; - let (color, gradient) = if is_active { + let (color, gradient) = if is_urgent { + (config.urgent_color, config.urgent_gradient) + } else if is_active { (config.active_color, config.active_gradient) } else { (config.inactive_color, config.inactive_gradient) diff --git a/src/window/mod.rs b/src/window/mod.rs index 4410febc..71aa607b 100644 --- a/src/window/mod.rs +++ b/src/window/mod.rs @@ -220,8 +220,10 @@ impl ResolvedWindowRules { tab_indicator: TabIndicatorRule { active_color: None, inactive_color: None, + urgent_color: None, active_gradient: None, inactive_gradient: None, + urgent_gradient: None, }, draw_border_with_background: None, opacity: None, diff --git a/wiki/Configuration:-Layout.md b/wiki/Configuration:-Layout.md index a4509eef..d0f7fd44 100644 --- a/wiki/Configuration:-Layout.md +++ b/wiki/Configuration:-Layout.md @@ -71,8 +71,10 @@ layout { corner-radius 8 active-color "red" inactive-color "gray" + urgent-color "blue" // active-gradient from="#80c8ff" to="#bbddff" angle=45 // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" + // urgent-gradient from="#800" to="#a33" angle=45 } insert-hint { @@ -448,7 +450,7 @@ 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. -`active-color`, `inactive-color`, `active-gradient`, `inactive-gradient` let you override the colors for the tabs. +`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. Tab colors are picked in this order: diff --git a/wiki/Configuration:-Window-Rules.md b/wiki/Configuration:-Window-Rules.md index 871f707c..03af8d41 100644 --- a/wiki/Configuration:-Window-Rules.md +++ b/wiki/Configuration:-Window-Rules.md @@ -87,8 +87,10 @@ window-rule { tab-indicator { active-color "red" inactive-color "gray" + urgent-color "blue" // active-gradient from="#80c8ff" to="#bbddff" angle=45 // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" + // urgent-gradient from="#800" to="#a33" angle=45 } geometry-corner-radius 12 |
