reset playspace button in settings

This commit is contained in:
galister
2026-01-25 11:44:17 +09:00
parent 3ec1dd7f4e
commit 6960652379
6 changed files with 36 additions and 11 deletions

View File

@@ -83,6 +83,8 @@
"SCREENCOPY_HELP": "Slow, no screen share popups.\nWorks on: Hyprland, Niri, River, Sway" "SCREENCOPY_HELP": "Slow, no screen share popups.\nWorks on: Hyprland, Niri, River, Sway"
}, },
"POINTER_LERP_FACTOR": "Pointer smoothing", "POINTER_LERP_FACTOR": "Pointer smoothing",
"RESET_PLAYSPACE": "Reset playspace",
"RESET_PLAYSPACE_HELP": "Clear the stage space offset.",
"RESTART_SOFTWARE": "Restart software", "RESTART_SOFTWARE": "Restart software",
"RESTART_SOFTWARE_HELP": "Apply settings that require a restart", "RESTART_SOFTWARE_HELP": "Apply settings that require a restart",
"ROUND_MULTIPLIER": "UI Edge roundness", "ROUND_MULTIPLIER": "UI Edge roundness",

View File

@@ -16,13 +16,13 @@ use wgui::{
}; };
use wlx_common::{ use wlx_common::{
audio, audio,
dash_interface::BoxDashInterface, dash_interface::{BoxDashInterface, RecenterMode},
timestep::{self, Timestep}, timestep::{self, Timestep},
}; };
use crate::{ use crate::{
assets, assets,
tab::{Tab, TabType, apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, settings::TabSettings}, tab::{apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, settings::TabSettings, Tab, TabType},
util::{ util::{
popup_manager::{MountPopupParams, PopupManager, PopupManagerParams}, popup_manager::{MountPopupParams, PopupManager, PopupManagerParams},
toast_manager::ToastManager, toast_manager::ToastManager,
@@ -490,7 +490,7 @@ impl<T: 'static> Frontend<T> {
} }
fn action_recenter_playspace(&mut self, data: &mut T) -> anyhow::Result<()> { fn action_recenter_playspace(&mut self, data: &mut T) -> anyhow::Result<()> {
self.interface.recenter_playspace(data)?; self.interface.recenter_playspace(data, RecenterMode::Recenter)?;
Ok(()) Ok(())
} }

View File

@@ -20,7 +20,7 @@ use wgui::{
widget::label::WidgetLabel, widget::label::WidgetLabel,
windowing::context_menu::{self, Blueprint, ContextMenu, TickResult}, windowing::context_menu::{self, Blueprint, ContextMenu, TickResult},
}; };
use wlx_common::{config::GeneralConfig, config_io::ConfigRoot}; use wlx_common::{config::GeneralConfig, config_io::ConfigRoot, dash_interface::RecenterMode};
use crate::{ use crate::{
frontend::{Frontend, FrontendTask}, frontend::{Frontend, FrontendTask},
@@ -60,6 +60,7 @@ enum Task {
ClearPipewireTokens, ClearPipewireTokens,
ClearSavedState, ClearSavedState,
DeleteAllConfigs, DeleteAllConfigs,
ResetPlayspace,
RestartSoftware, RestartSoftware,
RemoveAutostartApp(Rc<str>), RemoveAutostartApp(Rc<str>),
SetTab(TabNameEnum), SetTab(TabNameEnum),
@@ -127,6 +128,10 @@ impl<T> Tab<T> for TabSettings<T> {
std::fs::remove_dir_all(&path)?; std::fs::remove_dir_all(&path)?;
std::fs::create_dir(&path)?; std::fs::create_dir(&path)?;
} }
Task::ResetPlayspace => {
frontend.interface.recenter_playspace(data, RecenterMode::Reset)?;
return Ok(());
}
Task::RestartSoftware => { Task::RestartSoftware => {
frontend.interface.restart(data); frontend.interface.restart(data);
return Ok(()); return Ok(());
@@ -774,6 +779,13 @@ impl<T> TabSettings<T> {
} }
TabNameEnum::Troubleshooting => { TabNameEnum::Troubleshooting => {
let c = category!(mp, root, "APP_SETTINGS.TROUBLESHOOTING", "dashboard/cpu.svg")?; let c = category!(mp, root, "APP_SETTINGS.TROUBLESHOOTING", "dashboard/cpu.svg")?;
danger_button!(
mp,
c,
"APP_SETTINGS.RESET_PLAYSPACE",
"dashboard/recenter.svg",
Task::ResetPlayspace
);
danger_button!( danger_button!(
mp, mp,
c, c,

View File

@@ -16,7 +16,7 @@ use wgui::{
widget::EventResult, widget::EventResult,
}; };
use wlx_common::{ use wlx_common::{
dash_interface::{self, DashInterface}, dash_interface::{self, DashInterface, RecenterMode},
overlays::{BackendAttrib, BackendAttribValue}, overlays::{BackendAttrib, BackendAttribValue},
}; };
use wlx_common::{ use wlx_common::{
@@ -416,9 +416,13 @@ impl DashInterface<AppState> for DashInterfaceLive {
Ok(()) Ok(())
} }
fn recenter_playspace(&mut self, app: &mut AppState) -> anyhow::Result<()> { fn recenter_playspace(&mut self, app: &mut AppState, mode: RecenterMode) -> anyhow::Result<()> {
app.tasks let task = match mode {
.enqueue(TaskType::Playspace(PlayspaceTask::Recenter)); RecenterMode::FixFloor => PlayspaceTask::FixFloor,
RecenterMode::Recenter => PlayspaceTask::Recenter,
RecenterMode::Reset => PlayspaceTask::Reset,
};
app.tasks.enqueue(TaskType::Playspace(task));
Ok(()) Ok(())
} }

View File

@@ -16,6 +16,13 @@ pub struct MonadoClient {
pub is_io_active: bool, pub is_io_active: bool,
} }
#[derive(Clone, Copy)]
pub enum RecenterMode {
FixFloor,
Recenter,
Reset,
}
pub trait DashInterface<T> { pub trait DashInterface<T> {
fn window_list(&mut self, data: &mut T) -> anyhow::Result<Vec<WvrWindow>>; fn window_list(&mut self, data: &mut T) -> anyhow::Result<Vec<WvrWindow>>;
fn window_set_visible(&mut self, data: &mut T, handle: WvrWindowHandle, visible: bool) -> anyhow::Result<()>; fn window_set_visible(&mut self, data: &mut T, handle: WvrWindowHandle, visible: bool) -> anyhow::Result<()>;
@@ -33,7 +40,7 @@ pub trait DashInterface<T> {
fn monado_client_focus(&mut self, data: &mut T, name: &str) -> anyhow::Result<()>; fn monado_client_focus(&mut self, data: &mut T, name: &str) -> anyhow::Result<()>;
fn monado_brightness_get(&mut self, data: &mut T) -> Option<f32>; fn monado_brightness_get(&mut self, data: &mut T) -> Option<f32>;
fn monado_brightness_set(&mut self, data: &mut T, brightness: f32) -> Option<()>; fn monado_brightness_set(&mut self, data: &mut T, brightness: f32) -> Option<()>;
fn recenter_playspace(&mut self, data: &mut T) -> anyhow::Result<()>; fn recenter_playspace(&mut self, data: &mut T, mode: RecenterMode) -> anyhow::Result<()>;
fn desktop_finder<'a>(&'a mut self, data: &'a mut T) -> &'a mut DesktopFinder; fn desktop_finder<'a>(&'a mut self, data: &'a mut T) -> &'a mut DesktopFinder;
fn general_config<'a>(&'a mut self, data: &'a mut T) -> &'a mut GeneralConfig; fn general_config<'a>(&'a mut self, data: &'a mut T) -> &'a mut GeneralConfig;
fn config_changed(&mut self, data: &mut T); fn config_changed(&mut self, data: &mut T);

View File

@@ -5,7 +5,7 @@ use wayvr_ipc::{
use crate::{ use crate::{
config::GeneralConfig, config::GeneralConfig,
dash_interface::{self, DashInterface}, dash_interface::{self, DashInterface, RecenterMode},
desktop_finder::DesktopFinder, desktop_finder::DesktopFinder,
gen_id, gen_id,
}; };
@@ -210,7 +210,7 @@ impl DashInterface<()> for DashInterfaceEmulated {
} }
} }
fn recenter_playspace(&mut self, _: &mut ()) -> anyhow::Result<()> { fn recenter_playspace(&mut self, _: &mut (), _: RecenterMode) -> anyhow::Result<()> {
// stub! // stub!
Ok(()) Ok(())
} }