| @@ -1,9 +1,11 @@ |
|
|
1 |
+use std::io; |
| 1 |
use std::process::Command; |
2 |
use std::process::Command; |
| 2 |
|
3 |
|
| 3 |
-use anyhow::Result; |
|
|
| 4 |
use x11rb::connection::Connection; |
4 |
use x11rb::connection::Connection; |
| 5 |
use x11rb::protocol::xproto::*; |
5 |
use x11rb::protocol::xproto::*; |
| 6 |
|
6 |
|
|
|
7 |
+use crate::window_manager::X11Error; |
|
|
8 |
+ |
| 7 |
#[derive(Debug, Copy, Clone)] |
9 |
#[derive(Debug, Copy, Clone)] |
| 8 |
pub enum KeyAction { |
10 |
pub enum KeyAction { |
| 9 |
Spawn, |
11 |
Spawn, |
| @@ -67,7 +69,7 @@ pub fn setup_keybinds( |
| 67 |
connection: &impl Connection, |
69 |
connection: &impl Connection, |
| 68 |
root: Window, |
70 |
root: Window, |
| 69 |
keybindings: &[Key], |
71 |
keybindings: &[Key], |
| 70 |
-) -> Result<()> { |
72 |
+) -> Result<(), X11Error> { |
| 71 |
for keybinding in keybindings { |
73 |
for keybinding in keybindings { |
| 72 |
let modifier_mask = modifiers_to_mask(keybinding.modifiers); |
74 |
let modifier_mask = modifiers_to_mask(keybinding.modifiers); |
| 73 |
|
75 |
|
| @@ -83,20 +85,20 @@ pub fn setup_keybinds( |
| 83 |
Ok(()) |
85 |
Ok(()) |
| 84 |
} |
86 |
} |
| 85 |
|
87 |
|
| 86 |
-pub fn handle_key_press(event: KeyPressEvent, keybindings: &[Key]) -> Result<(KeyAction, Arg)> { |
88 |
+pub fn handle_key_press(event: KeyPressEvent, keybindings: &[Key]) -> (KeyAction, Arg) { |
| 87 |
for keybinding in keybindings { |
89 |
for keybinding in keybindings { |
| 88 |
let modifier_mask = modifiers_to_mask(keybinding.modifiers); |
90 |
let modifier_mask = modifiers_to_mask(keybinding.modifiers); |
| 89 |
|
91 |
|
| 90 |
if event.detail == keybinding.key && event.state == modifier_mask.into() { |
92 |
if event.detail == keybinding.key && event.state == modifier_mask.into() { |
| 91 |
- return Ok((keybinding.func, keybinding.arg.clone())); |
93 |
+ return (keybinding.func, keybinding.arg.clone()); |
| 92 |
} |
94 |
} |
| 93 |
} |
95 |
} |
| 94 |
|
96 |
|
| 95 |
- Ok((KeyAction::None, Arg::None)) |
97 |
+ (KeyAction::None, Arg::None) |
| 96 |
} |
98 |
} |
| 97 |
|
99 |
|
| 98 |
-pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> Result<()> { |
100 |
+pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> io::Result<()> { |
| 99 |
- use std::io::ErrorKind; |
101 |
+ use io::ErrorKind; |
| 100 |
match action { |
102 |
match action { |
| 101 |
KeyAction::Spawn => match arg { |
103 |
KeyAction::Spawn => match arg { |
| 102 |
Arg::Str(command) => match Command::new(command).spawn() { |
104 |
Arg::Str(command) => match Command::new(command).spawn() { |