dash-interface: fetch client IDs, toggle filter

This commit is contained in:
Aleksander 2026-03-26 22:15:05 +01:00
parent e035fb9d27
commit 0a4fc34fac
5 changed files with 33 additions and 16 deletions

6
Cargo.lock generated
View File

@ -2795,12 +2795,6 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "lebe" name = "lebe"
version = "0.5.3" version = "0.5.3"

View File

@ -71,6 +71,7 @@ struct DebugGraph {
} }
struct DebugSessionList { struct DebugSessionList {
#[allow(dead_code)]
buttons: Vec<Rc<ComponentButton>>, buttons: Vec<Rc<ComponentButton>>,
#[allow(dead_code)] #[allow(dead_code)]
data_vec: Vec<ParserData>, data_vec: Vec<ParserData>,
@ -112,6 +113,7 @@ struct SubtabDebugTimings {
} }
#[allow(dead_code)] #[allow(dead_code)]
#[allow(clippy::large_enum_variant)]
enum Subtab { enum Subtab {
Empty, Empty,
GeneralSettings(SubtabGeneralSettings), GeneralSettings(SubtabGeneralSettings),
@ -196,7 +198,7 @@ impl<T> Tab<T> for TabMonado<T> {
} }
} }
Subtab::DebugTimings(timings) => { Subtab::DebugTimings(timings) => {
timings.update(&self.tasks, data, frontend); timings.update(&self.tasks, data, frontend)?;
} }
} }
@ -427,14 +429,14 @@ impl SubtabDebugTimings {
Ok(()) Ok(())
} }
fn update<T>(&mut self, tasks: &Tasks<Task>, data: &mut T, frontend: &mut Frontend<T>) { fn update<T>(&mut self, tasks: &Tasks<Task>, data: &mut T, frontend: &mut Frontend<T>) -> anyhow::Result<()> {
if !frontend.interface.monado_metrics_set_enabled(data, true) { if !frontend.interface.monado_metrics_set_enabled(data, true) {
return; return Ok(());
} }
let frames = frontend.interface.monado_metrics_dump_session_frames(data); let frames = frontend.interface.monado_metrics_dump_session_frames(data);
if frames.is_empty() { if frames.is_empty() {
return; return Ok(());
} }
let col_green = Color::new(0.0, 1.0, 0.0, 1.0); let col_green = Color::new(0.0, 1.0, 0.0, 1.0);
@ -525,7 +527,7 @@ impl SubtabDebugTimings {
frame.session_id, frame.session_id,
TimingsSession { TimingsSession {
last_frame: frame, last_frame: frame,
resolved_name: None, resolved_name: None, /* TODO! find client ID from session ID */
}, },
); );
tasks.push(Task::DebugTimingsRefreshSessionList); tasks.push(Task::DebugTimingsRefreshSessionList);
@ -534,6 +536,8 @@ impl SubtabDebugTimings {
} }
frontend.layout.mark_redraw(); frontend.layout.mark_redraw();
Ok(())
} }
} }
@ -568,7 +572,10 @@ impl SubtabProcessList {
Rc::from("0") Rc::from("0")
}, },
); );
par.insert("name".into(), client.name.clone().into()); par.insert(
"name".into(),
format!("{} (Client ID: {})", client.name, client.id).into(),
);
par.insert("flag_active".into(), yesno(client.is_active).into()); par.insert("flag_active".into(), yesno(client.is_active).into());
par.insert("flag_focused".into(), yesno(client.is_focused).into()); par.insert("flag_focused".into(), yesno(client.is_focused).into());
par.insert("flag_io_active".into(), yesno(client.is_io_active).into()); par.insert("flag_io_active".into(), yesno(client.is_io_active).into());
@ -618,7 +625,7 @@ impl SubtabProcessList {
fn refresh<T>(&mut self, frontend: &mut Frontend<T>, data: &mut T, tasks: &Tasks<Task>) -> anyhow::Result<()> { fn refresh<T>(&mut self, frontend: &mut Frontend<T>, data: &mut T, tasks: &Tasks<Task>) -> anyhow::Result<()> {
log::debug!("refreshing monado client list"); log::debug!("refreshing monado client list");
let clients = frontend.interface.monado_client_list(data)?; let clients = frontend.interface.monado_client_list(data, true)?;
frontend.layout.remove_children(self.id_list_parent); frontend.layout.remove_children(self.id_list_parent);
self.cells.clear(); self.cells.clear();

View File

@ -470,20 +470,27 @@ impl DashInterface<AppState> for DashInterfaceLive {
fn monado_client_list( fn monado_client_list(
&mut self, &mut self,
app: &mut AppState, app: &mut AppState,
filtered: bool,
) -> anyhow::Result<Vec<dash_interface::MonadoClient>> { ) -> anyhow::Result<Vec<dash_interface::MonadoClient>> {
let Some(monado) = &mut app.monado_state else { let Some(monado) = &mut app.monado_state else {
return Ok(Vec::new()); // no monado available return Ok(Vec::new()); // no monado available
}; };
let clients = monado_list_clients_filtered(&mut monado.ipc)?; let clients = if filtered {
monado_list_clients_filtered(&mut monado.ipc)?
} else {
monado.ipc.clients()?.into_iter().collect()
};
let mut res = Vec::<dash_interface::MonadoClient>::new(); let mut res = Vec::<dash_interface::MonadoClient>::new();
for mut client in clients { for mut client in clients {
let client_id = client.id();
let name = client.name()?; let name = client.name()?;
let state = client.state()?; let state = client.state()?;
res.push(dash_interface::MonadoClient { res.push(dash_interface::MonadoClient {
id: client_id as i64,
name, name,
is_primary: state.contains(libmonado::ClientState::ClientPrimaryApp), is_primary: state.contains(libmonado::ClientState::ClientPrimaryApp),
is_active: state.contains(libmonado::ClientState::ClientSessionActive), is_active: state.contains(libmonado::ClientState::ClientSessionActive),
@ -592,6 +599,7 @@ impl DashInterface<AppState> for DashInterfaceLive {
fn monado_client_list( fn monado_client_list(
&mut self, &mut self,
_: &mut AppState, _: &mut AppState,
_filtered: bool,
) -> anyhow::Result<Vec<dash_interface::MonadoClient>> { ) -> anyhow::Result<Vec<dash_interface::MonadoClient>> {
anyhow::bail!("Not supported in this build.") anyhow::bail!("Not supported in this build.")
} }

View File

@ -7,6 +7,7 @@ use crate::{config::GeneralConfig, desktop_finder::DesktopFinder};
#[derive(Clone)] #[derive(Clone)]
pub struct MonadoClient { pub struct MonadoClient {
pub id: i64,
pub name: String, pub name: String,
pub is_primary: bool, pub is_primary: bool,
pub is_active: bool, pub is_active: bool,
@ -55,7 +56,7 @@ pub trait DashInterface<T> {
) -> anyhow::Result<WvrProcessHandle>; ) -> anyhow::Result<WvrProcessHandle>;
fn process_list(&mut self, data: &mut T) -> anyhow::Result<Vec<WvrProcess>>; 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 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_list(&mut self, data: &mut T, filtered: bool) -> anyhow::Result<Vec<MonadoClient>>;
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<()>;

View File

@ -88,6 +88,7 @@ impl DashInterfaceEmulated {
let monado_clients = vec![ let monado_clients = vec![
dash_interface::MonadoClient { dash_interface::MonadoClient {
id: 1,
name: String::from("The Best VR Game 3000"), name: String::from("The Best VR Game 3000"),
is_active: true, is_active: true,
is_focused: true, is_focused: true,
@ -97,6 +98,7 @@ impl DashInterfaceEmulated {
is_visible: true, is_visible: true,
}, },
dash_interface::MonadoClient { dash_interface::MonadoClient {
id: 2,
name: String::from("Second app"), name: String::from("Second app"),
is_active: true, is_active: true,
is_focused: false, is_focused: false,
@ -106,6 +108,7 @@ impl DashInterfaceEmulated {
is_visible: true, is_visible: true,
}, },
dash_interface::MonadoClient { dash_interface::MonadoClient {
id: 3,
name: String::from("Third app"), name: String::from("Third app"),
is_active: true, is_active: true,
is_focused: false, is_focused: false,
@ -233,7 +236,11 @@ impl DashInterface<()> for DashInterfaceEmulated {
fn toggle_dashboard(&mut self, _data: &mut ()) {} fn toggle_dashboard(&mut self, _data: &mut ()) {}
fn monado_client_list(&mut self, _data: &mut ()) -> anyhow::Result<Vec<dash_interface::MonadoClient>> { fn monado_client_list(
&mut self,
_data: &mut (),
_filtered: bool,
) -> anyhow::Result<Vec<dash_interface::MonadoClient>> {
Ok(self.monado_clients.clone()) Ok(self.monado_clients.clone())
} }