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

@@ -256,7 +256,7 @@ impl Layout {
if self.tree.dirty(self.root_node)? || self.prev_size != size { if self.tree.dirty(self.root_node)? || self.prev_size != size {
self.needs_redraw = true; self.needs_redraw = true;
println!("re-computing layout, size {}x{}", size.x, size.y); log::debug!("re-computing layout, size {}x{}", size.x, size.y);
self.prev_size = size; self.prev_size = size;
self.tree.compute_layout_with_measure( self.tree.compute_layout_with_measure(
self.root_node, self.root_node,
@@ -316,4 +316,4 @@ impl Layout {
}; };
widget.lock().unwrap().add_event_listener(listener); widget.lock().unwrap().add_event_listener(listener);
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,7 +5,7 @@ use std::{
time::Instant, time::Instant,
}; };
use glam::{vec3a, Quat}; use glam::{Quat, vec3a};
use idmap_derive::IntegerId; use idmap_derive::IntegerId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use wgui::{ use wgui::{
@@ -232,7 +232,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<(OverlayState, Box<dyn
let state = OverlayState { let state = OverlayState {
name: TOAST_NAME.clone(), name: TOAST_NAME.clone(),
want_visible: true, 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_rotation,
spawn_point, spawn_point,
z_order: Z_ORDER_TOAST, z_order: Z_ORDER_TOAST,