diff options
| -rw-r--r-- | protocols/river-status-unstable-v1.xml | 29 | ||||
| -rw-r--r-- | src/bar.rs | 30 | ||||
| -rw-r--r-- | src/river_protocols/status.rs | 14 | ||||
| -rw-r--r-- | src/state.rs | 17 |
4 files changed, 86 insertions, 4 deletions
diff --git a/protocols/river-status-unstable-v1.xml b/protocols/river-status-unstable-v1.xml index 1fbd5b4..13b6225 100644 --- a/protocols/river-status-unstable-v1.xml +++ b/protocols/river-status-unstable-v1.xml @@ -16,7 +16,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. </copyright> - <interface name="zriver_status_manager_v1" version="2"> + <interface name="zriver_status_manager_v1" version="3"> <description summary="manage river status objects"> A global factory for objects that receive status information specific to river. It could be used to implement, for example, a status bar. @@ -47,7 +47,7 @@ </request> </interface> - <interface name="zriver_output_status_v1" version="2"> + <interface name="zriver_output_status_v1" version="3"> <description summary="track output tags and focus"> This interface allows clients to receive information about the current windowing state of an output. @@ -83,9 +83,24 @@ </description> <arg name="tags" type="uint" summary="32-bit bitfield"/> </event> + + <event name="layout_name" since="3"> + <description summary="name of the layout"> + Sent once on binding the interface should a layout name exist and again + whenever the name changes. + </description> + <arg name="name" type="string" summary="layout name"/> + </event> + + <event name="layout_name_clear" since="3"> + <description summary="name of the layout"> + Sent when the current layout name has been removed without a new one + being set, for example whent the active layout generator disconnects. + </description> + </event> </interface> - <interface name="zriver_seat_status_v1" version="1"> + <interface name="zriver_seat_status_v1" version="3"> <description summary="track seat focus"> This interface allows clients to receive information about the current focus of a seat. Note that (un)focused_output events will only be sent @@ -121,6 +136,14 @@ </description> <arg name="title" type="string" summary="title of the focused view"/> </event> + + <event name="mode" since="3"> + <description summary="the active mode changed"> + Sent once on binding the interface and again whenever a new mode + is entered (e.g. with riverctl enter-mode foobar). + </description> + <arg name="name" type="string" summary="name of the mode"/> + </event> </interface> </protocol> @@ -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 { |
