clippy
This commit is contained in:
@@ -57,20 +57,20 @@ where
|
||||
crate::overlays::screen::get_screens_x11(&app.session)?
|
||||
};
|
||||
|
||||
let mut watch = create_watch::<T>(&app, &screens)?;
|
||||
let mut watch = create_watch::<T>(app, &screens)?;
|
||||
watch.state.want_visible = true;
|
||||
overlays.insert(watch.state.id, watch);
|
||||
|
||||
let mut keyboard = create_keyboard(&app)?;
|
||||
let mut keyboard = create_keyboard(app)?;
|
||||
keyboard.state.show_hide = true;
|
||||
keyboard.state.want_visible = false;
|
||||
overlays.insert(keyboard.state.id, keyboard);
|
||||
|
||||
let mut show_screens = app.session.config.show_screens.clone();
|
||||
if show_screens.is_empty() {
|
||||
screens.first().and_then(|s| {
|
||||
screens.first().map(|s| {
|
||||
show_screens.push(s.state.name.clone());
|
||||
Some(())
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,17 +102,17 @@ where
|
||||
.iter()
|
||||
.find(|(_, o)| *o.state.name == **name)
|
||||
.map(|(id, _)| *id);
|
||||
id.and_then(|id| self.overlays.remove(&id));
|
||||
id.and_then(|id| self.overlays.remove(id));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_by_id<'a>(&'a mut self, id: usize) -> Option<&'a OverlayData<T>> {
|
||||
self.overlays.get(&id)
|
||||
pub fn get_by_id(&mut self, id: usize) -> Option<&OverlayData<T>> {
|
||||
self.overlays.get(id)
|
||||
}
|
||||
|
||||
pub fn mut_by_id<'a>(&'a mut self, id: usize) -> Option<&'a mut OverlayData<T>> {
|
||||
self.overlays.get_mut(&id)
|
||||
pub fn mut_by_id(&mut self, id: usize) -> Option<&mut OverlayData<T>> {
|
||||
self.overlays.get_mut(id)
|
||||
}
|
||||
|
||||
pub fn get_by_name<'a>(&'a mut self, name: &str) -> Option<&'a OverlayData<T>> {
|
||||
@@ -123,11 +123,11 @@ where
|
||||
self.overlays.values_mut().find(|o| *o.state.name == *name)
|
||||
}
|
||||
|
||||
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a OverlayData<T>> {
|
||||
pub fn iter(&self) -> impl Iterator<Item = &'_ OverlayData<T>> {
|
||||
self.overlays.values()
|
||||
}
|
||||
|
||||
pub fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut OverlayData<T>> {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &'_ mut OverlayData<T>> {
|
||||
self.overlays.values_mut()
|
||||
}
|
||||
|
||||
|
||||
@@ -128,15 +128,13 @@ impl OpenVrInputSource {
|
||||
system: &mut SystemManager,
|
||||
app: &mut AppState,
|
||||
) {
|
||||
let aas = ActiveActionSet {
|
||||
0: ovr_overlay::sys::VRActiveActionSet_t {
|
||||
let aas = ActiveActionSet(ovr_overlay::sys::VRActiveActionSet_t {
|
||||
ulActionSet: self.set_hnd.0,
|
||||
ulRestrictedToDevice: 0,
|
||||
ulSecondaryActionSet: 0,
|
||||
unPadding: 0,
|
||||
nPriority: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
let _ = input.update_actions(&mut [aas]);
|
||||
|
||||
@@ -155,10 +153,10 @@ impl OpenVrInputSource {
|
||||
0.005,
|
||||
INPUT_ANY,
|
||||
)
|
||||
.and_then(|pose| {
|
||||
.map(|pose| {
|
||||
app_hand.pose = pose.0.pose.mDeviceToAbsoluteTracking.to_affine();
|
||||
hand.has_pose = true;
|
||||
Ok(())
|
||||
|
||||
});
|
||||
|
||||
app_hand.now.click = input
|
||||
@@ -237,9 +235,9 @@ impl OpenVrInputSource {
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
get_tracked_device(system, device, role).and_then(|device| {
|
||||
get_tracked_device(system, device, role).map(|device| {
|
||||
app.input_state.devices.push(device);
|
||||
Some(())
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ impl LinePool {
|
||||
) {
|
||||
let rotation = Affine3A::from_axis_angle(Vec3::X, -PI * 0.5);
|
||||
|
||||
from.translation = from.translation + from.transform_vector3a(Vec3A::NEG_Z) * (len * 0.5);
|
||||
from.translation += from.transform_vector3a(Vec3A::NEG_Z) * (len * 0.5);
|
||||
let mut transform = from * rotation * Affine3A::from_scale(Vec3::new(1., len / 0.002, 1.));
|
||||
|
||||
let to_hmd = hmd.translation - from.translation;
|
||||
@@ -114,7 +114,7 @@ impl LinePool {
|
||||
}
|
||||
}
|
||||
|
||||
transform = transform * rotations[closest.0];
|
||||
transform *= rotations[closest.0];
|
||||
|
||||
debug_assert!(color < self.colors.len());
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ impl OpenXrInputSource {
|
||||
Ok(Self {
|
||||
action_set,
|
||||
hands: [
|
||||
OpenXrHand::new(&xr, left_source)?,
|
||||
OpenXrHand::new(&xr, right_source)?,
|
||||
OpenXrHand::new(xr, left_source)?,
|
||||
OpenXrHand::new(xr, right_source)?,
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -94,14 +94,14 @@ impl LinePool {
|
||||
|
||||
debug_assert!(color < self.colors.len());
|
||||
|
||||
let Some(line) = self.lines.get_mut(&id) else {
|
||||
let Some(line) = self.lines.get_mut(id) else {
|
||||
log::warn!("Line {} not found", id);
|
||||
return;
|
||||
};
|
||||
|
||||
let rotation = Affine3A::from_axis_angle(Vec3::X, PI * 1.5);
|
||||
|
||||
from.translation = from.translation + from.transform_vector3a(Vec3A::NEG_Z) * (len * 0.5);
|
||||
from.translation += from.transform_vector3a(Vec3A::NEG_Z) * (len * 0.5);
|
||||
let mut transform = from * rotation;
|
||||
|
||||
let to_hmd = hmd.translation - from.translation;
|
||||
@@ -120,7 +120,7 @@ impl LinePool {
|
||||
}
|
||||
}
|
||||
|
||||
transform = transform * rotations[closest.0];
|
||||
transform *= rotations[closest.0];
|
||||
|
||||
let posef = helpers::transform_to_posef(&transform);
|
||||
|
||||
|
||||
@@ -221,11 +221,8 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
.input_state
|
||||
.pointers
|
||||
.iter()
|
||||
.any(|p| p.now.show_hide && !p.before.show_hide)
|
||||
{
|
||||
if show_hide_counter.click() {
|
||||
overlays.show_hide(&mut app_state);
|
||||
}
|
||||
.any(|p| p.now.show_hide && !p.before.show_hide) && show_hide_counter.click() {
|
||||
overlays.show_hide(&mut app_state);
|
||||
}
|
||||
|
||||
watch_fade(&mut app_state, overlays.mut_by_id(watch_id).unwrap()); // want panic
|
||||
|
||||
@@ -153,7 +153,6 @@ impl WlxGraphics {
|
||||
instance_extensions.khr_get_physical_device_properties2 = true;
|
||||
|
||||
let instance_extensions_raw = instance_extensions
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter_map(|(name, enabled)| {
|
||||
if enabled {
|
||||
@@ -241,7 +240,6 @@ impl WlxGraphics {
|
||||
};
|
||||
|
||||
let device_extensions_raw = device_extensions
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter_map(|(name, enabled)| {
|
||||
if enabled {
|
||||
@@ -590,7 +588,6 @@ impl WlxGraphics {
|
||||
let format = fourcc_to_vk(frame.format.fourcc)?;
|
||||
|
||||
let layouts: Vec<SubresourceLayout> = (0..frame.num_planes)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
let plane = &frame.planes[i];
|
||||
SubresourceLayout {
|
||||
|
||||
@@ -188,7 +188,7 @@ impl FontCache {
|
||||
|
||||
let bmp = glyph.bitmap();
|
||||
let buf = bmp.buffer().to_vec();
|
||||
if buf.len() == 0 {
|
||||
if buf.is_empty() {
|
||||
return Ok(font.glyphs[0].clone());
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ fn key_press(
|
||||
data.key_click(&app.session);
|
||||
|
||||
if let PointerMode::Right = mode {
|
||||
data.modifiers = data.modifiers | SHIFT;
|
||||
data.modifiers |= SHIFT;
|
||||
app.hid_provider.set_modifiers(data.modifiers);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ impl OverlayRenderer for MirrorRenderer {
|
||||
if let Some(view) = renderer.view() {
|
||||
let extent = view.image().extent();
|
||||
if self.last_extent != extent {
|
||||
self.last_extent = extent.clone();
|
||||
self.last_extent = extent;
|
||||
// resized
|
||||
app.tasks.enqueue(TaskType::Overlay(
|
||||
OverlaySelector::Name(self.name.clone()),
|
||||
|
||||
@@ -356,7 +356,7 @@ impl OverlayRenderer for ScreenRenderer {
|
||||
}
|
||||
});
|
||||
|
||||
self.capture.init(&drm_formats);
|
||||
self.capture.init(drm_formats);
|
||||
self.capture.request_new_frame();
|
||||
};
|
||||
|
||||
@@ -407,7 +407,7 @@ impl OverlayRenderer for ScreenRenderer {
|
||||
let data = unsafe { slice::from_raw_parts(map, len) };
|
||||
|
||||
let image =
|
||||
upload.texture2d(frame.format.width, frame.format.height, format, &data)?;
|
||||
upload.texture2d(frame.format.width, frame.format.height, format, data)?;
|
||||
upload.build_and_execute_now()?;
|
||||
|
||||
unsafe { libc::munmap(map as *mut _, len) };
|
||||
@@ -426,7 +426,7 @@ impl OverlayRenderer for ScreenRenderer {
|
||||
let data = unsafe { slice::from_raw_parts(frame.ptr as *const u8, frame.size) };
|
||||
|
||||
let image =
|
||||
upload.texture2d(frame.format.width, frame.format.height, format, &data)?;
|
||||
upload.texture2d(frame.format.width, frame.format.height, format, data)?;
|
||||
|
||||
let mut pipeline = None;
|
||||
if frame.mouse.is_some() {
|
||||
|
||||
@@ -80,14 +80,11 @@ where
|
||||
canvas.font_size = font_size;
|
||||
canvas.fg_color = color_parse(&fg_color).unwrap_or(FALLBACK_COLOR);
|
||||
|
||||
let tz: Option<Tz> = match timezone {
|
||||
Some(tz) => Some(tz.parse().unwrap_or_else(|_| {
|
||||
let tz: Option<Tz> = timezone.map(|tz| tz.parse().unwrap_or_else(|_| {
|
||||
log::error!("Failed to parse timezone '{}'", &tz);
|
||||
canvas.fg_color = FALLBACK_COLOR;
|
||||
Tz::UTC
|
||||
})),
|
||||
None => None,
|
||||
};
|
||||
}));
|
||||
|
||||
let label = canvas.label(x, y, w, h, empty_str.clone());
|
||||
label.state = Some(ElemState::Clock {
|
||||
|
||||
Reference in New Issue
Block a user