do not panic if focus_window fails (#39)

Some windows don't take well to being focused, but it doesn't matter that much.
---------

Co-authored-by: Shawn Wallace <yungwallace@live.com>
This commit is contained in:
galister 2024-07-16 22:12:58 +00:00 committed by GitHub
parent 3140b7c83e
commit 054af2a1f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -812,19 +812,23 @@ impl super::XConnection for Arc<xcb::Connection> {
} }
fn focus_window(&mut self, window: x::Window, atoms: Self::ExtraData) { fn focus_window(&mut self, window: x::Window, atoms: Self::ExtraData) {
unwrap_or_skip_bad_window!(self.send_and_check_request(&x::SetInputFocus { if let Err(e) = self.send_and_check_request(&x::SetInputFocus {
focus: window, focus: window,
revert_to: x::InputFocus::None, revert_to: x::InputFocus::None,
time: x::CURRENT_TIME, time: x::CURRENT_TIME,
})); }) {
log::debug!("SetInputFocus failed ({:?}: {:?})", window, e);
unwrap_or_skip_bad_window!(self.send_and_check_request(&x::ChangeProperty { return;
}
if let Err(e) = self.send_and_check_request(&x::ChangeProperty {
mode: x::PropMode::Replace, mode: x::PropMode::Replace,
window: self.root_window(), window: self.root_window(),
property: atoms.active_win, property: atoms.active_win,
r#type: x::ATOM_WINDOW, r#type: x::ATOM_WINDOW,
data: &[window], data: &[window],
})); }) {
log::debug!("ChangeProperty failed ({:?}: {:?})", window, e);
}
} }
fn close_window(&mut self, window: x::Window, atoms: Self::ExtraData) { fn close_window(&mut self, window: x::Window, atoms: Self::ExtraData) {