fix(wm): handle monitor index pref edge case

This commit handles an edge case where the first registered display
monitor has an index preference that is greater than the current length
of the Ring data structure storing the monitors.

re #612
This commit is contained in:
LGUG2Z
2023-12-22 17:59:44 -08:00
parent d3bc78097c
commit e221d96785

View File

@@ -110,14 +110,16 @@ pub extern "system" fn enum_display_monitor(
let display_index_preferences = DISPLAY_INDEX_PREFERENCES.lock();
for (index, device) in &*display_index_preferences {
if let Some(known_device) = m.device() {
if let Some(known_device) = m.device_id() {
if device == known_device {
index_preference = Option::from(index);
}
}
}
if let Some(preference) = index_preference {
if monitors.elements().is_empty() {
monitors.elements_mut().push_back(m);
} else if let Some(preference) = index_preference {
let current_len = monitors.elements().len();
if *preference > current_len {
monitors.elements_mut().reserve(1);