tony / oxwm

add error handling TODOs Browse files
- with some style related ones
emzywastaken committed 2025-10-13 parent 6c3b329 commit 618817d8b8b7dc7daf8567d45e08ecf61a3ca2c0
Showing 2 changed files with 17 additions and 0 deletions. UnifiedSplit
+5 −0 src/bar/bar.rs
@@ -32,6 +32,9 @@ pub struct Bar {
32 32 scheme_selected: crate::ColorScheme,
33 33 }
34 34
35 +// Potential Errors:
36 +// ::new -> x11rb::errors::ReplyOrIdError
37 +// ::new -> x11rb::errors::ConnectionError
35 38 impl Bar {
36 39 pub fn new(
37 40 connection: &RustConnection,
@@ -48,6 +51,7 @@ impl Bar {
48 51 if display.is_null() {
49 52 anyhow::bail!("Failed to open X11 display for XFT");
50 53 }
54 + // TODO: Identify errors
51 55 let font = Font::new(display, screen_num as i32, &config.font)?;
52 56
53 57 let height = (font.height() as f32 * 1.4) as u16;
@@ -83,6 +87,7 @@ impl Bar {
83 87 let visual = unsafe { x11::xlib::XDefaultVisual(display, screen_num as i32) };
84 88 let colormap = unsafe { x11::xlib::XDefaultColormap(display, screen_num as i32) };
85 89
90 + // TODO: Identify errors
86 91 let font_draw = FontDraw::new(display, window as x11::xlib::Drawable, visual, colormap)?;
87 92
88 93 let horizontal_padding = (font.height() as f32 * 0.4) as u16;
+12 −0 src/window_manager.rs
@@ -89,8 +89,10 @@ impl WindowManager {
89 89 u16::from(config.modkey).into(),
90 90 )?;
91 91
92 + // TODO: identify error types
92 93 let bar = Bar::new(&connection, &screen, screen_number, &config)?;
93 94
95 + // TODO: identify error types
94 96 let selected_tags = Self::get_saved_selected_tags(&connection, root, config.tags.len())?;
95 97 let gaps_enabled = config.gaps_enabled;
96 98
@@ -111,6 +113,7 @@ impl WindowManager {
111 113 bar,
112 114 };
113 115
116 + // TODO: identify error types
114 117 window_manager.scan_existing_windows()?;
115 118 window_manager.update_bar()?;
116 119
@@ -179,6 +182,7 @@ impl WindowManager {
179 182 }
180 183
181 184 if attrs.map_state == MapState::VIEWABLE {
185 + // TODO: Identify errors
182 186 let tag = self.get_saved_tag(window, net_client_info)?;
183 187 self.windows.push(window);
184 188 self.window_tags.insert(window, tag);
@@ -203,6 +207,7 @@ impl WindowManager {
203 207 .is_ok_and(|prop| !prop.value.is_empty());
204 208
205 209 if has_wm_class {
210 + // TODO: Identify errors
206 211 let tag = self.get_saved_tag(window, net_client_info)?;
207 212 self.windows.push(window);
208 213 self.window_tags.insert(window, tag);
@@ -211,9 +216,11 @@ impl WindowManager {
211 216 }
212 217
213 218 if let Some(&first) = self.windows.first() {
219 + // TODO: Identify errors
214 220 self.set_focus(Some(first))?;
215 221 }
216 222
223 + // TODO: Identify errors
217 224 self.apply_layout()?;
218 225 Ok(())
219 226 }
@@ -295,10 +302,12 @@ impl WindowManager {
295 302 pub fn run(&mut self) -> Result<bool> {
296 303 println!("oxwm started on display {}", self.screen_number);
297 304
305 + // TODO: Identify errors
298 306 keyboard::setup_keybinds(&self.connection, self.root, &self.config.keybindings)?;
299 307 self.update_bar()?;
300 308
301 309 loop {
310 + // TODO: Identify errors
302 311 self.bar.update_blocks()?;
303 312
304 313 if let Ok(Some(event)) = self.connection.poll_for_event() {
@@ -322,6 +331,7 @@ impl WindowManager {
322 331
323 332 self.connection.map_window(self.bar.window())?;
324 333
334 + // TODO: Identify errors
325 335 self.apply_layout()?;
326 336 self.update_focus_visuals()?;
327 337 } else {
@@ -356,6 +366,7 @@ impl WindowManager {
356 366 }
357 367
358 368 self.bar.invalidate();
369 + // TODO: Identify errors
359 370 self.bar
360 371 .draw(&self.connection, self.selected_tags, occupied_tags)?;
361 372 Ok(())
@@ -545,6 +556,7 @@ impl WindowManager {
545 556 self.connection.flush()?;
546 557 }
547 558
559 + // TODO: Indentify errors
548 560 self.update_focus_visuals()?;
549 561 Ok(())
550 562 }