fix some floating windows being split

This commit is contained in:
Alex Janka 2024-07-26 12:25:14 +10:00
parent ab95a4b019
commit b6bc571b52
4 changed files with 20 additions and 16 deletions

2
Cargo.lock generated
View file

@ -653,7 +653,7 @@ dependencies = [
[[package]] [[package]]
name = "sway-flash-indicator" name = "sway-flash-indicator"
version = "0.2.0" version = "0.2.1"
dependencies = [ dependencies = [
"directories", "directories",
"futures-util", "futures-util",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "sway-flash-indicator" name = "sway-flash-indicator"
version = "0.2.0" version = "0.2.1"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View file

@ -1,7 +1,7 @@
# Maintainer: Alex Janka <alex@alexjanka.com> # Maintainer: Alex Janka <alex@alexjanka.com>
pkgname=sway-flash-indicator pkgname=sway-flash-indicator
pkgver=0.2.0 pkgver=0.2.1
pkgrel=1 pkgrel=1
pkgdesc="flashes sway indicator border rather than always showing it" pkgdesc="flashes sway indicator border rather than always showing it"
arch=('x86_64' 'aarch64') arch=('x86_64' 'aarch64')

View file

@ -60,22 +60,26 @@ async fn main() -> Res<()> {
} }
} }
swayipc_async::Event::Window(window) 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 => 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 node = window.container;
if node.node_type == swayipc_async::NodeType::Con {
let (width, height) = (node.window_rect.width, node.window_rect.height); let (width, height) = (node.window_rect.width, node.window_rect.height);
let ratio = (width as f64) / (height as f64); if width == 0 || height == 0 {
let autosplit_ratio = continue;
CONFIG.get().ok_or(Error::NoMatchingConfig)?.autosplit_ratio; }
if let Err(e) = if ratio > autosplit_ratio { let ratio = (width as f64) / (height as f64);
autosplit_connection.run_command("splith").await let autosplit_ratio =
} else { CONFIG.get().ok_or(Error::NoMatchingConfig)?.autosplit_ratio;
autosplit_connection.run_command("splitv").await if let Err(e) = if ratio > autosplit_ratio {
} { autosplit_connection.run_command("splith").await
log::warn!("error {e:?} setting split"); } else {
autosplit_connection.run_command("splitv").await
} {
log::warn!("error {e:?} setting split");
}
} }
} }
_ => {} _ => {}