This commit is contained in:
galister
2025-10-31 17:33:38 +09:00
parent fa562f7b12
commit 67017a9f54
21 changed files with 30 additions and 39 deletions

View File

@@ -1,5 +1,5 @@
use crate::{ use crate::{
components::{self, Component, button, tooltip}, components::{Component, button, tooltip},
drawing::Color, drawing::Color,
i18n::Translation, i18n::Translation,
layout::WidgetID, layout::WidgetID,

View File

@@ -783,7 +783,7 @@ fn parse_widget_universal(ctx: &mut ParserContext, widget_id: WidgetID, attribs:
ctx.insert_id(&pair.value, widget_id); ctx.insert_id(&pair.value, widget_id);
} }
"interactable" => { "interactable" => {
if let Ok(0) = &pair.value.parse::<i32>() { if matches!(&pair.value.parse::<i32>(), Ok(0)) {
log::info!("setting {widget_id:?} to noninteractable."); log::info!("setting {widget_id:?} to noninteractable.");
ctx.layout.state.widgets.get(widget_id).unwrap().state().interactable = false; ctx.layout.state.widgets.get(widget_id).unwrap().state().interactable = false;
} else { } else {

View File

@@ -479,7 +479,7 @@ fn handle_scroll<O>(hit: &PointerHit, hovered: &mut OverlayWindowData<O>, app: &
hovered hovered
.config .config
.backend .backend
.on_scroll(app, &hit, scroll_y, scroll_x); .on_scroll(app, hit, scroll_y, scroll_x);
} }
} }
} }
@@ -511,11 +511,10 @@ where
id, id,
&overlay_state.transform, &overlay_state.transform,
overlay_state.curvature.as_ref(), overlay_state.curvature.as_ref(),
) { )
if hit.dist.is_finite() { && hit.dist.is_finite() {
hits.push(hit); hits.push(hit);
} }
}
} }
hits.sort_by(|a, b| a.dist.total_cmp(&b.dist)); hits.sort_by(|a, b| a.dist.total_cmp(&b.dist));
@@ -657,7 +656,7 @@ fn ray_test(
let (dist, local_pos) = curvature.map_or_else( let (dist, local_pos) = curvature.map_or_else(
|| { || {
Some(raycast_plane( Some(raycast_plane(
&ray_origin, ray_origin,
Vec3A::NEG_Z, Vec3A::NEG_Z,
overlay_pose, overlay_pose,
Vec3A::NEG_Z, Vec3A::NEG_Z,

View File

@@ -354,7 +354,7 @@ pub fn set_action_manifest(input: &mut InputManager) -> anyhow::Result<()> {
} }
if let Err(e) = input.set_action_manifest(action_path.as_path()) { if let Err(e) = input.set_action_manifest(action_path.as_path()) {
bail!("Failed to set action manifest: {}", e); bail!("Failed to set action manifest: {e}");
} }
Ok(()) Ok(())
} }

View File

@@ -26,7 +26,7 @@ use crate::backend::input::{HoverResult, PointerHit};
use crate::graphics::CommandBuffers; use crate::graphics::CommandBuffers;
use crate::state::AppState; use crate::state::AppState;
use crate::windowing::backend::{FrameMeta, OverlayBackend, ShouldRender}; use crate::windowing::backend::{FrameMeta, OverlayBackend, ShouldRender};
use crate::windowing::window::{OverlayWindowConfig, OverlayWindowData, OverlayWindowState}; use crate::windowing::window::{OverlayWindowConfig, OverlayWindowData};
use crate::windowing::Z_ORDER_LINES; use crate::windowing::Z_ORDER_LINES;
use super::overlay::OpenVrOverlayData; use super::overlay::OpenVrOverlayData;
@@ -85,9 +85,7 @@ impl LinePool {
}, },
..OverlayWindowData::from_config(OverlayWindowConfig { ..OverlayWindowData::from_config(OverlayWindowConfig {
name: Arc::from(format!("wlx-line{id}")), name: Arc::from(format!("wlx-line{id}")),
default_state: OverlayWindowState { default_state: Default::default(),
..Default::default()
},
z_order: Z_ORDER_LINES, z_order: Z_ORDER_LINES,
..OverlayWindowConfig::from_backend(Box::new(LineBackend { ..OverlayWindowConfig::from_backend(Box::new(LineBackend {
view: self.view.clone(), view: self.view.clone(),

View File

@@ -53,14 +53,12 @@ pub(super) fn install_manifest(app_mgr: &mut ApplicationsManager) -> anyhow::Res
}; };
let Ok(mut file) = File::create(&manifest_path) else { let Ok(mut file) = File::create(&manifest_path) else {
bail!("Failed to create manifest file at {:?}", manifest_path); bail!("Failed to create manifest file at {manifest_path:?}");
}; };
if let Err(e) = manifest.write(&mut file) { if let Err(e) = manifest.write(&mut file) {
bail!( bail!(
"Failed to write manifest file at {:?}: {:?}", "Failed to write manifest file at {manifest_path:?}: {e:?}"
manifest_path,
e
); );
} }

View File

@@ -88,8 +88,7 @@ impl OverlayWindowData<OpenVrOverlayData> {
.config .config
.active_state .active_state
.as_ref() .as_ref()
.map(|x| x.alpha > 0.05) .is_some_and(|x| x.alpha > 0.05);
.unwrap_or(false);
if want_visible && !self.data.visible { if want_visible && !self.data.visible {
self.show_internal(overlay, app)?; self.show_internal(overlay, app)?;

View File

@@ -125,8 +125,7 @@ impl OverlayWindowData<OpenXrOverlayData> {
.config .config
.active_state .active_state
.as_ref() .as_ref()
.map(|x| x.alpha > 0.05) .is_some_and(|x| x.alpha > 0.05);
.unwrap_or(false);
if self.data.last_visible != want_visible { if self.data.last_visible != want_visible {
if want_visible { if want_visible {

View File

@@ -576,9 +576,7 @@ impl Display {
Ok(child) => Ok(SpawnProcessResult { auth_key, child }), Ok(child) => Ok(SpawnProcessResult { auth_key, child }),
Err(e) => { Err(e) => {
anyhow::bail!( anyhow::bail!(
"Failed to launch process with path \"{}\": {}. Make sure your exec path exists.", "Failed to launch process with path \"{exec_path}\": {e}. Make sure your exec path exists."
exec_path,
e
); );
} }
} }

View File

@@ -56,7 +56,7 @@ fn load_egl_func(
) -> anyhow::Result<extern "system" fn()> { ) -> anyhow::Result<extern "system" fn()> {
let raw_fn = egl let raw_fn = egl
.get_proc_address(func_name) .get_proc_address(func_name)
.ok_or_else(|| anyhow::anyhow!("Required EGL function {} not found", func_name))?; .ok_or_else(|| anyhow::anyhow!("Required EGL function {func_name} not found"))?;
Ok(raw_fn) Ok(raw_fn)
} }

View File

@@ -619,7 +619,7 @@ impl WayVRServer {
.nonblocking(local_socket::ListenerNonblockingMode::Both); .nonblocking(local_socket::ListenerNonblockingMode::Both);
let listener = match opts.create_sync() { let listener = match opts.create_sync() {
Ok(listener) => listener, Ok(listener) => listener,
Err(e) => anyhow::bail!("Failed to start WayVRServer IPC listener. Reason: {}", e), Err(e) => anyhow::bail!("Failed to start WayVRServer IPC listener. Reason: {e}"),
}; };
log::info!("WayVRServer IPC running at {printname}"); log::info!("WayVRServer IPC running at {printname}");

View File

@@ -96,6 +96,6 @@ pub fn dds_to_vk(dds_fmt: ImageFormat) -> anyhow::Result<Format> {
// BPTC // BPTC
ImageFormat::BC7RgbaUnorm => Ok(Format::BC7_UNORM_BLOCK), ImageFormat::BC7RgbaUnorm => Ok(Format::BC7_UNORM_BLOCK),
ImageFormat::BC7RgbaUnormSrgb => Ok(Format::BC7_SRGB_BLOCK), ImageFormat::BC7RgbaUnormSrgb => Ok(Format::BC7_SRGB_BLOCK),
_ => anyhow::bail!("Unsupported format {:?}", dds_fmt), _ => anyhow::bail!("Unsupported format {dds_fmt:?}"),
} }
} }

View File

@@ -347,6 +347,6 @@ pub fn fourcc_to_vk(fourcc: FourCC) -> anyhow::Result<Format> {
DRM_FORMAT_ABGR8888 | DRM_FORMAT_XBGR8888 => Ok(Format::R8G8B8A8_UNORM), DRM_FORMAT_ABGR8888 | DRM_FORMAT_XBGR8888 => Ok(Format::R8G8B8A8_UNORM),
DRM_FORMAT_ARGB8888 | DRM_FORMAT_XRGB8888 => Ok(Format::B8G8R8A8_UNORM), DRM_FORMAT_ARGB8888 | DRM_FORMAT_XRGB8888 => Ok(Format::B8G8R8A8_UNORM),
DRM_FORMAT_ABGR2101010 | DRM_FORMAT_XBGR2101010 => Ok(Format::A2B10G10R10_UNORM_PACK32), DRM_FORMAT_ABGR2101010 | DRM_FORMAT_XBGR2101010 => Ok(Format::A2B10G10R10_UNORM_PACK32),
_ => anyhow::bail!("Unsupported format {}", fourcc), _ => anyhow::bail!("Unsupported format {fourcc}"),
} }
} }

View File

@@ -310,7 +310,7 @@ pub fn init_openxr_graphics(
.descriptor_binding_sampled_image_update_after_bind(true); .descriptor_binding_sampled_image_update_after_bind(true);
dynamic_rendering.p_next = device_create_info.p_next.cast_mut(); dynamic_rendering.p_next = device_create_info.p_next.cast_mut();
indexing_features.p_next = &raw mut dynamic_rendering as *mut c_void; indexing_features.p_next = (&raw mut dynamic_rendering).cast::<c_void>();
device_create_info.p_next = &raw mut indexing_features as *const c_void; device_create_info.p_next = &raw mut indexing_features as *const c_void;
let (device, queues) = unsafe { let (device, queues) = unsafe {

View File

@@ -6,7 +6,7 @@ impl wgui::assets::AssetProvider for GuiAsset {
fn load_from_path(&mut self, path: &str) -> anyhow::Result<Vec<u8>> { fn load_from_path(&mut self, path: &str) -> anyhow::Result<Vec<u8>> {
match Self::get(path) { match Self::get(path) {
Some(data) => Ok(data.data.to_vec()), Some(data) => Ok(data.data.to_vec()),
None => anyhow::bail!("embedded file {} not found", path), None => anyhow::bail!("embedded file {path} not found"),
} }
} }
} }

View File

@@ -275,7 +275,7 @@ impl<S: 'static> OverlayBackend for GuiPanel<S> {
pos: hit.uv * self.layout.content_size, pos: hit.uv * self.layout.content_size,
device: hit.pointer, device: hit.pointer,
}); });
let result = self.push_event(app, &e); let result = self.push_event(app, e);
HoverResult { HoverResult {
consume: result != EventResult::NoHit, consume: result != EventResult::NoHit,

View File

@@ -168,7 +168,7 @@ pub fn create_keyboard(
params, params,
)?; )?;
if let Some(widget_id) = gui_state_key.get_widget_id(&*my_id).ok() { if let Ok(widget_id) = gui_state_key.get_widget_id(&my_id) {
let key_state = { let key_state = {
let rect = panel let rect = panel
.layout .layout

View File

@@ -187,7 +187,7 @@ fn get_or_create_display_by_name(
.session .session
.wayvr_config .wayvr_config
.get_display(disp_name) .get_display(disp_name)
.ok_or_else(|| anyhow::anyhow!("Cannot find display named \"{}\"", disp_name))? .ok_or_else(|| anyhow::anyhow!("Cannot find display named \"{disp_name}\""))?
.clone(); .clone();
let disp_handle = wayvr.data.state.create_display( let disp_handle = wayvr.data.state.create_display(
@@ -852,7 +852,7 @@ where
.session .session
.wayvr_config .wayvr_config
.get_catalog(catalog_name) .get_catalog(catalog_name)
.ok_or_else(|| anyhow::anyhow!("Failed to get catalog \"{}\"", catalog_name))? .ok_or_else(|| anyhow::anyhow!("Failed to get catalog \"{catalog_name}\""))?
.clone(); .clone();
if let Some(app_entry) = catalog.get_app(app_name) { if let Some(app_entry) = catalog.get_app(app_name) {

View File

@@ -40,6 +40,6 @@ impl AudioOutput {
return; return;
} }
}; };
let _ = handle.mixer().add(source); let () = handle.mixer().add(source);
} }
} }

View File

@@ -77,7 +77,7 @@ where
.and_then(|s| s.overlays.get(keyboard_id)) .and_then(|s| s.overlays.get(keyboard_id))
.unwrap() .unwrap()
.clone(); .clone();
for set in me.sets.iter_mut() { for set in &mut me.sets {
set.overlays.insert(keyboard_id, kbd_state.clone()); set.overlays.insert(keyboard_id, kbd_state.clone());
} }
@@ -151,8 +151,8 @@ impl<T> OverlayWindowManager<T> {
if overlay.config.show_on_spawn { if overlay.config.show_on_spawn {
overlay.config.activate(app); overlay.config.activate(app);
} }
let id = self.overlays.insert(overlay);
id self.overlays.insert(overlay)
} }
pub fn switch_or_toggle_set(&mut self, app: &mut AppState, set: usize) { pub fn switch_or_toggle_set(&mut self, app: &mut AppState, set: usize) {

View File

@@ -34,10 +34,10 @@ pub enum Positioning {
} }
impl Positioning { impl Positioning {
pub fn moves_with_space(&self) -> bool { pub const fn moves_with_space(&self) -> bool {
matches!( matches!(
self, self,
Positioning::Floating | Positioning::Anchored | Positioning::Static Self::Floating | Self::Anchored | Self::Static
) )
} }
} }