mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
tab indicator: Add hide-when-single-tab
This commit is contained in:
@@ -683,6 +683,8 @@ pub struct ShadowOffset {
|
||||
pub struct TabIndicator {
|
||||
#[knuffel(child)]
|
||||
pub off: bool,
|
||||
#[knuffel(child)]
|
||||
pub hide_when_single_tab: bool,
|
||||
#[knuffel(child, unwrap(argument), default = Self::default().gap)]
|
||||
pub gap: FloatOrInt<-65535, 65535>,
|
||||
#[knuffel(child, unwrap(argument), default = Self::default().width)]
|
||||
@@ -703,6 +705,7 @@ impl Default for TabIndicator {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
off: false,
|
||||
hide_when_single_tab: false,
|
||||
gap: FloatOrInt(5.),
|
||||
width: FloatOrInt(4.),
|
||||
length: TabIndicatorLength {
|
||||
|
||||
@@ -63,6 +63,13 @@ impl TabIndicator {
|
||||
return;
|
||||
}
|
||||
|
||||
let count = tabs.clone().count();
|
||||
if self.config.hide_when_single_tab && count == 1 {
|
||||
self.shader_locs.clear();
|
||||
self.shaders.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// Tab indicators are rendered relative to the tile geometry.
|
||||
let tile_geo = Rectangle::new(Point::from((0., 0.)), tile_size);
|
||||
|
||||
@@ -74,7 +81,6 @@ impl TabIndicator {
|
||||
let total_prop = self.config.length.total_proportion.unwrap_or(0.5);
|
||||
let min_length = round(tile_size.h * total_prop.clamp(0., 2.));
|
||||
|
||||
let count = tabs.clone().count();
|
||||
self.shaders.resize_with(count, Default::default);
|
||||
self.shader_locs.resize_with(count, Default::default);
|
||||
|
||||
|
||||
@@ -3242,12 +3242,14 @@ prop_compose! {
|
||||
prop_compose! {
|
||||
fn arbitrary_tab_indicator()(
|
||||
off in any::<bool>(),
|
||||
hide_when_single_tab in any::<bool>(),
|
||||
width in arbitrary_spacing(),
|
||||
gap in arbitrary_spacing_neg(),
|
||||
length in (0f64..2f64),
|
||||
) -> niri_config::TabIndicator {
|
||||
niri_config::TabIndicator {
|
||||
off,
|
||||
hide_when_single_tab,
|
||||
width: FloatOrInt(width),
|
||||
gap: FloatOrInt(gap),
|
||||
length: TabIndicatorLength { total_proportion: Some(length) },
|
||||
|
||||
Reference in New Issue
Block a user