tony / oxwm

drop `Result` from `bar::update_blocks` and convert `bar::draw` to use the `X11Error` type Browse files
update_blocks no longer returns a Result since it can't fail
emzywastaken committed 2025-10-14 parent ed85f11 commit 34487bf67f3b006968a5b464134bca4d1fb6ffbc
Showing 2 changed files with 4 additions and 7 deletions. UnifiedSplit
+3 −4 src/bar/bar.rs
@@ -1,6 +1,7 @@
1 use super::blocks::Block; 1 use super::blocks::Block;
2 use super::font::{Font, FontDraw}; 2 use super::font::{Font, FontDraw};
3 use crate::Config; 3 use crate::Config;
4 +use crate::window_manager::X11Error;
4 use anyhow::Result; 5 use anyhow::Result;
5 use std::time::Instant; 6 use std::time::Instant;
6 use x11rb::COPY_DEPTH_FROM_PARENT; 7 use x11rb::COPY_DEPTH_FROM_PARENT;
@@ -148,7 +149,7 @@ impl Bar {
148 self.needs_redraw = true; 149 self.needs_redraw = true;
149 } 150 }
150 151
151 - pub fn update_blocks(&mut self) -> Result<()> { 152 + pub fn update_blocks(&mut self) {
152 let now = Instant::now(); 153 let now = Instant::now();
153 let mut changed = false; 154 let mut changed = false;
154 155
@@ -173,8 +174,6 @@ impl Bar {
173 self.status_text = parts.join(""); 174 self.status_text = parts.join("");
174 self.needs_redraw = true; 175 self.needs_redraw = true;
175 } 176 }
176 -
177 - Ok(())
178 } 177 }
179 178
180 pub fn draw( 179 pub fn draw(
@@ -182,7 +181,7 @@ impl Bar {
182 connection: &RustConnection, 181 connection: &RustConnection,
183 current_tags: u32, 182 current_tags: u32,
184 occupied_tags: u32, 183 occupied_tags: u32,
185 - ) -> Result<()> { 184 + ) -> std::result::Result<(), X11Error> {
186 if !self.needs_redraw { 185 if !self.needs_redraw {
187 return Ok(()); 186 return Ok(());
188 } 187 }
+1 −3 src/window_manager.rs
@@ -378,8 +378,7 @@ impl WindowManager {
378 self.update_bar()?; 378 self.update_bar()?;
379 379
380 loop { 380 loop {
381 - // TODO: Identify errors 381 + self.bar.update_blocks();
382 - self.bar.update_blocks()?;
383 382
384 if let Ok(Some(event)) = self.connection.poll_for_event() { 383 if let Ok(Some(event)) = self.connection.poll_for_event() {
385 if let Some(should_restart) = self.handle_event(event)? { 384 if let Some(should_restart) = self.handle_event(event)? {
@@ -436,7 +435,6 @@ impl WindowManager {
436 } 435 }
437 436
438 self.bar.invalidate(); 437 self.bar.invalidate();
439 - // TODO: Identify errors
440 self.bar 438 self.bar
441 .draw(&self.connection, self.selected_tags, occupied_tags)?; 439 .draw(&self.connection, self.selected_tags, occupied_tags)?;
442 Ok(()) 440 Ok(())