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