@@ -48,7 +48,6 @@ macro_rules! gen_id {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//ThingVec
|
//ThingVec
|
||||||
#[allow(dead_code, clippy::iter_not_returning_iterator)]
|
|
||||||
impl $container_name {
|
impl $container_name {
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -57,25 +56,27 @@ macro_rules! gen_id {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter(&self, callback: &dyn Fn($handle_name, &$instance_name)) {
|
pub fn iter(&self) -> impl Iterator<Item = ($handle_name, &$instance_name)> {
|
||||||
for (idx, opt_cell) in self.vec.iter().enumerate() {
|
self.vec.iter().enumerate().filter_map(|(idx, opt_cell)| {
|
||||||
if let Some(cell) = opt_cell {
|
opt_cell.as_ref().map(|cell| {
|
||||||
let handle = $container_name::get_handle(&cell, idx);
|
let handle = $container_name::get_handle(&cell, idx);
|
||||||
callback(handle, &cell.obj);
|
(handle, &cell.obj)
|
||||||
}
|
})
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_mut(
|
pub fn iter_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
callback: &mut dyn FnMut($handle_name, &mut $instance_name),
|
) -> impl Iterator<Item = ($handle_name, &mut $instance_name)> {
|
||||||
) {
|
self.vec
|
||||||
for (idx, opt_cell) in self.vec.iter_mut().enumerate() {
|
.iter_mut()
|
||||||
if let Some(cell) = opt_cell {
|
.enumerate()
|
||||||
let handle = $container_name::get_handle(&cell, idx);
|
.filter_map(|(idx, opt_cell)| {
|
||||||
callback(handle, &mut cell.obj);
|
opt_cell.as_mut().map(|cell| {
|
||||||
}
|
let handle = $container_name::get_handle(&cell, idx);
|
||||||
}
|
(handle, &mut cell.obj)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn get_handle(cell: &$cell_name, idx: usize) -> $handle_name {
|
pub const fn get_handle(cell: &$cell_name, idx: usize) -> $handle_name {
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ impl WayVR {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check for redraw events
|
// Check for redraw events
|
||||||
self.state.displays.iter_mut(&mut |_, disp| {
|
for (_, disp) in self.state.displays.iter_mut() {
|
||||||
for disp_window in &disp.displayed_windows {
|
for disp_window in &disp.displayed_windows {
|
||||||
if self
|
if self
|
||||||
.state
|
.state
|
||||||
@@ -322,17 +322,17 @@ impl WayVR {
|
|||||||
disp.wants_redraw = true;
|
disp.wants_redraw = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// Tick all child processes
|
// Tick all child processes
|
||||||
let mut to_remove: SmallVec<[(process::ProcessHandle, display::DisplayHandle); 2]> =
|
let mut to_remove: SmallVec<[(process::ProcessHandle, display::DisplayHandle); 2]> =
|
||||||
SmallVec::new();
|
SmallVec::new();
|
||||||
|
|
||||||
self.state.processes.iter_mut(&mut |handle, process| {
|
for (handle, process) in self.state.processes.iter_mut() {
|
||||||
if !process.is_running() {
|
if !process.is_running() {
|
||||||
to_remove.push((handle, process.display_handle()));
|
to_remove.push((handle, process.display_handle()));
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
for (p_handle, disp_handle) in &to_remove {
|
for (p_handle, disp_handle) in &to_remove {
|
||||||
self.state.processes.remove(p_handle);
|
self.state.processes.remove(p_handle);
|
||||||
@@ -345,9 +345,9 @@ impl WayVR {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.state.displays.iter_mut(&mut |handle, display| {
|
for (handle, display) in self.state.displays.iter_mut() {
|
||||||
display.tick(&self.state.config, &handle, &mut self.state.signals);
|
display.tick(&self.state.config, &handle, &mut self.state.signals);
|
||||||
});
|
}
|
||||||
|
|
||||||
if !to_remove.is_empty() {
|
if !to_remove.is_empty() {
|
||||||
self.state.signals.send(WayVRSignal::BroadcastStateChanged(
|
self.state.signals.send(WayVRSignal::BroadcastStateChanged(
|
||||||
@@ -591,11 +591,11 @@ impl WayVRState {
|
|||||||
|
|
||||||
let mut process_names = Vec::<String>::new();
|
let mut process_names = Vec::<String>::new();
|
||||||
|
|
||||||
self.processes.iter_mut(&mut |_, process| {
|
for (_, process) in self.processes.iter_mut() {
|
||||||
if process.display_handle() == handle {
|
if process.display_handle() == handle {
|
||||||
process_names.push(process.get_name());
|
process_names.push(process.get_name());
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
if !display.displayed_windows.is_empty() || !process_names.is_empty() {
|
if !display.displayed_windows.is_empty() || !process_names.is_empty() {
|
||||||
anyhow::bail!(
|
anyhow::bail!(
|
||||||
|
|||||||
Reference in New Issue
Block a user