remove all `anyhow` results in `window_manager`
Browse files
+15 −10 src/window_manager.rs
| @@ -4,9 +4,7 @@ use crate::keyboard::{self, Arg, KeyAction, handlers}; | |||
| 4 | use crate::layout::GapConfig; | 4 | use crate::layout::GapConfig; |
| 5 | use crate::layout::Layout; | 5 | use crate::layout::Layout; |
| 6 | use crate::layout::tiling::TilingLayout; | 6 | use crate::layout::tiling::TilingLayout; |
| 7 | -use anyhow::Result; | ||
| 8 | use std::collections::HashSet; | 7 | use std::collections::HashSet; |
| 9 | -use std::path::PathBuf; | ||
| 10 | use x11rb::cursor::Handle as CursorHandle; | 8 | use x11rb::cursor::Handle as CursorHandle; |
| 11 | 9 | ||
| 12 | use x11rb::connection::Connection; | 10 | use x11rb::connection::Connection; |
| @@ -202,7 +200,7 @@ impl WindowManager { | |||
| 202 | connection: &RustConnection, | 200 | connection: &RustConnection, |
| 203 | root: Window, | 201 | root: Window, |
| 204 | tag_count: usize, | 202 | tag_count: usize, |
| 205 | - ) -> Result<TagMask> { | 203 | + ) -> std::result::Result<TagMask, WindowManagerError> { |
| 206 | let net_current_desktop = connection | 204 | let net_current_desktop = connection |
| 207 | .intern_atom(false, b"_NET_CURRENT_DESKTOP")? | 205 | .intern_atom(false, b"_NET_CURRENT_DESKTOP")? |
| 208 | .reply()? | 206 | .reply()? |
| @@ -385,7 +383,7 @@ impl WindowManager { | |||
| 385 | Ok(()) | 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 | println!("oxwm started on display {}", self.screen_number); | 387 | println!("oxwm started on display {}", self.screen_number); |
| 390 | 388 | ||
| 391 | // TODO: Identify errors | 389 | // TODO: Identify errors |
| @@ -444,7 +442,7 @@ impl WindowManager { | |||
| 444 | Ok(()) | 442 | Ok(()) |
| 445 | } | 443 | } |
| 446 | 444 | ||
| 447 | - fn update_bar(&mut self) -> Result<()> { | 445 | + fn update_bar(&mut self) -> std::result::Result<(), WindowManagerError> { |
| 448 | let mut occupied_tags: TagMask = 0; | 446 | let mut occupied_tags: TagMask = 0; |
| 449 | for &tags in self.window_tags.values() { | 447 | for &tags in self.window_tags.values() { |
| 450 | occupied_tags |= tags; | 448 | occupied_tags |= tags; |
| @@ -457,7 +455,11 @@ impl WindowManager { | |||
| 457 | Ok(()) | 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 | match action { | 463 | match action { |
| 462 | KeyAction::Spawn => handlers::handle_spawn_action(action, arg)?, | 464 | KeyAction::Spawn => handlers::handle_spawn_action(action, arg)?, |
| 463 | KeyAction::KillClient => { | 465 | KeyAction::KillClient => { |
| @@ -539,7 +541,7 @@ impl WindowManager { | |||
| 539 | Ok(()) | 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 | if tag_index >= self.config.tags.len() { | 545 | if tag_index >= self.config.tags.len() { |
| 544 | return Ok(()); | 546 | return Ok(()); |
| 545 | } | 547 | } |
| @@ -587,7 +589,7 @@ impl WindowManager { | |||
| 587 | Ok(()) | 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 | if tag_index >= self.config.tags.len() { | 593 | if tag_index >= self.config.tags.len() { |
| 592 | return Ok(()); | 594 | return Ok(()); |
| 593 | } | 595 | } |
| @@ -606,7 +608,7 @@ impl WindowManager { | |||
| 606 | Ok(()) | 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 | let visible = self.visible_windows(); | 612 | let visible = self.visible_windows(); |
| 611 | 613 | ||
| 612 | if visible.is_empty() { | 614 | if visible.is_empty() { |
| @@ -787,7 +789,10 @@ impl WindowManager { | |||
| 787 | Ok(()) | 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 | match event { | 796 | match event { |
| 792 | Event::MapRequest(event) => { | 797 | Event::MapRequest(event) => { |
| 793 | let attrs = match self.connection.get_window_attributes(event.window)?.reply() { | 798 | let attrs = match self.connection.get_window_attributes(event.window)?.reply() { |