fix blocker getting stuck on when the config changes at runtime (#350)

This commit is contained in:
Orion
2026-01-10 03:05:09 +01:00
committed by GitHub
parent 4a853fd79b
commit a7e12a86c4

View File

@@ -4,13 +4,13 @@ use log::{trace, warn};
use crate::{state::AppState, windowing::OverlayID}; use crate::{state::AppState, windowing::OverlayID};
pub(super) struct InputBlocker { pub(super) struct InputBlocker {
hovered_last_frame: bool, blocked_last_frame: bool,
} }
impl InputBlocker { impl InputBlocker {
pub const fn new() -> Self { pub const fn new() -> Self {
Self { Self {
hovered_last_frame: false, blocked_last_frame: false,
} }
} }
@@ -19,17 +19,13 @@ impl InputBlocker {
return; // monado not available return; // monado not available
}; };
if !app.session.config.block_game_input { let should_block = app.input_state.pointers.iter().any(|p| {
return;
}
let any_hovered = app.input_state.pointers.iter().any(|p| {
p.interaction.hovered_id.is_some_and(|id| { p.interaction.hovered_id.is_some_and(|id| {
id != watch_id || !app.session.config.block_game_input_ignore_watch id != watch_id || !app.session.config.block_game_input_ignore_watch
}) })
}); }) && app.session.config.block_game_input;
match (any_hovered, self.hovered_last_frame) { match (should_block, self.blocked_last_frame) {
(true, false) => { (true, false) => {
trace!("Blocking input"); trace!("Blocking input");
set_clients_io_active(monado, false); set_clients_io_active(monado, false);
@@ -41,7 +37,7 @@ impl InputBlocker {
_ => {} _ => {}
} }
self.hovered_last_frame = any_hovered; self.blocked_last_frame = should_block;
} }
} }