feat: toast topics
This commit is contained in:
@@ -9,7 +9,12 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crate::{config::def_true, config_io, overlays::toast::Toast, state::AppState};
|
||||
use crate::{
|
||||
config::def_true,
|
||||
config_io,
|
||||
overlays::toast::{Toast, ToastTopic},
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
pub struct NotificationManager {
|
||||
rx_toast: mpsc::Receiver<Toast>,
|
||||
@@ -167,9 +172,13 @@ impl NotificationManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
let toast = Toast::new(msg.title, msg.content.unwrap_or_else(|| "".into()))
|
||||
.with_timeout(msg.timeout.unwrap_or(5.))
|
||||
.with_sound(msg.volume.unwrap_or(-1.) >= 0.); // XSOverlay still plays at 0,
|
||||
let toast = Toast::new(
|
||||
ToastTopic::XSNotification,
|
||||
msg.title,
|
||||
msg.content.unwrap_or_else(|| "".into()),
|
||||
)
|
||||
.with_timeout(msg.timeout.unwrap_or(5.))
|
||||
.with_sound(msg.volume.unwrap_or(-1.) >= 0.); // XSOverlay still plays at 0,
|
||||
|
||||
match sender.try_send(toast) {
|
||||
Ok(_) => {}
|
||||
@@ -204,9 +213,11 @@ fn parse_dbus(msg: &dbus::Message) -> anyhow::Result<Toast> {
|
||||
summary
|
||||
};
|
||||
|
||||
Ok(Toast::new(title.into(), body.into())
|
||||
.with_timeout(5.0)
|
||||
.with_opacity(1.0))
|
||||
Ok(
|
||||
Toast::new(ToastTopic::DesktopNotification, title.into(), body.into())
|
||||
.with_timeout(5.0)
|
||||
.with_opacity(1.0),
|
||||
)
|
||||
// leave the audio part to the desktop env
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,10 @@ use crate::{
|
||||
overlay::OverlayData,
|
||||
},
|
||||
graphics::WlxGraphics,
|
||||
overlays::watch::{watch_fade, WATCH_NAME},
|
||||
overlays::{
|
||||
toast::{Toast, ToastTopic},
|
||||
watch::{watch_fade, WATCH_NAME},
|
||||
},
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
@@ -178,6 +181,12 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
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!("{:.1} mm", ipd).into(),
|
||||
)
|
||||
.submit(&mut state);
|
||||
}
|
||||
state.input_state.ipd = ipd;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,10 @@ use crate::{
|
||||
overlay::OverlayData,
|
||||
},
|
||||
graphics::WlxGraphics,
|
||||
overlays::watch::{watch_fade, WATCH_NAME},
|
||||
overlays::{
|
||||
toast::{Toast, ToastTopic},
|
||||
watch::{watch_fade, WATCH_NAME},
|
||||
},
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
@@ -220,8 +223,18 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
&xr_state.stage,
|
||||
)?;
|
||||
|
||||
(app_state.input_state.hmd, app_state.input_state.ipd) =
|
||||
helpers::hmd_pose_from_views(&views);
|
||||
let (hmd, ipd) = helpers::hmd_pose_from_views(&views);
|
||||
app_state.input_state.hmd = hmd;
|
||||
if (app_state.input_state.ipd - ipd).abs() > 0.01 {
|
||||
log::info!("IPD changed: {} -> {}", app_state.input_state.ipd, ipd);
|
||||
app_state.input_state.ipd = ipd;
|
||||
Toast::new(
|
||||
ToastTopic::IpdChange,
|
||||
"IPD".into(),
|
||||
format!("{:.1} mm", ipd).into(),
|
||||
)
|
||||
.submit(&mut app_state);
|
||||
}
|
||||
|
||||
overlays
|
||||
.iter_mut()
|
||||
|
||||
Reference in New Issue
Block a user