settings implementation
This commit is contained in:
@@ -23,11 +23,11 @@ pub const fn def_pw_tokens() -> PwTokenMap {
|
||||
AStrMap::new()
|
||||
}
|
||||
|
||||
const fn def_mouse_move_interval_ms() -> u32 {
|
||||
const fn def_mouse_move_interval_ms() -> i32 {
|
||||
10 // 100fps
|
||||
}
|
||||
|
||||
const fn def_click_freeze_time_ms() -> u32 {
|
||||
const fn def_click_freeze_time_ms() -> i32 {
|
||||
300
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ pub struct GeneralConfig {
|
||||
pub attribs: AStrMap<Vec<BackendAttribValue>>,
|
||||
|
||||
#[serde(default = "def_click_freeze_time_ms")]
|
||||
pub click_freeze_time_ms: u32,
|
||||
pub click_freeze_time_ms: i32,
|
||||
|
||||
#[serde(default = "def_false")]
|
||||
pub invert_scroll_direction_x: bool,
|
||||
@@ -125,7 +125,7 @@ pub struct GeneralConfig {
|
||||
pub long_press_duration: f32,
|
||||
|
||||
#[serde(default = "def_mouse_move_interval_ms")]
|
||||
pub mouse_move_interval_ms: u32,
|
||||
pub mouse_move_interval_ms: i32,
|
||||
|
||||
#[serde(default = "def_true")]
|
||||
pub notifications_enabled: bool,
|
||||
@@ -240,4 +240,13 @@ pub struct GeneralConfig {
|
||||
|
||||
#[serde(default)]
|
||||
pub last_set: u32,
|
||||
|
||||
#[serde(default)]
|
||||
pub hide_username: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub opaque_background: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub xwayland_by_default: bool,
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use wayvr_ipc::{
|
||||
packet_server::{WvrProcess, WvrProcessHandle, WvrWindow, WvrWindowHandle},
|
||||
};
|
||||
|
||||
use crate::desktop_finder::DesktopFinder;
|
||||
use crate::{config::GeneralConfig, desktop_finder::DesktopFinder};
|
||||
|
||||
pub trait DashInterface<T> {
|
||||
fn window_list(&mut self, data: &mut T) -> anyhow::Result<Vec<WvrWindow>>;
|
||||
@@ -15,6 +15,7 @@ pub trait DashInterface<T> {
|
||||
fn process_terminate(&mut self, data: &mut T, handle: WvrProcessHandle) -> anyhow::Result<()>;
|
||||
fn recenter_playspace(&mut self, data: &mut T) -> 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;
|
||||
}
|
||||
|
||||
pub type BoxDashInterface<T> = Box<dyn DashInterface<T>>;
|
||||
|
||||
@@ -3,7 +3,7 @@ use wayvr_ipc::{
|
||||
packet_server::{WvrProcess, WvrProcessHandle, WvrWindow, WvrWindowHandle},
|
||||
};
|
||||
|
||||
use crate::{dash_interface::DashInterface, desktop_finder::DesktopFinder, gen_id};
|
||||
use crate::{config::GeneralConfig, dash_interface::DashInterface, desktop_finder::DesktopFinder, gen_id};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EmuProcess {
|
||||
@@ -55,6 +55,7 @@ pub struct DashInterfaceEmulated {
|
||||
processes: EmuProcessVec,
|
||||
windows: EmuWindowVec,
|
||||
desktop_finder: DesktopFinder,
|
||||
general_config: GeneralConfig,
|
||||
}
|
||||
|
||||
impl DashInterfaceEmulated {
|
||||
@@ -73,10 +74,14 @@ impl DashInterfaceEmulated {
|
||||
let mut desktop_finder = DesktopFinder::new();
|
||||
desktop_finder.refresh();
|
||||
|
||||
// Use serde defaults
|
||||
let general_config = serde_json::from_str("{}").unwrap();
|
||||
|
||||
Self {
|
||||
processes,
|
||||
windows,
|
||||
desktop_finder,
|
||||
general_config,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,4 +174,8 @@ impl DashInterface<()> for DashInterfaceEmulated {
|
||||
fn desktop_finder<'a>(&'a mut self, _: &'a mut ()) -> &'a mut DesktopFinder {
|
||||
&mut self.desktop_finder
|
||||
}
|
||||
|
||||
fn general_config<'a>(&'a mut self, _: &'a mut ()) -> &'a mut crate::config::GeneralConfig {
|
||||
&mut self.general_config
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user