clippy, minor refactoring

This commit is contained in:
Aleksander 2026-06-27 12:15:02 +02:00
parent 860ae92edf
commit 92b9cb8d30
8 changed files with 70 additions and 72 deletions

View File

@ -56,6 +56,8 @@ fn vdf_parse_libraryfolders<'a>(vdf_root: &'a Vdf<'a>) -> Option<Vec<AppEntry>>
let mut res = Vec::<AppEntry>::new(); let mut res = Vec::<AppEntry>::new();
let mut num = 0; let mut num = 0;
#[allow(clippy::while_let_loop)]
loop { loop {
let Some(library_folder) = get_obj_first(obj_libraryfolders, format!("{}", num).as_str()) else { let Some(library_folder) = get_obj_first(obj_libraryfolders, format!("{}", num).as_str()) else {
// no more libraries to find // no more libraries to find
@ -293,7 +295,7 @@ impl SteamUtils {
games.sort_by(|a, b| b.name.cmp(&a.name)); games.sort_by(|a, b| b.name.cmp(&a.name));
} }
GameSortMethod::PlayDateDesc => { 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));
} }
} }

View File

@ -125,10 +125,8 @@ impl InputState {
hand.interaction.mode = PointerMode::Left; hand.interaction.mode = PointerMode::Left;
} }
} }
PointerMode::Right => { PointerMode::Right if !right_click_orientation => {
if !right_click_orientation { hand.interaction.mode = PointerMode::Left;
hand.interaction.mode = PointerMode::Left;
}
} }
_ => {} _ => {}
} }

View File

@ -216,63 +216,51 @@ impl OpenVrInputSource {
app_hand.now.click = input app_hand.now.click = input
.get_digital_action_data(self.click_hnd, hand.input_hnd) .get_digital_action_data(self.click_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
app_hand.now.grab = input app_hand.now.grab = input
.get_digital_action_data(self.grab_hnd, hand.input_hnd) .get_digital_action_data(self.grab_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
app_hand.now.alt_click = input app_hand.now.alt_click = input
.get_digital_action_data(self.alt_click_hnd, hand.input_hnd) .get_digital_action_data(self.alt_click_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
app_hand.now.show_hide = input app_hand.now.show_hide = input
.get_digital_action_data(self.show_hide_hnd, hand.input_hnd) .get_digital_action_data(self.show_hide_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
app_hand.now.toggle_dashboard = input app_hand.now.toggle_dashboard = input
.get_digital_action_data(self.toggle_dashboard_hnd, hand.input_hnd) .get_digital_action_data(self.toggle_dashboard_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
app_hand.now.space_drag = input app_hand.now.space_drag = input
.get_digital_action_data(self.space_drag_hnd, hand.input_hnd) .get_digital_action_data(self.space_drag_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
app_hand.now.space_rotate = input app_hand.now.space_rotate = input
.get_digital_action_data(self.space_rotate_hnd, hand.input_hnd) .get_digital_action_data(self.space_rotate_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
app_hand.now.space_reset = input app_hand.now.space_reset = input
.get_digital_action_data(self.space_reset_hnd, hand.input_hnd) .get_digital_action_data(self.space_reset_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
app_hand.now.click_modifier_right = input app_hand.now.click_modifier_right = input
.get_digital_action_data(self.click_modifier_right_hnd, hand.input_hnd) .get_digital_action_data(self.click_modifier_right_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
app_hand.now.click_modifier_middle = input app_hand.now.click_modifier_middle = input
.get_digital_action_data(self.click_modifier_middle_hnd, hand.input_hnd) .get_digital_action_data(self.click_modifier_middle_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
app_hand.now.move_mouse = input app_hand.now.move_mouse = input
.get_digital_action_data(self.move_mouse_hnd, hand.input_hnd) .get_digital_action_data(self.move_mouse_hnd, hand.input_hnd)
.map(|x| x.0.bState) .is_ok_and(|x| x.0.bState);
.unwrap_or(false);
let scroll = input let scroll = input
.get_analog_action_data(self.scroll_hnd, hand.input_hnd) .get_analog_action_data(self.scroll_hnd, hand.input_hnd)
.map(|x| (x.0.x, x.0.y)) .map_or((0.0, 0.0), |x| (x.0.x, x.0.y));
.unwrap_or((0.0, 0.0));
app_hand.now.scroll_x = scroll.0; app_hand.now.scroll_x = scroll.0;
app_hand.now.scroll_y = scroll.1; app_hand.now.scroll_y = scroll.1;
} }
@ -364,8 +352,7 @@ fn get_tracked_device(
index, index,
ETrackedDeviceProperty::Prop_TrackingSystemName_String, ETrackedDeviceProperty::Prop_TrackingSystemName_String,
) )
.map(|x: String| x.contains("ALVR")) .is_ok_and(|x: String| x.contains("ALVR"));
.unwrap_or(false);
if is_alvr { if is_alvr {
// don't show ALVR's fake trackers on battery panel // don't show ALVR's fake trackers on battery panel

View File

@ -519,7 +519,7 @@ pub fn openxr_run(
let watch = overlays.mut_by_id(watch_id).unwrap(); // want panic let watch = overlays.mut_by_id(watch_id).unwrap(); // want panic
if let Some(state) = watch.config.active_state.as_mut() { if let Some(state) = watch.config.active_state.as_mut() {
state.transform = watch_transform state.transform = watch_transform;
} }
if !app.session.config.enable_watch { if !app.session.config.enable_watch {
watch.config.deactivate(); watch.config.deactivate();

View File

@ -114,7 +114,7 @@ impl WGfxExtras {
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE, | MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
..Default::default() ..Default::default()
}, },
vertices.into_iter(), vertices,
)?; )?;
let mut cmd_xfer = gfx.create_xfer_command_buffer(CommandBufferUsage::OneTimeSubmit)?; let mut cmd_xfer = gfx.create_xfer_command_buffer(CommandBufferUsage::OneTimeSubmit)?;

View File

@ -45,7 +45,7 @@ impl DbusConnector {
let proxy = connection.with_proxy( let proxy = connection.with_proxy(
"org.freedesktop.DBus", "org.freedesktop.DBus",
"/org/freedesktop/DBus", "/org/freedesktop/DBus",
Duration::from_millis(5000), Duration::from_secs(5),
); );
let result: Result<(), dbus::Error> = proxy.method_call( let result: Result<(), dbus::Error> = proxy.method_call(
"org.freedesktop.DBus.Monitoring", "org.freedesktop.DBus.Monitoring",

View File

@ -288,13 +288,13 @@ where
self.sets_changed(app); self.sets_changed(app);
} }
OverlayTask::SettingsChanged => { OverlayTask::SettingsChanged => {
if let Some(watch) = self.mut_by_id(self.watch_id) { if let Some(watch) = self.mut_by_id(self.watch_id)
if app.session.config.enable_watch != watch.config.active_state.is_some() { && app.session.config.enable_watch != watch.config.active_state.is_some()
if watch.config.active_state.is_some() { {
watch.config.deactivate(); if watch.config.active_state.is_some() {
} else { watch.config.deactivate();
watch.config.activate(app); } else {
} watch.config.activate(app);
} }
} }

View File

@ -61,9 +61,7 @@ impl TextRenderer {
let resolution = viewport.resolution(); let resolution = viewport.resolution();
let mut glyphs_to_render = Vec::new(); let mut glyphs_to_render = Vec::new();
let mut pending_glyph_uploads = Vec::new(); let mut glyphs_todo = GlyphsTodo::default();
let mut missing_glyphs = HashSet::new();
let mut unavailable_glyphs = HashSet::new();
for text_area in text_areas { for text_area in text_areas {
let bounds_min_x = text_area.bounds.left.max(0); let bounds_min_x = text_area.bounds.left.max(0);
@ -101,13 +99,13 @@ impl TextRenderer {
.unwrap_or(text_area.default_color); .unwrap_or(text_area.default_color);
if queue_missing_glyph_upload( if queue_missing_glyph_upload(
atlas, &mut QueueMissingGlyphUploadParams {
font_system, atlas,
cache, font_system,
cache_key, cache,
&mut missing_glyphs, cache_key,
&mut unavailable_glyphs, glyphs_todo: &mut glyphs_todo,
&mut pending_glyph_uploads, },
|_cache, _font_system| -> Option<GetGlyphImageResult> { |_cache, _font_system| -> Option<GetGlyphImageResult> {
if cached_width == 0 || cached_height == 0 { if cached_width == 0 || cached_height == 0 {
return None; return None;
@ -180,13 +178,13 @@ impl TextRenderer {
let cache_key = GlyphonCacheKey::Text(physical_glyph.cache_key); let cache_key = GlyphonCacheKey::Text(physical_glyph.cache_key);
if queue_missing_glyph_upload( if queue_missing_glyph_upload(
atlas, &mut QueueMissingGlyphUploadParams {
font_system, atlas,
cache, font_system,
cache_key, cache,
&mut missing_glyphs, cache_key,
&mut unavailable_glyphs, glyphs_todo: &mut glyphs_todo,
&mut pending_glyph_uploads, },
|cache, font_system| -> Option<GetGlyphImageResult> { |cache, font_system| -> Option<GetGlyphImageResult> {
let image = cache.get_image_uncached(font_system, physical_glyph.cache_key)?; 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 { for glyph in &glyphs_to_render {
if let Some(glyph_to_render) = prepare_glyph(&mut PrepareGlyphParams { if let Some(glyph_to_render) = prepare_glyph(&mut PrepareGlyphParams {
@ -349,31 +347,43 @@ struct PrepareGlyphParams<'a> {
model_buffer: &'a mut ModelBuffer, model_buffer: &'a mut ModelBuffer,
} }
fn queue_missing_glyph_upload( #[derive(Default)]
atlas: &mut TextAtlas, struct GlyphsTodo {
font_system: &mut FontSystem, pending_uploads: Vec<PendingGlyphUpload>,
cache: &mut SwashCache, missing: HashSet<GlyphonCacheKey>,
unavailable: HashSet<GlyphonCacheKey>,
}
struct QueueMissingGlyphUploadParams<'a> {
atlas: &'a mut TextAtlas,
font_system: &'a mut FontSystem,
cache: &'a mut SwashCache,
cache_key: GlyphonCacheKey, cache_key: GlyphonCacheKey,
missing_glyphs: &mut HashSet<GlyphonCacheKey>, glyphs_todo: &'a mut GlyphsTodo,
unavailable_glyphs: &mut HashSet<GlyphonCacheKey>, }
pending_glyph_uploads: &mut Vec<PendingGlyphUpload>,
fn queue_missing_glyph_upload(
par: &mut QueueMissingGlyphUploadParams,
get_glyph_image: impl FnOnce(&mut SwashCache, &mut FontSystem) -> Option<GetGlyphImageResult>, get_glyph_image: impl FnOnce(&mut SwashCache, &mut FontSystem) -> Option<GetGlyphImageResult>,
) -> bool { ) -> 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; return true;
} }
if unavailable_glyphs.contains(&cache_key) { if par.glyphs_todo.unavailable.contains(&par.cache_key) {
return false; return false;
} }
if missing_glyphs.insert(cache_key) { if par.glyphs_todo.missing.insert(par.cache_key) {
let Some(image) = get_glyph_image(cache, font_system) else { let Some(image) = get_glyph_image(par.cache, par.font_system) else {
unavailable_glyphs.insert(cache_key); par.glyphs_todo.unavailable.insert(par.cache_key);
return false; return false;
}; };
pending_glyph_uploads.push(PendingGlyphUpload { cache_key, image }); par.glyphs_todo.pending_uploads.push(PendingGlyphUpload {
cache_key: par.cache_key,
image,
});
} }
true true
@ -422,6 +432,7 @@ fn upload_missing_glyphs(
for (upload_index, upload) in rasterized_uploads.iter().enumerate() { for (upload_index, upload) in rasterized_uploads.iter().enumerate() {
let content_type = upload.image.content_type; let content_type = upload.image.content_type;
#[allow(clippy::never_loop)]
let allocation = loop { let allocation = loop {
if let Some(allocation) = { if let Some(allocation) = {
let inner = atlas.inner_for_content_mut(content_type); let inner = atlas.inner_for_content_mut(content_type);