Monado app switcher, lang update
This commit is contained in:
@@ -5,6 +5,17 @@ use wayvr_ipc::{
|
||||
|
||||
use crate::{config::GeneralConfig, desktop_finder::DesktopFinder};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MonadoClient {
|
||||
pub name: String,
|
||||
pub is_primary: bool,
|
||||
pub is_active: bool,
|
||||
pub is_visible: bool,
|
||||
pub is_focused: bool,
|
||||
pub is_overlay: bool,
|
||||
pub is_io_active: bool,
|
||||
}
|
||||
|
||||
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<()>;
|
||||
@@ -18,6 +29,8 @@ pub trait DashInterface<T> {
|
||||
) -> anyhow::Result<WvrProcessHandle>;
|
||||
fn process_list(&mut self, data: &mut T) -> anyhow::Result<Vec<WvrProcess>>;
|
||||
fn process_terminate(&mut self, data: &mut T, handle: WvrProcessHandle) -> anyhow::Result<()>;
|
||||
fn monado_client_list(&mut self, data: &mut T) -> anyhow::Result<Vec<MonadoClient>>;
|
||||
fn monado_client_focus(&mut self, data: &mut T, name: &str) -> 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;
|
||||
|
||||
@@ -3,7 +3,12 @@ use wayvr_ipc::{
|
||||
packet_server::{WvrProcess, WvrProcessHandle, WvrWindow, WvrWindowHandle},
|
||||
};
|
||||
|
||||
use crate::{config::GeneralConfig, dash_interface::DashInterface, desktop_finder::DesktopFinder, gen_id};
|
||||
use crate::{
|
||||
config::GeneralConfig,
|
||||
dash_interface::{self, DashInterface},
|
||||
desktop_finder::DesktopFinder,
|
||||
gen_id,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EmuProcess {
|
||||
@@ -56,6 +61,7 @@ pub struct DashInterfaceEmulated {
|
||||
windows: EmuWindowVec,
|
||||
desktop_finder: DesktopFinder,
|
||||
general_config: GeneralConfig,
|
||||
monado_clients: Vec<dash_interface::MonadoClient>,
|
||||
}
|
||||
|
||||
impl DashInterfaceEmulated {
|
||||
@@ -77,11 +83,42 @@ impl DashInterfaceEmulated {
|
||||
// Use serde defaults
|
||||
let general_config = serde_json::from_str("{}").unwrap();
|
||||
|
||||
let monado_clients = vec![
|
||||
dash_interface::MonadoClient {
|
||||
name: String::from("The Best VR Game 3000"),
|
||||
is_active: true,
|
||||
is_focused: true,
|
||||
is_io_active: true,
|
||||
is_overlay: false,
|
||||
is_primary: true,
|
||||
is_visible: true,
|
||||
},
|
||||
dash_interface::MonadoClient {
|
||||
name: String::from("Second app"),
|
||||
is_active: true,
|
||||
is_focused: false,
|
||||
is_io_active: true,
|
||||
is_overlay: false,
|
||||
is_primary: false,
|
||||
is_visible: true,
|
||||
},
|
||||
dash_interface::MonadoClient {
|
||||
name: String::from("Third app"),
|
||||
is_active: true,
|
||||
is_focused: false,
|
||||
is_io_active: true,
|
||||
is_overlay: false,
|
||||
is_primary: false,
|
||||
is_visible: true,
|
||||
},
|
||||
];
|
||||
|
||||
Self {
|
||||
processes,
|
||||
windows,
|
||||
desktop_finder,
|
||||
general_config,
|
||||
monado_clients,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,4 +224,23 @@ impl DashInterface<()> for DashInterfaceEmulated {
|
||||
fn config_changed(&mut self, _: &mut ()) {}
|
||||
|
||||
fn restart(&mut self, _data: &mut ()) {}
|
||||
|
||||
fn monado_client_list(&mut self, _data: &mut ()) -> anyhow::Result<Vec<dash_interface::MonadoClient>> {
|
||||
Ok(self.monado_clients.clone())
|
||||
}
|
||||
|
||||
fn monado_client_focus(&mut self, _data: &mut (), name: &str) -> anyhow::Result<()> {
|
||||
for client in self.monado_clients.iter_mut() {
|
||||
client.is_focused = false;
|
||||
client.is_active = false;
|
||||
client.is_primary = false;
|
||||
}
|
||||
|
||||
if let Some(client) = self.monado_clients.iter_mut().find(|m| m.name == name) {
|
||||
client.is_active = true;
|
||||
client.is_focused = true;
|
||||
client.is_primary = true;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user