tony / oxwm

remove all `anyhow` results in `window_manager` Browse files
emzywastaken committed 2025-10-13 parent 67e8eb4 commit 93868ba7d54564a47de3d2da3416a61ea9244598
Showing 1 changed file with 15 additions and 10 deletions. UnifiedSplit
+15 −10 src/window_manager.rs
@@ -4,9 +4,7 @@ use crate::keyboard::{self, Arg, KeyAction, handlers};
4 4 use crate::layout::GapConfig;
5 5 use crate::layout::Layout;
6 6 use crate::layout::tiling::TilingLayout;
7 -use anyhow::Result;
8 7 use std::collections::HashSet;
9 -use std::path::PathBuf;
10 8 use x11rb::cursor::Handle as CursorHandle;
11 9
12 10 use x11rb::connection::Connection;
@@ -202,7 +200,7 @@ impl WindowManager {
202 200 connection: &RustConnection,
203 201 root: Window,
204 202 tag_count: usize,
205 - ) -> Result<TagMask> {
203 + ) -> std::result::Result<TagMask, WindowManagerError> {
206 204 let net_current_desktop = connection
207 205 .intern_atom(false, b"_NET_CURRENT_DESKTOP")?
208 206 .reply()?
@@ -385,7 +383,7 @@ impl WindowManager {
385 383 Ok(())
386 384 }
387 385
388 - pub fn run(&mut self) -> Result<bool> {
386 + pub fn run(&mut self) -> std::result::Result<bool, WindowManagerError> {
389 387 println!("oxwm started on display {}", self.screen_number);
390 388
391 389 // TODO: Identify errors
@@ -444,7 +442,7 @@ impl WindowManager {
444 442 Ok(())
445 443 }
446 444
447 - fn update_bar(&mut self) -> Result<()> {
445 + fn update_bar(&mut self) -> std::result::Result<(), WindowManagerError> {
448 446 let mut occupied_tags: TagMask = 0;
449 447 for &tags in self.window_tags.values() {
450 448 occupied_tags |= tags;
@@ -457,7 +455,11 @@ impl WindowManager {
457 455 Ok(())
458 456 }
459 457
460 - fn handle_key_action(&mut self, action: KeyAction, arg: &Arg) -> Result<()> {
458 + fn handle_key_action(
459 + &mut self,
460 + action: KeyAction,
461 + arg: &Arg,
462 + ) -> std::result::Result<(), WindowManagerError> {
461 463 match action {
462 464 KeyAction::Spawn => handlers::handle_spawn_action(action, arg)?,
463 465 KeyAction::KillClient => {
@@ -539,7 +541,7 @@ impl WindowManager {
539 541 Ok(())
540 542 }
541 543
542 - pub fn view_tag(&mut self, tag_index: usize) -> Result<()> {
544 + pub fn view_tag(&mut self, tag_index: usize) -> std::result::Result<(), WindowManagerError> {
543 545 if tag_index >= self.config.tags.len() {
544 546 return Ok(());
545 547 }
@@ -587,7 +589,7 @@ impl WindowManager {
587 589 Ok(())
588 590 }
589 591
590 - pub fn move_to_tag(&mut self, tag_index: usize) -> Result<()> {
592 + pub fn move_to_tag(&mut self, tag_index: usize) -> std::result::Result<(), WindowManagerError> {
591 593 if tag_index >= self.config.tags.len() {
592 594 return Ok(());
593 595 }
@@ -606,7 +608,7 @@ impl WindowManager {
606 608 Ok(())
607 609 }
608 610
609 - pub fn cycle_focus(&mut self, direction: i32) -> Result<()> {
611 + pub fn cycle_focus(&mut self, direction: i32) -> std::result::Result<(), WindowManagerError> {
610 612 let visible = self.visible_windows();
611 613
612 614 if visible.is_empty() {
@@ -787,7 +789,10 @@ impl WindowManager {
787 789 Ok(())
788 790 }
789 791
790 - fn handle_event(&mut self, event: Event) -> Result<Option<bool>> {
792 + fn handle_event(
793 + &mut self,
794 + event: Event,
795 + ) -> std::result::Result<Option<bool>, WindowManagerError> {
791 796 match event {
792 797 Event::MapRequest(event) => {
793 798 let attrs = match self.connection.get_window_attributes(event.window)?.reply() {