feat: toggle to show by default

This commit is contained in:
galister
2024-07-11 16:59:57 +09:00
parent bdc500973c
commit a991c6b84a
4 changed files with 12 additions and 8 deletions

View File

@@ -60,7 +60,7 @@ impl<T> OverlayContainer<T>
where where
T: Default, T: Default,
{ {
pub fn new(app: &mut AppState) -> anyhow::Result<Self> { pub fn new(app: &mut AppState, show_by_default: bool) -> anyhow::Result<Self> {
let mut overlays = IdMap::new(); let mut overlays = IdMap::new();
let mut wl = create_wl_client(); let mut wl = create_wl_client();
@@ -95,7 +95,7 @@ where
for (meta, mut state, backend) in data.screens { for (meta, mut state, backend) in data.screens {
if show_screens.arc_get(state.name.as_ref()) { if show_screens.arc_get(state.name.as_ref()) {
state.show_hide = true; state.show_hide = true;
state.want_visible = false; state.want_visible = show_by_default;
} }
overlays.insert( overlays.insert(
state.id, state.id,

View File

@@ -61,7 +61,7 @@ pub fn openvr_uninstall() {
let _ = uninstall_manifest(&mut app_mgr); let _ = uninstall_manifest(&mut app_mgr);
} }
pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> { pub fn openvr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(), BackendError> {
let app_type = EVRApplicationType::VRApplication_Overlay; let app_type = EVRApplicationType::VRApplication_Overlay;
let Ok(context) = ovr_overlay::Context::init(app_type) else { let Ok(context) = ovr_overlay::Context::init(app_type) else {
log::warn!("Will not use OpenVR: Context init failed"); log::warn!("Will not use OpenVR: Context init failed");
@@ -105,7 +105,7 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
let _ = install_manifest(&mut app_mgr); let _ = install_manifest(&mut app_mgr);
let mut overlays = OverlayContainer::<OpenVrOverlayData>::new(&mut state)?; let mut overlays = OverlayContainer::<OpenVrOverlayData>::new(&mut state, show_by_default)?;
let mut notifications = NotificationManager::new(); let mut notifications = NotificationManager::new();
notifications.run_dbus(); notifications.run_dbus();
notifications.run_udp(); notifications.run_udp();

View File

@@ -48,7 +48,7 @@ struct XrState {
stage_offset: Affine3A, stage_offset: Affine3A,
} }
pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> { pub fn openxr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(), BackendError> {
let (xr_instance, system) = match helpers::init_xr() { let (xr_instance, system) = match helpers::init_xr() {
Ok((xr_instance, system)) => (xr_instance, system), Ok((xr_instance, system)) => (xr_instance, system),
Err(e) => { Err(e) => {
@@ -66,7 +66,7 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
AppState::from_graphics(graphics)? AppState::from_graphics(graphics)?
}; };
let mut overlays = OverlayContainer::<OpenXrOverlayData>::new(&mut app_state)?; let mut overlays = OverlayContainer::<OpenXrOverlayData>::new(&mut app_state, show_by_default)?;
let mut lines = LinePool::new(app_state.graphics.clone())?; let mut lines = LinePool::new(app_state.graphics.clone())?;
let mut notifications = NotificationManager::new(); let mut notifications = NotificationManager::new();

View File

@@ -34,6 +34,10 @@ struct Args {
#[arg(long)] #[arg(long)]
openxr: bool, openxr: bool,
/// Show the working set of overlay on startup
#[arg(long)]
show: bool,
/// Uninstall OpenVR manifest and exit /// Uninstall OpenVR manifest and exit
#[arg(long)] #[arg(long)]
uninstall: bool, uninstall: bool,
@@ -109,7 +113,7 @@ fn auto_run(running: Arc<AtomicBool>, args: Args) {
#[cfg(feature = "openxr")] #[cfg(feature = "openxr")]
if !args_get_openvr(&args) { if !args_get_openvr(&args) {
use crate::backend::openxr::openxr_run; use crate::backend::openxr::openxr_run;
match openxr_run(running.clone()) { match openxr_run(running.clone(), args.show) {
Ok(()) => return, Ok(()) => return,
Err(BackendError::NotSupported) => (), Err(BackendError::NotSupported) => (),
Err(e) => { Err(e) => {
@@ -122,7 +126,7 @@ fn auto_run(running: Arc<AtomicBool>, args: Args) {
#[cfg(feature = "openvr")] #[cfg(feature = "openvr")]
if !args_get_openxr(&args) { if !args_get_openxr(&args) {
use crate::backend::openvr::openvr_run; use crate::backend::openvr::openvr_run;
match openvr_run(running.clone()) { match openvr_run(running.clone(), args.show) {
Ok(()) => return, Ok(()) => return,
Err(BackendError::NotSupported) => (), Err(BackendError::NotSupported) => (),
Err(e) => { Err(e) => {