summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxVerevkin <maxxverrr@gmail.com>2022-11-27 22:11:08 +0200
committerMaxVerevkin <maxxverrr@gmail.com>2022-11-27 22:11:08 +0200
commitf6727acdd4cc112c51d3dd71df61689738e31de9 (patch)
treee6607e9056bb6cd39115f99e611c5df5a967eb3a /src
parentd28693c9d293ea7c348c0e9e1a4e89ccff6dcae4 (diff)
downloadi3bar-mango-f6727acdd4cc112c51d3dd71df61689738e31de9.tar.gz
WIP: support river-status-unstable-v1 version 3
Depends on https://github.com/riverwm/river/pull/673
Diffstat (limited to 'src')
-rw-r--r--src/bar.rs30
-rw-r--r--src/river_protocols/status.rs14
-rw-r--r--src/state.rs17
3 files changed, 60 insertions, 1 deletions
diff --git a/src/bar.rs b/src/bar.rs
index dfa63a3..b68aefa 100644
--- a/src/bar.rs
+++ b/src/bar.rs
@@ -28,6 +28,7 @@ pub struct Bar {
pub blocks_btns: ButtonManager<(Option<String>, Option<String>)>,
pub river_output_status: Option<RiverOutputStatus>,
pub river_control: Option<RiverControlState>,
+ pub layout_name: Option<String>,
pub tags_btns: ButtonManager,
pub tags_info: TagsInfo,
pub tags_computed: Vec<ComputedText>,
@@ -172,6 +173,35 @@ impl Bar {
}
}
+ // Display layout name
+ if let Some(layout_name) = &self.layout_name {
+ let text = ComputedText::new(
+ layout_name,
+ text::Attributes {
+ font: &ss.config.font,
+ padding_left: 25.0,
+ padding_right: 25.0,
+ min_width: None,
+ align: Default::default(),
+ markup: false,
+ },
+ &cairo_ctx,
+ );
+ text.render(
+ &cairo_ctx,
+ RenderOptions {
+ x_offset: offset_left,
+ bar_height: height_f,
+ fg_color: ss.config.tag_inactive_fg,
+ bg_color: None,
+ r_left: 0.0,
+ r_right: 0.0,
+ overlap: 0.0,
+ },
+ );
+ offset_left += text.width;
+ }
+
// Display the blocks
render_blocks(
&cairo_ctx,
diff --git a/src/river_protocols/status.rs b/src/river_protocols/status.rs
index 1779719..4424c58 100644
--- a/src/river_protocols/status.rs
+++ b/src/river_protocols/status.rs
@@ -19,7 +19,7 @@ impl RiverStatusState {
where
D: Dispatch<zriver_status_manager_v1::ZriverStatusManagerV1, (), D> + 'static,
{
- let status_manager = globals.bind(qh, 1..=1, ())?;
+ let status_manager = globals.bind(qh, 1..=3, ())?;
Ok(Self {
status_manager,
output_statuses: Vec::new(),
@@ -88,6 +88,14 @@ pub trait RiverStatusHandler: Sized {
output_status: &RiverOutputStatus,
tags: Vec<u32>,
);
+
+ fn layout_name_updated(
+ &mut self,
+ conn: &Connection,
+ qh: &QueueHandle<Self>,
+ output_status: &RiverOutputStatus,
+ layout_name: Option<String>,
+ );
}
#[derive(Debug, Clone)]
@@ -176,6 +184,10 @@ where
.collect();
data.views_tags_updated(conn, qh, &status, tags);
}
+ Event::LayoutName { name } => {
+ data.layout_name_updated(conn, qh, &status, Some(name))
+ }
+ Event::LayoutNameClear => data.layout_name_updated(conn, qh, &status, None),
}
}
}
diff --git a/src/state.rs b/src/state.rs
index ed6c3d1..e6cb421 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -207,6 +207,7 @@ impl OutputHandler for State {
blocks_btns: Default::default(),
river_output_status,
river_control: self.river_control_state.clone(),
+ layout_name: None,
tags_btns: Default::default(),
tags_info: Default::default(),
tags_computed: Vec::new(),
@@ -437,6 +438,22 @@ impl RiverStatusHandler for State {
bar.tags_info.active = tags.into_iter().fold(0, |a, b| a | b);
bar.draw(&mut self.shared_state);
}
+
+ fn layout_name_updated(
+ &mut self,
+ _conn: &Connection,
+ _qh: &QueueHandle<Self>,
+ output_status: &RiverOutputStatus,
+ layout_name: Option<String>,
+ ) {
+ let bar = self
+ .bars
+ .iter_mut()
+ .find(|b| b.river_output_status.as_ref() == Some(output_status))
+ .unwrap();
+ bar.layout_name = layout_name;
+ bar.draw(&mut self.shared_state);
+ }
}
impl RiverControlHandler for State {