This commit is contained in:
galister
2025-06-18 19:42:05 +09:00
parent 467b0cc33d
commit a14c22568c
9 changed files with 40 additions and 50 deletions

View File

@@ -7,8 +7,9 @@ use dbus::{
use serde::Deserialize;
use std::{
sync::{
Arc,
atomic::{AtomicBool, Ordering},
mpsc, Arc,
mpsc,
},
time::Duration,
};
@@ -172,7 +173,7 @@ impl NotificationManager {
let toast = Toast::new(
ToastTopic::XSNotification,
msg.title,
msg.content.unwrap_or_else(|| "".into()),
msg.content.unwrap_or(String::new()),
)
.with_timeout(msg.timeout.unwrap_or(5.))
.with_sound(msg.volume.unwrap_or(-1.) >= 0.); // XSOverlay still plays at 0,
@@ -264,11 +265,9 @@ fn parse_dbus(msg: &dbus::Message) -> anyhow::Result<Toast> {
summary
};
Ok(
Toast::new(ToastTopic::DesktopNotification, title.into(), body.into())
.with_timeout(5.0)
.with_opacity(1.0),
)
Ok(Toast::new(ToastTopic::DesktopNotification, title, body)
.with_timeout(5.0)
.with_opacity(1.0))
// leave the audio part to the desktop env
}

View File

@@ -2,18 +2,18 @@ use std::{
collections::VecDeque,
ops::Add,
sync::{
atomic::{AtomicBool, AtomicUsize, Ordering},
Arc,
atomic::{AtomicBool, AtomicUsize, Ordering},
},
time::{Duration, Instant},
};
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use ovr_overlay::{
sys::{ETrackedDeviceProperty, EVRApplicationType, EVREventType},
TrackedDeviceIndex,
sys::{ETrackedDeviceProperty, EVRApplicationType, EVREventType},
};
use vulkano::{device::physical::PhysicalDevice, Handle, VulkanObject};
use vulkano::{Handle, VulkanObject, device::physical::PhysicalDevice};
use crate::{
backend::{
@@ -22,7 +22,7 @@ use crate::{
notifications::NotificationManager,
openvr::{
helpers::adjust_gain,
input::{set_action_manifest, OpenVrInputSource},
input::{OpenVrInputSource, set_action_manifest},
lines::LinePool,
manifest::{install_manifest, uninstall_manifest},
overlay::OpenVrOverlayData,
@@ -30,10 +30,10 @@ use crate::{
overlay::{OverlayData, ShouldRender},
task::{SystemTask, TaskType},
},
graphics::{init_openvr_graphics, CommandBuffers},
graphics::{CommandBuffers, init_openvr_graphics},
overlays::{
toast::{Toast, ToastTopic},
watch::{watch_fade, WATCH_NAME},
watch::{WATCH_NAME, watch_fade},
},
state::AppState,
};
@@ -185,12 +185,8 @@ pub fn openvr_run(
let ipd = (ipd * 10000.0).round() * 0.1;
if (ipd - state.input_state.ipd).abs() > 0.05 {
log::info!("IPD: {:.1} mm -> {:.1} mm", state.input_state.ipd, ipd);
Toast::new(
ToastTopic::IpdChange,
"IPD".into(),
format!("{ipd:.1} mm").into(),
)
.submit(&mut state);
Toast::new(ToastTopic::IpdChange, "IPD".into(), format!("{ipd:.1} mm"))
.submit(&mut state);
}
state.input_state.ipd = ipd;
}

View File

@@ -330,12 +330,8 @@ pub fn openxr_run(
if (app.input_state.ipd - ipd).abs() > 0.01 {
log::info!("IPD changed: {} -> {}", app.input_state.ipd, ipd);
app.input_state.ipd = ipd;
Toast::new(
ToastTopic::IpdChange,
"IPD".into(),
format!("{ipd:.1} mm").into(),
)
.submit(&mut app);
Toast::new(ToastTopic::IpdChange, "IPD".into(), format!("{ipd:.1} mm"))
.submit(&mut app);
}
overlays

View File

@@ -1,9 +1,9 @@
use crate::state::AppState;
use super::{display, process, window, TickTask, WayVRSignal};
use super::{TickTask, WayVRSignal, display, process, window};
use bytes::BufMut;
use glam::Vec3A;
use interprocess::local_socket::{self, traits::Listener, ToNsName};
use interprocess::local_socket::{self, ToNsName, traits::Listener};
use smallvec::SmallVec;
use std::io::{Read, Write};
use wayvr_ipc::{
@@ -81,11 +81,10 @@ pub fn gen_args_vec(input: &str) -> Vec<&str> {
}
pub fn gen_env_vec(input: &[String]) -> Vec<(&str, &str)> {
let res = input
input
.iter()
.filter_map(|e| e.as_str().split_once('='))
.collect();
res
.collect()
}
impl Connection {

View File

@@ -23,18 +23,18 @@ pub struct GuiPanel {
pub layout: Layout,
context: WguiContext,
timestep: Timestep,
pub width: u32,
pub height: u32,
pub max_width: u32,
pub max_height: u32,
}
impl GuiPanel {
pub fn new_from_template(
app: &AppState,
width: u32,
height: u32,
max_width: u32,
max_height: u32,
path: &str,
) -> anyhow::Result<Self> {
let mut me = Self::new_blank(app, width, height)?;
let mut me = Self::new_blank(app, max_width, max_height)?;
let parent = me.layout.root_widget;
let _res = wgui::parser::parse_from_assets(&mut me.layout, parent, path)?;
@@ -42,7 +42,7 @@ impl GuiPanel {
Ok(me)
}
pub fn new_blank(app: &AppState, width: u32, height: u32) -> anyhow::Result<Self> {
pub fn new_blank(app: &AppState, max_width: u32, max_height: u32) -> anyhow::Result<Self> {
let layout = Layout::new(Box::new(GuiAsset {}))?;
let context = WguiContext::new(app.gfx.clone(), app.gfx.surface_format, 1.0)?;
let mut timestep = Timestep::new();
@@ -52,8 +52,8 @@ impl GuiPanel {
layout,
context,
timestep,
width,
height,
max_width,
max_height,
})
}
}
@@ -74,7 +74,7 @@ impl InteractionHandler for GuiPanel {
shift: vec2(delta_x, delta_y),
pos: hit.uv,
}))
.unwrap()
.unwrap();
}
fn on_hover(&mut self, _app: &mut AppState, hit: &PointerHit) -> Option<Haptics> {
@@ -154,7 +154,7 @@ impl OverlayRenderer for GuiPanel {
fn frame_meta(&mut self) -> Option<FrameMeta> {
Some(FrameMeta {
extent: [self.width, self.height, 1],
extent: [self.max_width, self.max_height, 1],
..Default::default()
})
}

View File

@@ -18,8 +18,8 @@ pub struct Timestep {
}
impl Timestep {
pub fn new() -> Timestep {
let mut timestep = Timestep {
pub fn new() -> Self {
let mut timestep = Self {
speed: 1.0,
..Default::default()
};

View File

@@ -29,8 +29,8 @@ mod config_wayvr;
use std::{
path::PathBuf,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
atomic::{AtomicBool, Ordering},
},
};
@@ -38,7 +38,7 @@ use backend::notifications::DbusNotificationSender;
use clap::Parser;
use sysinfo::Pid;
use tracing::level_filters::LevelFilter;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};
/// The lightweight desktop overlay for OpenVR and OpenXR
#[derive(Default, Parser, Debug)]
@@ -126,7 +126,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
#[allow(unused_mut)]
#[allow(unused_mut, clippy::similar_names)]
fn auto_run(running: Arc<AtomicBool>, args: Args) {
use backend::common::BackendError;

View File

@@ -5,7 +5,7 @@ use std::{
time::Instant,
};
use glam::{vec3a, Quat};
use glam::{Quat, vec3a};
use idmap_derive::IntegerId;
use serde::{Deserialize, Serialize};
use wgui::{
@@ -232,7 +232,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<(OverlayState, Box<dyn
let state = OverlayState {
name: TOAST_NAME.clone(),
want_visible: true,
spawn_scale: (panel.width as f32) * PIXELS_TO_METERS,
spawn_scale: (panel.max_width as f32) * PIXELS_TO_METERS,
spawn_rotation,
spawn_point,
z_order: Z_ORDER_TOAST,