diff --git a/dash-frontend/src/util/steam_utils.rs b/dash-frontend/src/util/steam_utils.rs index 3c7faa3a..56ce0bb6 100644 --- a/dash-frontend/src/util/steam_utils.rs +++ b/dash-frontend/src/util/steam_utils.rs @@ -56,6 +56,8 @@ fn vdf_parse_libraryfolders<'a>(vdf_root: &'a Vdf<'a>) -> Option> let mut res = Vec::::new(); let mut num = 0; + + #[allow(clippy::while_let_loop)] loop { let Some(library_folder) = get_obj_first(obj_libraryfolders, format!("{}", num).as_str()) else { // no more libraries to find @@ -293,7 +295,7 @@ impl SteamUtils { games.sort_by(|a, b| b.name.cmp(&a.name)); } GameSortMethod::PlayDateDesc => { - games.sort_by(|a, b| b.last_played.cmp(&a.last_played)); + games.sort_by_key(|b| std::cmp::Reverse(b.last_played)); } } diff --git a/wayvr/src/backend/input.rs b/wayvr/src/backend/input.rs index cec98ab4..88e8738b 100644 --- a/wayvr/src/backend/input.rs +++ b/wayvr/src/backend/input.rs @@ -125,10 +125,8 @@ impl InputState { hand.interaction.mode = PointerMode::Left; } } - PointerMode::Right => { - if !right_click_orientation { - hand.interaction.mode = PointerMode::Left; - } + PointerMode::Right if !right_click_orientation => { + hand.interaction.mode = PointerMode::Left; } _ => {} } diff --git a/wayvr/src/backend/openvr/input.rs b/wayvr/src/backend/openvr/input.rs index d10f6c91..952b8e36 100644 --- a/wayvr/src/backend/openvr/input.rs +++ b/wayvr/src/backend/openvr/input.rs @@ -216,63 +216,51 @@ impl OpenVrInputSource { app_hand.now.click = input .get_digital_action_data(self.click_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); app_hand.now.grab = input .get_digital_action_data(self.grab_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); app_hand.now.alt_click = input .get_digital_action_data(self.alt_click_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); app_hand.now.show_hide = input .get_digital_action_data(self.show_hide_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); app_hand.now.toggle_dashboard = input .get_digital_action_data(self.toggle_dashboard_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); app_hand.now.space_drag = input .get_digital_action_data(self.space_drag_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); app_hand.now.space_rotate = input .get_digital_action_data(self.space_rotate_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); app_hand.now.space_reset = input .get_digital_action_data(self.space_reset_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); app_hand.now.click_modifier_right = input .get_digital_action_data(self.click_modifier_right_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); app_hand.now.click_modifier_middle = input .get_digital_action_data(self.click_modifier_middle_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); app_hand.now.move_mouse = input .get_digital_action_data(self.move_mouse_hnd, hand.input_hnd) - .map(|x| x.0.bState) - .unwrap_or(false); + .is_ok_and(|x| x.0.bState); let scroll = input .get_analog_action_data(self.scroll_hnd, hand.input_hnd) - .map(|x| (x.0.x, x.0.y)) - .unwrap_or((0.0, 0.0)); + .map_or((0.0, 0.0), |x| (x.0.x, x.0.y)); app_hand.now.scroll_x = scroll.0; app_hand.now.scroll_y = scroll.1; } @@ -364,8 +352,7 @@ fn get_tracked_device( index, ETrackedDeviceProperty::Prop_TrackingSystemName_String, ) - .map(|x: String| x.contains("ALVR")) - .unwrap_or(false); + .is_ok_and(|x: String| x.contains("ALVR")); if is_alvr { // don't show ALVR's fake trackers on battery panel diff --git a/wayvr/src/backend/openxr/mod.rs b/wayvr/src/backend/openxr/mod.rs index ceecfc74..535aa9cd 100644 --- a/wayvr/src/backend/openxr/mod.rs +++ b/wayvr/src/backend/openxr/mod.rs @@ -519,7 +519,7 @@ pub fn openxr_run( let watch = overlays.mut_by_id(watch_id).unwrap(); // want panic if let Some(state) = watch.config.active_state.as_mut() { - state.transform = watch_transform + state.transform = watch_transform; } if !app.session.config.enable_watch { watch.config.deactivate(); diff --git a/wayvr/src/graphics/mod.rs b/wayvr/src/graphics/mod.rs index 5c1573ba..ca16f0f2 100644 --- a/wayvr/src/graphics/mod.rs +++ b/wayvr/src/graphics/mod.rs @@ -114,7 +114,7 @@ impl WGfxExtras { | MemoryTypeFilter::HOST_SEQUENTIAL_WRITE, ..Default::default() }, - vertices.into_iter(), + vertices, )?; let mut cmd_xfer = gfx.create_xfer_command_buffer(CommandBufferUsage::OneTimeSubmit)?; diff --git a/wayvr/src/subsystem/dbus/mod.rs b/wayvr/src/subsystem/dbus/mod.rs index 171498b5..7bb5d506 100644 --- a/wayvr/src/subsystem/dbus/mod.rs +++ b/wayvr/src/subsystem/dbus/mod.rs @@ -45,7 +45,7 @@ impl DbusConnector { let proxy = connection.with_proxy( "org.freedesktop.DBus", "/org/freedesktop/DBus", - Duration::from_millis(5000), + Duration::from_secs(5), ); let result: Result<(), dbus::Error> = proxy.method_call( "org.freedesktop.DBus.Monitoring", diff --git a/wayvr/src/windowing/manager.rs b/wayvr/src/windowing/manager.rs index 8b859ff0..33f0d2b4 100644 --- a/wayvr/src/windowing/manager.rs +++ b/wayvr/src/windowing/manager.rs @@ -288,13 +288,13 @@ where self.sets_changed(app); } OverlayTask::SettingsChanged => { - if let Some(watch) = self.mut_by_id(self.watch_id) { - if app.session.config.enable_watch != watch.config.active_state.is_some() { - if watch.config.active_state.is_some() { - watch.config.deactivate(); - } else { - watch.config.activate(app); - } + if let Some(watch) = self.mut_by_id(self.watch_id) + && app.session.config.enable_watch != watch.config.active_state.is_some() + { + if watch.config.active_state.is_some() { + watch.config.deactivate(); + } else { + watch.config.activate(app); } } diff --git a/wgui/src/renderer_vk/text/text_renderer.rs b/wgui/src/renderer_vk/text/text_renderer.rs index 258c0be9..27439bb0 100644 --- a/wgui/src/renderer_vk/text/text_renderer.rs +++ b/wgui/src/renderer_vk/text/text_renderer.rs @@ -61,9 +61,7 @@ impl TextRenderer { let resolution = viewport.resolution(); let mut glyphs_to_render = Vec::new(); - let mut pending_glyph_uploads = Vec::new(); - let mut missing_glyphs = HashSet::new(); - let mut unavailable_glyphs = HashSet::new(); + let mut glyphs_todo = GlyphsTodo::default(); for text_area in text_areas { let bounds_min_x = text_area.bounds.left.max(0); @@ -101,13 +99,13 @@ impl TextRenderer { .unwrap_or(text_area.default_color); if queue_missing_glyph_upload( - atlas, - font_system, - cache, - cache_key, - &mut missing_glyphs, - &mut unavailable_glyphs, - &mut pending_glyph_uploads, + &mut QueueMissingGlyphUploadParams { + atlas, + font_system, + cache, + cache_key, + glyphs_todo: &mut glyphs_todo, + }, |_cache, _font_system| -> Option { if cached_width == 0 || cached_height == 0 { return None; @@ -180,13 +178,13 @@ impl TextRenderer { let cache_key = GlyphonCacheKey::Text(physical_glyph.cache_key); if queue_missing_glyph_upload( - atlas, - font_system, - cache, - cache_key, - &mut missing_glyphs, - &mut unavailable_glyphs, - &mut pending_glyph_uploads, + &mut QueueMissingGlyphUploadParams { + atlas, + font_system, + cache, + cache_key, + glyphs_todo: &mut glyphs_todo, + }, |cache, font_system| -> Option { let image = cache.get_image_uncached(font_system, physical_glyph.cache_key)?; @@ -229,7 +227,7 @@ impl TextRenderer { } } - upload_missing_glyphs(atlas, font_system, cache, pending_glyph_uploads)?; + upload_missing_glyphs(atlas, font_system, cache, glyphs_todo.pending_uploads)?; for glyph in &glyphs_to_render { if let Some(glyph_to_render) = prepare_glyph(&mut PrepareGlyphParams { @@ -349,31 +347,43 @@ struct PrepareGlyphParams<'a> { model_buffer: &'a mut ModelBuffer, } -fn queue_missing_glyph_upload( - atlas: &mut TextAtlas, - font_system: &mut FontSystem, - cache: &mut SwashCache, +#[derive(Default)] +struct GlyphsTodo { + pending_uploads: Vec, + missing: HashSet, + unavailable: HashSet, +} + +struct QueueMissingGlyphUploadParams<'a> { + atlas: &'a mut TextAtlas, + font_system: &'a mut FontSystem, + cache: &'a mut SwashCache, cache_key: GlyphonCacheKey, - missing_glyphs: &mut HashSet, - unavailable_glyphs: &mut HashSet, - pending_glyph_uploads: &mut Vec, + glyphs_todo: &'a mut GlyphsTodo, +} + +fn queue_missing_glyph_upload( + par: &mut QueueMissingGlyphUploadParams, get_glyph_image: impl FnOnce(&mut SwashCache, &mut FontSystem) -> Option, ) -> bool { - if mark_glyph_in_use_if_cached(atlas, cache_key) { + if mark_glyph_in_use_if_cached(par.atlas, par.cache_key) { return true; } - if unavailable_glyphs.contains(&cache_key) { + if par.glyphs_todo.unavailable.contains(&par.cache_key) { return false; } - if missing_glyphs.insert(cache_key) { - let Some(image) = get_glyph_image(cache, font_system) else { - unavailable_glyphs.insert(cache_key); + if par.glyphs_todo.missing.insert(par.cache_key) { + let Some(image) = get_glyph_image(par.cache, par.font_system) else { + par.glyphs_todo.unavailable.insert(par.cache_key); return false; }; - pending_glyph_uploads.push(PendingGlyphUpload { cache_key, image }); + par.glyphs_todo.pending_uploads.push(PendingGlyphUpload { + cache_key: par.cache_key, + image, + }); } true @@ -422,6 +432,7 @@ fn upload_missing_glyphs( for (upload_index, upload) in rasterized_uploads.iter().enumerate() { let content_type = upload.image.content_type; + #[allow(clippy::never_loop)] let allocation = loop { if let Some(allocation) = { let inner = atlas.inner_for_content_mut(content_type);