fix(wm): correct monitor index preference handling

This commit is contained in:
alex-ds13
2024-10-18 17:33:06 +01:00
committed by LGUG2Z
parent 903b6af507
commit 09afad624f

View File

@@ -300,14 +300,21 @@ impl WindowsApi {
}
}
if monitors.elements().is_empty() {
monitors.elements_mut().push_back(m);
} else if let Some(preference) = index_preference {
while *preference > monitors.elements().len() {
if let Some(preference) = index_preference {
while *preference >= monitors.elements().len() {
monitors.elements_mut().push_back(Monitor::placeholder());
}
monitors.elements_mut().insert(*preference, m);
let current_name = monitors
.elements_mut()
.get(*preference)
.map_or("", |m| m.name());
if current_name == "PLACEHOLDER" {
let _ = monitors.elements_mut().remove(*preference);
monitors.elements_mut().insert(*preference, m);
} else {
monitors.elements_mut().insert(*preference, m);
}
} else {
monitors.elements_mut().push_back(m);
}