mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Add urgent color support to tab indicators
This commit is contained in:
@@ -841,9 +841,13 @@ pub struct TabIndicator {
|
|||||||
#[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>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TabIndicator {
|
impl Default for TabIndicator {
|
||||||
@@ -862,8 +866,10 @@ impl Default for TabIndicator {
|
|||||||
corner_radius: FloatOrInt(0.),
|
corner_radius: FloatOrInt(0.),
|
||||||
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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1539,9 +1545,13 @@ pub struct TabIndicatorRule {
|
|||||||
#[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, Clone, Copy, PartialEq)]
|
#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)]
|
||||||
@@ -2500,12 +2510,18 @@ impl TabIndicatorRule {
|
|||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4470,8 +4486,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,
|
||||||
},
|
},
|
||||||
insert_hint: InsertHint {
|
insert_hint: InsertHint {
|
||||||
off: false,
|
off: false,
|
||||||
@@ -4901,8 +4919,10 @@ mod tests {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
inactive_color: None,
|
inactive_color: None,
|
||||||
|
urgent_color: None,
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
inactive_gradient: None,
|
inactive_gradient: None,
|
||||||
|
urgent_gradient: None,
|
||||||
},
|
},
|
||||||
draw_border_with_background: None,
|
draw_border_with_background: None,
|
||||||
opacity: None,
|
opacity: None,
|
||||||
|
|||||||
@@ -3820,8 +3820,9 @@ impl<W: LayoutElement> Column<W> {
|
|||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(tile_idx, (tile, tile_off))| {
|
.map(|(tile_idx, (tile, tile_off))| {
|
||||||
let is_active = tile_idx == active_idx;
|
let is_active = tile_idx == active_idx;
|
||||||
|
let is_urgent = tile.window().is_urgent();
|
||||||
let tile_pos = tile_off + tile.render_offset();
|
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,
|
// Hide the tab indicator in fullscreen. If you have it configured to overlap the window,
|
||||||
|
|||||||
@@ -350,13 +350,16 @@ impl TabInfo {
|
|||||||
tile: &Tile<W>,
|
tile: &Tile<W>,
|
||||||
position: Point<f64, Logical>,
|
position: Point<f64, Logical>,
|
||||||
is_active: bool,
|
is_active: bool,
|
||||||
|
is_urgent: bool,
|
||||||
config: &niri_config::TabIndicator,
|
config: &niri_config::TabIndicator,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let rules = tile.window().rules();
|
let rules = tile.window().rules();
|
||||||
let rule = rules.tab_indicator;
|
let rule = rules.tab_indicator;
|
||||||
|
|
||||||
let gradient_from_rule = || {
|
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)
|
(rule.active_color, rule.active_gradient)
|
||||||
} else {
|
} else {
|
||||||
(rule.inactive_color, rule.inactive_gradient)
|
(rule.inactive_color, rule.inactive_gradient)
|
||||||
@@ -366,7 +369,9 @@ impl TabInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let gradient_from_config = || {
|
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)
|
(config.active_color, config.active_gradient)
|
||||||
} else {
|
} else {
|
||||||
(config.inactive_color, config.inactive_gradient)
|
(config.inactive_color, config.inactive_gradient)
|
||||||
@@ -386,7 +391,9 @@ impl TabInfo {
|
|||||||
focus_ring_config
|
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)
|
(config.active_color, config.active_gradient)
|
||||||
} else {
|
} else {
|
||||||
(config.inactive_color, config.inactive_gradient)
|
(config.inactive_color, config.inactive_gradient)
|
||||||
|
|||||||
@@ -220,8 +220,10 @@ impl ResolvedWindowRules {
|
|||||||
tab_indicator: TabIndicatorRule {
|
tab_indicator: TabIndicatorRule {
|
||||||
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,
|
||||||
},
|
},
|
||||||
draw_border_with_background: None,
|
draw_border_with_background: None,
|
||||||
opacity: None,
|
opacity: None,
|
||||||
|
|||||||
@@ -71,8 +71,10 @@ layout {
|
|||||||
corner-radius 8
|
corner-radius 8
|
||||||
active-color "red"
|
active-color "red"
|
||||||
inactive-color "gray"
|
inactive-color "gray"
|
||||||
|
urgent-color "blue"
|
||||||
// active-gradient from="#80c8ff" to="#bbddff" angle=45
|
// active-gradient from="#80c8ff" to="#bbddff" angle=45
|
||||||
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
|
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
|
||||||
|
// urgent-gradient from="#800" to="#a33" angle=45
|
||||||
}
|
}
|
||||||
|
|
||||||
insert-hint {
|
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.
|
`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.
|
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.
|
They have the same semantics as the border and focus ring colors and gradients.
|
||||||
|
|
||||||
Tab colors are picked in this order:
|
Tab colors are picked in this order:
|
||||||
|
|||||||
@@ -87,8 +87,10 @@ window-rule {
|
|||||||
tab-indicator {
|
tab-indicator {
|
||||||
active-color "red"
|
active-color "red"
|
||||||
inactive-color "gray"
|
inactive-color "gray"
|
||||||
|
urgent-color "blue"
|
||||||
// active-gradient from="#80c8ff" to="#bbddff" angle=45
|
// active-gradient from="#80c8ff" to="#bbddff" angle=45
|
||||||
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
|
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
|
||||||
|
// urgent-gradient from="#800" to="#a33" angle=45
|
||||||
}
|
}
|
||||||
|
|
||||||
geometry-corner-radius 12
|
geometry-corner-radius 12
|
||||||
|
|||||||
Reference in New Issue
Block a user