From 6960652379028f1389ca1eb7db1f1cc7df77d822 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Sun, 25 Jan 2026 11:44:17 +0900 Subject: [PATCH] reset playspace button in settings --- dash-frontend/assets/lang/en.json | 2 ++ dash-frontend/src/frontend.rs | 6 +++--- dash-frontend/src/tab/settings.rs | 14 +++++++++++++- wayvr/src/overlays/dashboard.rs | 12 ++++++++---- wlx-common/src/dash_interface.rs | 9 ++++++++- wlx-common/src/dash_interface_emulated.rs | 4 ++-- 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/dash-frontend/assets/lang/en.json b/dash-frontend/assets/lang/en.json index c5c98d4..ae16a05 100644 --- a/dash-frontend/assets/lang/en.json +++ b/dash-frontend/assets/lang/en.json @@ -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", diff --git a/dash-frontend/src/frontend.rs b/dash-frontend/src/frontend.rs index 6fb6625..ffa9b94 100644 --- a/dash-frontend/src/frontend.rs +++ b/dash-frontend/src/frontend.rs @@ -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 Frontend { } fn action_recenter_playspace(&mut self, data: &mut T) -> anyhow::Result<()> { - self.interface.recenter_playspace(data)?; + self.interface.recenter_playspace(data, RecenterMode::Recenter)?; Ok(()) } diff --git a/dash-frontend/src/tab/settings.rs b/dash-frontend/src/tab/settings.rs index 3fe7dac..5266b4d 100644 --- a/dash-frontend/src/tab/settings.rs +++ b/dash-frontend/src/tab/settings.rs @@ -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), SetTab(TabNameEnum), @@ -127,6 +128,10 @@ impl Tab for TabSettings { 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 TabSettings { } 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, diff --git a/wayvr/src/overlays/dashboard.rs b/wayvr/src/overlays/dashboard.rs index 7f37804..6b040ee 100644 --- a/wayvr/src/overlays/dashboard.rs +++ b/wayvr/src/overlays/dashboard.rs @@ -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 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(()) } diff --git a/wlx-common/src/dash_interface.rs b/wlx-common/src/dash_interface.rs index 2d2266d..821ab1e 100644 --- a/wlx-common/src/dash_interface.rs +++ b/wlx-common/src/dash_interface.rs @@ -16,6 +16,13 @@ pub struct MonadoClient { pub is_io_active: bool, } +#[derive(Clone, Copy)] +pub enum RecenterMode { + FixFloor, + Recenter, + Reset, +} + pub trait DashInterface { fn window_list(&mut self, data: &mut T) -> anyhow::Result>; fn window_set_visible(&mut self, data: &mut T, handle: WvrWindowHandle, visible: bool) -> anyhow::Result<()>; @@ -33,7 +40,7 @@ pub trait DashInterface { fn monado_client_focus(&mut self, data: &mut T, name: &str) -> anyhow::Result<()>; fn monado_brightness_get(&mut self, data: &mut T) -> 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 general_config<'a>(&'a mut self, data: &'a mut T) -> &'a mut GeneralConfig; fn config_changed(&mut self, data: &mut T); diff --git a/wlx-common/src/dash_interface_emulated.rs b/wlx-common/src/dash_interface_emulated.rs index 9e76e64..017e7bf 100644 --- a/wlx-common/src/dash_interface_emulated.rs +++ b/wlx-common/src/dash_interface_emulated.rs @@ -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(()) }