diff --git a/Cargo.lock b/Cargo.lock index b6e8cfa..a871d41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -653,7 +653,7 @@ dependencies = [ [[package]] name = "sway-flash-indicator" -version = "0.2.0" +version = "0.2.1" dependencies = [ "directories", "futures-util", diff --git a/Cargo.toml b/Cargo.toml index 033cf3a..c5639ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sway-flash-indicator" -version = "0.2.0" +version = "0.2.1" edition = "2021" [dependencies] diff --git a/packaging/PKGBUILD b/packaging/PKGBUILD index dbccf1d..4e63c36 100644 --- a/packaging/PKGBUILD +++ b/packaging/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Alex Janka pkgname=sway-flash-indicator -pkgver=0.2.0 +pkgver=0.2.1 pkgrel=1 pkgdesc="flashes sway indicator border rather than always showing it" arch=('x86_64' 'aarch64') diff --git a/src/main.rs b/src/main.rs index 3598a38..9e8bc0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,22 +60,26 @@ async fn main() -> Res<()> { } } swayipc_async::Event::Window(window) - // TODO: change on window closed also - // the node we're given is the one that closes if window.change != swayipc_async::WindowChange::Mark => { + // TODO: also change on window closed - + // the node we're given is the one that closes let node = window.container; - - let (width, height) = (node.window_rect.width, node.window_rect.height); - let ratio = (width as f64) / (height as f64); - let autosplit_ratio = - CONFIG.get().ok_or(Error::NoMatchingConfig)?.autosplit_ratio; - if let Err(e) = if ratio > autosplit_ratio { - autosplit_connection.run_command("splith").await - } else { - autosplit_connection.run_command("splitv").await - } { - log::warn!("error {e:?} setting split"); + if node.node_type == swayipc_async::NodeType::Con { + let (width, height) = (node.window_rect.width, node.window_rect.height); + if width == 0 || height == 0 { + continue; + } + let ratio = (width as f64) / (height as f64); + let autosplit_ratio = + CONFIG.get().ok_or(Error::NoMatchingConfig)?.autosplit_ratio; + if let Err(e) = if ratio > autosplit_ratio { + autosplit_connection.run_command("splith").await + } else { + autosplit_connection.run_command("splitv").await + } { + log::warn!("error {e:?} setting split"); + } } } _ => {}