Compare commits

...

1 Commits

Author SHA1 Message Date
LGUG2Z
3101e089b3 fix(wm): grow monitors vec to accomodate index prefs 2024-08-27 08:57:50 -07:00
2 changed files with 21 additions and 1 deletions

View File

@@ -88,6 +88,22 @@ pub fn new(
}
impl Monitor {
pub fn placeholder() -> Self {
Self {
id: 0,
name: "PLACEHOLDER".to_string(),
device: "".to_string(),
device_id: "".to_string(),
size: Default::default(),
work_area_size: Default::default(),
work_area_offset: None,
window_based_work_area_offset: None,
window_based_work_area_offset_limit: 0,
workspaces: Default::default(),
last_focused_workspace: None,
workspace_names: Default::default(),
}
}
pub fn load_focused_workspace(&mut self, mouse_follows_focus: bool) -> Result<()> {
let focused_idx = self.focused_workspace_idx();
for (i, workspace) in self.workspaces_mut().iter_mut().enumerate() {

View File

@@ -288,7 +288,7 @@ impl WindowsApi {
monitors.elements_mut().push_back(m);
} else if let Some(preference) = index_preference {
while *preference > monitors.elements().len() {
monitors.elements_mut().reserve(1);
monitors.elements_mut().push_back(Monitor::placeholder());
}
monitors.elements_mut().insert(*preference, m);
@@ -297,6 +297,10 @@ impl WindowsApi {
}
}
monitors
.elements_mut()
.retain(|m| m.name().ne("PLACEHOLDER"));
Ok(())
}