reduce indentations in block_inputs

This commit is contained in:
Sapphire 2026-02-11 18:51:23 -06:00 committed by galister
parent 26f078d512
commit 4afaa6d048
1 changed files with 32 additions and 41 deletions

View File

@ -1,5 +1,6 @@
use libmonado::{BlockFlags, ClientLogic, ClientState, Monado, Version};
use log::{trace, warn};
use log::trace;
use wgui::log::LogErr;
use crate::state::AppState;
@ -57,47 +58,37 @@ impl InputBlocker {
}
fn block_inputs(&self, monado: &mut Monado, block_inputs: bool, block_poses: bool) {
match monado.clients() {
Ok(clients) => {
for mut client in clients {
match client.name() {
Ok(n) => {
if n == "wayvr" {
continue;
}
}
Err(e) => {
warn!("Failed to get client name: {e}");
continue;
}
};
let state = match client.state() {
Ok(s) => s,
Err(e) => {
warn!("Failed to get client state: {e}");
continue;
}
};
if state.contains(ClientState::ClientSessionVisible) {
let r = if self.use_io_blocks {
let flags = match (block_inputs, block_poses) {
(true, true) => BlockFlags::BlockPoses | BlockFlags::BlockInputs,
(true, false) => BlockFlags::BlockInputs.into(),
(false, _) => BlockFlags::None.into(),
};
client.set_io_blocks(flags)
} else {
client.set_io_active(!block_inputs)
};
if let Err(e) = r {
warn!("Failed to set io active for client: {e}");
}
}
}
let Ok(clients) = monado
.clients()
.log_warn("Failed to get clients from Monado")
else {
return;
};
for mut client in clients {
let Ok(name) = client.name().log_warn("Failed to get client name") else {
continue;
};
if name == "wayvr" {
continue;
}
let Ok(state) = client.state().log_warn("Failed to get client state") else {
continue;
};
if state.contains(ClientState::ClientSessionVisible) {
let _ = if self.use_io_blocks {
let flags = match (block_inputs, block_poses) {
(true, true) => BlockFlags::BlockPoses | BlockFlags::BlockInputs,
(true, false) => BlockFlags::BlockInputs.into(),
(false, _) => BlockFlags::None.into(),
};
client.set_io_blocks(flags)
} else {
client.set_io_active(!block_inputs)
}
.log_warn("Failed to set IO active for client");
}
Err(e) => warn!("Failed to get clients from Monado: {e}"),
}
}
}