feat(wm): reconcile monitor state

When monitors turn on and off, they do not retain their hmonitor id,
therefore this commit introduces an initial attempt to reconcile invalid
and valid hmonitors after monitor changes based on the windows that are
assigned to them.

If a monitor has at least one window, and has been assigned a new
hmonitor id, komorebi will look up the current hmonitor of that window's
hwnd and update Monitor.id in-place.

When reconciling monitors, any monitor marked as invalid will be purged
from the window manager state.

This commit also applies some of the new clippy lints that come along
with the latest nightly release of Rust.

resolve #31
This commit is contained in:
LGUG2Z
2021-09-10 12:46:49 -07:00
parent e1bd0e9fcb
commit c4c8bd7d4b
7 changed files with 86 additions and 29 deletions

View File

@@ -527,11 +527,10 @@ fn main() -> Result<()> {
None
};
let script = if let Some(exec) = exec {
format!("Start-Process '{}' -WindowStyle hidden", exec)
} else {
String::from("Start-Process komorebi -WindowStyle hidden")
};
let script = exec.map_or_else(
|| String::from("Start-Process komorebi -WindowStyle hidden"),
|exec| format!("Start-Process '{}' -WindowStyle hidden", exec),
);
match powershell_script::run(&script, true) {
Ok(output) => {