mirror of
https://github.com/wayvr-org/wayvr.git
synced 2026-11-20 09:01:18 -08:00
clippy
This commit is contained in:
1 parent
ebd3b2e415
commit
f672069ba7
16 files changed
+77
-75
No files matched your search
@@ -1008,7 +1008,7 @@ fn create_dropdown<B: 'static + BindingsDropdown>(
|
||||
.iter()
|
||||
.map(|item| {
|
||||
context_menu::Cell::Button(context_menu::Button {
|
||||
action_name: Some(item.action_str(&action, side).into()),
|
||||
action_name: Some(item.action_str(&action, side)),
|
||||
title: item.translation(),
|
||||
..Default::default()
|
||||
})
|
||||
@@ -1019,7 +1019,7 @@ fn create_dropdown<B: 'static + BindingsDropdown>(
|
||||
cells.insert(
|
||||
0,
|
||||
context_menu::Cell::Button(context_menu::Button {
|
||||
action_name: Some(action_str.into()),
|
||||
action_name: Some(action_str),
|
||||
title: Translation::from_translation_key("APP_SETTINGS.OPTION.NONE"),
|
||||
..Default::default()
|
||||
}),
|
||||
|
||||
@@ -874,11 +874,11 @@ fn start_grab(par: StartGrabParams) {
|
||||
// - not in editmode
|
||||
// - not using grab_float
|
||||
// - grabbing with one hand. (grabbing with the 2nd hand will grab the individual overlay instead)
|
||||
let grab_anchor = !par.edit_mode
|
||||
&& !par.grab_float
|
||||
&& !app.anchor_grabbed
|
||||
&& matches!(state.positioning, Positioning::Anchored)
|
||||
&& !(app.session.config.middle_grabs_single
|
||||
let grab_anchor = !(par.edit_mode
|
||||
|| par.grab_float
|
||||
|| app.anchor_grabbed
|
||||
|| !matches!(state.positioning, Positioning::Anchored)
|
||||
|| app.session.config.middle_grabs_single
|
||||
&& pointer.interaction.mode == PointerMode::Middle);
|
||||
|
||||
let relative_grab_transform = if grab_anchor {
|
||||
|
||||
@@ -723,7 +723,7 @@ fn for_each_path(spec: Option<&OneOrMany<String>>, mut f: impl FnMut(&str)) {
|
||||
}
|
||||
}
|
||||
|
||||
fn button_actions(profile: &OpenXrInputProfile) -> [Option<&OpenXrInputAction>; 11] {
|
||||
const fn button_actions(profile: &OpenXrInputProfile) -> [Option<&OpenXrInputAction>; 11] {
|
||||
[
|
||||
profile.click.as_ref(),
|
||||
profile.alt_click.as_ref(),
|
||||
@@ -925,7 +925,7 @@ fn add_button_bindings(
|
||||
|
||||
for (side, hand) in hands.iter_mut().enumerate() {
|
||||
for binding in build_button_bindings(action, side, profile_index, physical_input_map) {
|
||||
field(&mut **hand).add_binding(binding);
|
||||
field(hand).add_binding(binding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,34 +146,30 @@ impl PlayspaceMover {
|
||||
self.rotate = Some(data);
|
||||
// drag and rotate can share a button
|
||||
return;
|
||||
} else {
|
||||
// start space rotate
|
||||
for (i, pointer) in app.input_state.pointers.iter().enumerate() {
|
||||
if pointer.now.space_rotate {
|
||||
let Ok(pose) = monado
|
||||
.ipc
|
||||
.get_reference_space_offset(ReferenceSpaceType::Stage)
|
||||
.log_err("Could not get reference space offset.")
|
||||
.map(|p| {
|
||||
Affine3A::from_rotation_translation(
|
||||
p.orientation.into(),
|
||||
p.position.into(),
|
||||
)
|
||||
})
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
let hand_pose = pose * pointer.raw_pose;
|
||||
self.rotate = Some(MoverData {
|
||||
pose,
|
||||
hand: i,
|
||||
hand_pose,
|
||||
});
|
||||
self.drag = None;
|
||||
log::info!("Start space rotate");
|
||||
}
|
||||
// start space rotate
|
||||
for (i, pointer) in app.input_state.pointers.iter().enumerate() {
|
||||
if pointer.now.space_rotate {
|
||||
let Ok(pose) = monado
|
||||
.ipc
|
||||
.get_reference_space_offset(ReferenceSpaceType::Stage)
|
||||
.log_err("Could not get reference space offset.")
|
||||
.map(|p| {
|
||||
Affine3A::from_rotation_translation(p.orientation.into(), p.position.into())
|
||||
})
|
||||
else {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let hand_pose = pose * pointer.raw_pose;
|
||||
self.rotate = Some(MoverData {
|
||||
pose,
|
||||
hand: i,
|
||||
hand_pose,
|
||||
});
|
||||
self.drag = None;
|
||||
log::info!("Start space rotate");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ impl WlxSwapchain {
|
||||
|
||||
struct RetiredSwapchain {
|
||||
// keep alive until completion is signaled
|
||||
_swapchain: WlxSwapchain,
|
||||
swapchain: WlxSwapchain,
|
||||
completion: Option<GpuCompletionMarker>,
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ impl SwapchainRetirementQueue {
|
||||
/// queue the swapchain for non-blocking retirement
|
||||
pub(super) fn retire(&mut self, swapchain: WlxSwapchain, gfx: &Arc<WGfx>) {
|
||||
self.retired.push(RetiredSwapchain {
|
||||
_swapchain: swapchain,
|
||||
swapchain,
|
||||
completion: None,
|
||||
});
|
||||
|
||||
@@ -177,7 +177,7 @@ impl SwapchainRetirementQueue {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
retired._swapchain.ensure_image_released()?;
|
||||
retired.swapchain.ensure_image_released()?;
|
||||
retired.completion = Some(gfx.submit_graphics_completion_marker()?);
|
||||
Ok(())
|
||||
}
|
||||
@@ -185,12 +185,12 @@ impl SwapchainRetirementQueue {
|
||||
pub(super) fn collect(&mut self, gfx: &Arc<WGfx>) {
|
||||
let mut idx = 0;
|
||||
while idx < self.retired.len() {
|
||||
if self.retired[idx].completion.is_none() {
|
||||
if let Err(e) = Self::arm(&mut self.retired[idx], gfx) {
|
||||
log::warn!("Failed re-arming retired OpenXR swapchain: {e:#}");
|
||||
idx += 1;
|
||||
continue;
|
||||
}
|
||||
if self.retired[idx].completion.is_none()
|
||||
&& let Err(e) = Self::arm(&mut self.retired[idx], gfx)
|
||||
{
|
||||
log::warn!("Failed re-arming retired OpenXR swapchain: {e:#}");
|
||||
idx += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
let complete = match self.retired[idx]
|
||||
|
||||
@@ -248,7 +248,7 @@ impl Application {
|
||||
}
|
||||
}
|
||||
|
||||
fn drm_format_has_alpha(format: DrmFourcc) -> bool {
|
||||
const fn drm_format_has_alpha(format: DrmFourcc) -> bool {
|
||||
matches!(
|
||||
format,
|
||||
DrmFourcc::Abgr8888 | DrmFourcc::Argb8888 | DrmFourcc::Abgr2101010
|
||||
|
||||
@@ -504,8 +504,7 @@ impl WvrServerState {
|
||||
let mut title: Arc<str> = fallback_title
|
||||
.map(Arc::from)
|
||||
.or_else(|| name.clone())
|
||||
.unwrap_or_else(|| format!("P{}", client.pid).into())
|
||||
.into();
|
||||
.unwrap_or_else(|| format!("P{}", client.pid).into());
|
||||
|
||||
let spawn_pos = SpawnPos::WlDefault(
|
||||
window_handle,
|
||||
@@ -559,8 +558,9 @@ impl WvrServerState {
|
||||
.wvr_server
|
||||
.as_ref()
|
||||
.and_then(|wvr| wvr.wm.windows.get(window_handle))
|
||||
.map(|w| (w.name.clone(), w.restore_on_spawn))
|
||||
.unwrap_or((None, false));
|
||||
.map_or((None, false), |w| {
|
||||
(w.name.clone(), w.restore_on_spawn)
|
||||
});
|
||||
let persistent = identity.is_some();
|
||||
let name =
|
||||
identity.unwrap_or_else(|| window_handle.transient_name());
|
||||
@@ -686,7 +686,7 @@ impl WvrServerState {
|
||||
window.app_id = app_id;
|
||||
window.parent = parent;
|
||||
if window.name != key || window.restore_on_spawn != restore {
|
||||
window.name = key.clone();
|
||||
window.name.clone_from(&key);
|
||||
window.restore_on_spawn = restore;
|
||||
if let Some(oid) = wvr_server.window_to_overlay.get(&handle) {
|
||||
let persistent = key.is_some();
|
||||
@@ -878,7 +878,7 @@ impl WvrServerState {
|
||||
Box::new(move |app| {
|
||||
create_drag_item(app, icon, pointer)
|
||||
.inspect_err(|e| {
|
||||
log::warn!("Could not create drag item overlay: {e:?}")
|
||||
log::warn!("Could not create drag item overlay: {e:?}");
|
||||
})
|
||||
.ok()
|
||||
}),
|
||||
@@ -1499,7 +1499,7 @@ impl WvrServerState {
|
||||
self.manager.send_pointer_button(index, pressed);
|
||||
}
|
||||
|
||||
pub fn set_vr_pointer(&mut self, pointer: usize) {
|
||||
pub const fn set_vr_pointer(&mut self, pointer: usize) {
|
||||
self.manager.state.vr_pointer = pointer;
|
||||
}
|
||||
|
||||
@@ -1514,7 +1514,7 @@ impl WvrServerState {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dnd_active(&self) -> bool {
|
||||
pub const fn dnd_active(&self) -> bool {
|
||||
self.manager.state.dnd_pointer.is_some()
|
||||
}
|
||||
|
||||
@@ -1736,6 +1736,7 @@ impl SurfaceBufWithImage {
|
||||
|
||||
let mut guard = surface_data.cached_state.get::<ViewportCachedState>();
|
||||
let viewport = *guard.current();
|
||||
drop(guard);
|
||||
let Some(src) = viewport.src else {
|
||||
return [0.0, 0.0, 1.0, 1.0];
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::{collections::HashMap, io::Read, sync::Arc};
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use slotmap::{DenseSlotMap, new_key_type};
|
||||
use slotmap::new_key_type;
|
||||
use wayvr_ipc::{packet_client, packet_server};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -39,7 +39,7 @@ pub(super) fn app_key(app_id: &str) -> Arc<str> {
|
||||
format!("wayvr/app/{}:{app_id}", app_id.len()).into()
|
||||
}
|
||||
|
||||
pub(super) struct WindowSession {
|
||||
pub struct WindowSession {
|
||||
pub key: Arc<str>,
|
||||
pub restore_requested: bool,
|
||||
pub restore_resource: Option<XdgToplevelSessionV1>,
|
||||
|
||||
@@ -3,16 +3,21 @@
|
||||
#[allow(clippy::all)]
|
||||
pub mod server {
|
||||
use smithay::reexports::wayland_server;
|
||||
use wayland_protocols::xdg::shell::server::*;
|
||||
use wayland_protocols::xdg::shell::server::xdg_toplevel;
|
||||
use wayland_server::protocol::*;
|
||||
|
||||
pub mod __interfaces {
|
||||
use super::wayland_server;
|
||||
use wayland_protocols::xdg::shell::server::__interfaces::*;
|
||||
use wayland_protocols::xdg::shell::server::__interfaces::{
|
||||
XDG_TOPLEVEL_INTERFACE, xdg_toplevel_interface,
|
||||
};
|
||||
use wayland_server::backend as wayland_backend;
|
||||
use wayland_server::protocol::__interfaces::*;
|
||||
wayland_scanner::generate_interfaces!("protocols/xdg-session-management-v1.xml");
|
||||
}
|
||||
use self::__interfaces::*;
|
||||
use self::__interfaces::{
|
||||
XDG_SESSION_MANAGER_V1_INTERFACE, XDG_SESSION_V1_INTERFACE,
|
||||
XDG_TOPLEVEL_SESSION_V1_INTERFACE,
|
||||
};
|
||||
wayland_scanner::generate_server_code!("protocols/xdg-session-management-v1.xml");
|
||||
}
|
||||
@@ -116,7 +116,7 @@ impl OverlayList {
|
||||
}
|
||||
|
||||
params.insert_rc("idx", i.to_string().into());
|
||||
params.insert("name", meta.title.as_deref().unwrap_or(meta.name.as_ref()));
|
||||
params.insert("name", meta.title.as_deref().unwrap_or(&meta.name));
|
||||
parser_state
|
||||
.instantiate_template(doc_params, template, layout, root, params)?;
|
||||
let overlay_button = parser_state
|
||||
|
||||
@@ -147,6 +147,7 @@ impl ScreenPipeline {
|
||||
|
||||
/// Select normalized rect from backing image
|
||||
pub fn set_source_uv(&mut self, source_uv: [f32; 4]) {
|
||||
#[allow(clippy::float_cmp)]
|
||||
if self.source_uv != source_uv {
|
||||
self.source_uv = source_uv;
|
||||
self.pass.clear();
|
||||
|
||||
@@ -661,6 +661,7 @@ impl OverlayBackend for WvrWindowBackend {
|
||||
let source_uv = surf.source_uv(states);
|
||||
let mut xdg_state = states.cached_state.get::<SurfaceCachedState>();
|
||||
let window_geometry = xdg_state.current().geometry;
|
||||
drop(xdg_state);
|
||||
Some((surf, surface_size, source_uv, window_geometry))
|
||||
})
|
||||
else {
|
||||
@@ -699,9 +700,9 @@ impl OverlayBackend for WvrWindowBackend {
|
||||
}
|
||||
|
||||
let inner_extent = meta.extent;
|
||||
let committed_window_extent = window_geometry
|
||||
.map(|geometry| [geometry.size.w.max(1) as u32, geometry.size.h.max(1) as u32])
|
||||
.unwrap_or(inner_extent);
|
||||
let committed_window_extent = window_geometry.map_or(inner_extent, |geometry| {
|
||||
[geometry.size.w.max(1) as u32, geometry.size.h.max(1) as u32]
|
||||
});
|
||||
self.sync_committed_toplevel_size(app, committed_window_extent);
|
||||
|
||||
if self.server_side_decorations {
|
||||
|
||||
@@ -459,7 +459,7 @@ where
|
||||
.overlays
|
||||
.get(id)
|
||||
.and_then(|overlay| overlay.config.lifetime.as_ref())
|
||||
.is_some_and(|lifetime| lifetime.is_expired());
|
||||
.is_some_and(super::window::OverlayLifetime::is_expired);
|
||||
|
||||
if should_drop
|
||||
&& let Some(o) = self.remove_by_selector(&OverlaySelector::Id(id), app)
|
||||
@@ -796,10 +796,9 @@ impl<T> OverlayWindowManager<T> {
|
||||
for o in self.overlays.values() {
|
||||
if o.config.global
|
||||
&& let Some(state) = &o.config.active_state
|
||||
&& o.config.can_persist()
|
||||
{
|
||||
if o.config.can_persist() {
|
||||
global_overlays.insert(o.config.name.clone(), state.clone());
|
||||
}
|
||||
global_overlays.insert(o.config.name.clone(), state.clone());
|
||||
}
|
||||
}
|
||||
let global_hidden: HashMap<_, _> = self
|
||||
@@ -1302,13 +1301,12 @@ impl<T> OverlayWindowManager<T> {
|
||||
fallback_pid.filter(|candidate| *candidate != oid)
|
||||
}
|
||||
});
|
||||
if let Some(parent_id) = parent_id {
|
||||
if self
|
||||
if let Some(parent_id) = parent_id
|
||||
&& self
|
||||
.offset_spawn_from_parent(app, oid, &OverlaySelector::Id(parent_id))
|
||||
.is_some()
|
||||
{
|
||||
return;
|
||||
}
|
||||
{
|
||||
return;
|
||||
}
|
||||
if let Some(parent_id) = self.spread_parent_for(oid) {
|
||||
let _ =
|
||||
|
||||
@@ -140,7 +140,7 @@ pub struct OverlayWindowConfig {
|
||||
}
|
||||
|
||||
impl OverlayWindowConfig {
|
||||
pub fn can_persist(&self) -> bool {
|
||||
pub const fn can_persist(&self) -> bool {
|
||||
self.persistent
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -218,7 +218,7 @@ impl WGfx {
|
||||
|
||||
/// Submit a non-blocking completion marker to the queue
|
||||
///
|
||||
/// It uses an ALL_COMMANDS to ALL_COMMANDS barrier, so its fence doesn't
|
||||
/// It uses an `ALL_COMMANDS` to `ALL_COMMANDS` barrier, so its fence doesn't
|
||||
/// complete until all earlier work is finished.
|
||||
pub fn submit_graphics_completion_marker(&self) -> anyhow::Result<GpuCompletionMarker> {
|
||||
Ok(GpuCompletionMarker {
|
||||
|
||||
Reference in new issue
Block a user