mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-23 17:18:40 +02:00
fix(wm): grow monitors vec to accomodate idx prefs
This commit fixes a bug in load_monitor_information which resulted in an infinite while loop due to a misunderstanding of how VecDeque::reserve works.
This commit is contained in:
@@ -88,6 +88,22 @@ pub fn new(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Monitor {
|
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<()> {
|
pub fn load_focused_workspace(&mut self, mouse_follows_focus: bool) -> Result<()> {
|
||||||
let focused_idx = self.focused_workspace_idx();
|
let focused_idx = self.focused_workspace_idx();
|
||||||
for (i, workspace) in self.workspaces_mut().iter_mut().enumerate() {
|
for (i, workspace) in self.workspaces_mut().iter_mut().enumerate() {
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ impl WindowsApi {
|
|||||||
monitors.elements_mut().push_back(m);
|
monitors.elements_mut().push_back(m);
|
||||||
} else if let Some(preference) = index_preference {
|
} else if let Some(preference) = index_preference {
|
||||||
while *preference > monitors.elements().len() {
|
while *preference > monitors.elements().len() {
|
||||||
monitors.elements_mut().reserve(1);
|
monitors.elements_mut().push_back(Monitor::placeholder());
|
||||||
}
|
}
|
||||||
|
|
||||||
monitors.elements_mut().insert(*preference, m);
|
monitors.elements_mut().insert(*preference, m);
|
||||||
@@ -297,6 +297,10 @@ impl WindowsApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
monitors
|
||||||
|
.elements_mut()
|
||||||
|
.retain(|m| m.name().ne("PLACEHOLDER"));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user