~cassaundra/layerizer

0c49bdd42812d3231beeaf09cd05b3ea18abc828 — cassaundra 1 year, 2 months ago 2827111
cargo clippy
4 files changed, 10 insertions(+), 17 deletions(-)

M src/config.rs
M src/keyboard.rs
M src/main.rs
M src/x11.rs
M src/config.rs => src/config.rs +1 -1
@@ 55,7 55,7 @@ fn deserialize_pattern<'de, D>(deserializer: D) -> Result<Option<Pattern<String>
where
    D: Deserializer<'de>,
{
    Ok(Option::deserialize(deserializer)?.map(|s| Pattern::new(s)))
    Ok(Option::deserialize(deserializer)?.map(Pattern::new))
}

fn layer_mask(layers: &[u8]) -> u8 {

M src/keyboard.rs => src/keyboard.rs +1 -1
@@ 35,7 35,7 @@ pub fn find_device(

    if let Some(device_info) = device_info {
        let device = device_info
            .open_device(&hidapi)
            .open_device(hidapi)
            .context("Failed to open device")?;
        Ok(Some(device))
    } else {

M src/main.rs => src/main.rs +6 -13
@@ 59,11 59,8 @@ impl App {
                }
            };

            match event {
                xcb::Event::X(x::Event::FocusOut(_)) => {
                    self.handle_focus_event()?;
                }
                _ => {}
            if let xcb::Event::X(x::Event::FocusOut(_)) = event {
                self.handle_focus_event()?;
            }
        }
    }


@@ 112,13 109,10 @@ impl App {
        if let Err(err) = self.apply_rules(input_focus) {
            // if we encountered an hid error, assume we have disconnected and
            // try to reconnect
            match err.downcast_ref::<HidError>() {
                Some(_) => {
                    if let Some(device) = find_device(&mut self.hidapi, &self.config.device_info)? {
                        self.device = device;
                    }
            if err.downcast_ref::<HidError>().is_some() {
                if let Some(device) = find_device(&mut self.hidapi, &self.config.device_info)? {
                    self.device = device;
                }
                None => {}
            }
        }



@@ 149,8 143,7 @@ fn main() -> anyhow::Result<()> {
        };

        let raw = fs::read_to_string(config_path).context("Failed to read configuration file")?;
        let parsed = toml::from_str(&raw).context("Failed to parse configuration file")?;
        parsed
        toml::from_str(&raw).context("Failed to parse configuration file")?
    };

    App::from_config(config)?.run()

M src/x11.rs => src/x11.rs +2 -2
@@ 41,7 41,7 @@ pub fn get_window_info(
        let strings: Vec<_> = class_reply
            .value::<u8>()
            .split(|b| *b == 0)
            .map(|bs| std::str::from_utf8(bs))
            .map(std::str::from_utf8)
            .take(2)
            .collect::<Result<_, _>>()?;



@@ 77,7 77,7 @@ pub fn get_input_focus(connection: &xcb::Connection) -> anyhow::Result<x::Window
pub fn listen_to_window(connection: &xcb::Connection, window: x::Window) -> anyhow::Result<()> {
    let cookie = connection.send_request_checked(&x::ChangeWindowAttributes {
        window,
        value_list: &WINDOW_ATTRIBUTES,
        value_list: WINDOW_ATTRIBUTES,
    });
    connection.check_request(cookie)?;
    connection.flush()?;