use slate_platform::WindowId;
use crate::event::{PendingCaptureOp, PendingFocusOp};
use super::state::AppState;
impl AppState {
pub(crate) fn apply_pending_focus_op(&self, window: WindowId, op: Option<PendingFocusOp>) {
let Some(op) = op else { return };
let guard = self.windows.borrow();
let Some(win) = guard.get(&window) else {
return;
};
let mut reg = win.focus_registry.borrow_mut();
match op {
PendingFocusOp::Focus(id) => {
reg.set_focus(id);
}
PendingFocusOp::Blur => reg.clear_focus(),
}
}
pub(crate) fn apply_pending_capture_op(&self, window: WindowId, op: Option<PendingCaptureOp>) {
let Some(op) = op else { return };
let guard = self.windows.borrow();
let Some(win) = guard.get(&window) else {
return;
};
match op {
PendingCaptureOp::Set(id) => {
*win.capture_target.borrow_mut() = Some(id);
*win.explicit_capture.borrow_mut() = true;
}
PendingCaptureOp::Release => {
*win.capture_target.borrow_mut() = None;
*win.explicit_capture.borrow_mut() = false;
}
}
}
}