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"
},
"POINTER_LERP_FACTOR": "Pointer smoothing",
"RESET_PLAYSPACE": "Reset playspace",
"RESET_PLAYSPACE_HELP": "Clear the stage space offset.",
"RESTART_SOFTWARE": "Restart software",
"RESTART_SOFTWARE_HELP": "Apply settings that require a restart",
"ROUND_MULTIPLIER": "UI Edge roundness",

View File

@@ -16,13 +16,13 @@ use wgui::{
};
use wlx_common::{
audio,
dash_interface::BoxDashInterface,
dash_interface::{BoxDashInterface, RecenterMode},
timestep::{self, Timestep},
};
use crate::{
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::{
popup_manager::{MountPopupParams, PopupManager, PopupManagerParams},
toast_manager::ToastManager,
@@ -490,7 +490,7 @@ impl<T: 'static> Frontend<T> {
}
fn action_recenter_playspace(&mut self, data: &mut T) -> anyhow::Result<()> {
self.interface.recenter_playspace(data)?;
self.interface.recenter_playspace(data, RecenterMode::Recenter)?;
Ok(())
}

View File

@@ -20,7 +20,7 @@ use wgui::{
widget::label::WidgetLabel,
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::{
frontend::{Frontend, FrontendTask},
@@ -60,6 +60,7 @@ enum Task {
ClearPipewireTokens,
ClearSavedState,
DeleteAllConfigs,
ResetPlayspace,
RestartSoftware,
RemoveAutostartApp(Rc<str>),
SetTab(TabNameEnum),
@@ -127,6 +128,10 @@ impl<T> Tab<T> for TabSettings<T> {
std::fs::remove_dir_all(&path)?;
std::fs::create_dir(&path)?;
}
Task::ResetPlayspace => {
frontend.interface.recenter_playspace(data, RecenterMode::Reset)?;
return Ok(());
}
Task::RestartSoftware => {
frontend.interface.restart(data);
return Ok(());
@@ -774,6 +779,13 @@ impl<T> TabSettings<T> {
}
TabNameEnum::Troubleshooting => {
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!(
mp,
c,

View File

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

View File

@@ -16,6 +16,13 @@ pub struct MonadoClient {
pub is_io_active: bool,
}
#[derive(Clone, Copy)]
pub enum RecenterMode {
FixFloor,
Recenter,
Reset,
}
pub trait DashInterface<T> {
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<()>;
@@ -33,7 +40,7 @@ pub trait DashInterface<T> {
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_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 general_config<'a>(&'a mut self, data: &'a mut T) -> &'a mut GeneralConfig;
fn config_changed(&mut self, data: &mut T);

View File

@@ -5,7 +5,7 @@ use wayvr_ipc::{
use crate::{
config::GeneralConfig,
dash_interface::{self, DashInterface},
dash_interface::{self, DashInterface, RecenterMode},
desktop_finder::DesktopFinder,
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!
Ok(())
}