From 054af2a1f7d2785baa25e2eb4de51d88226bed23 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Tue, 16 Jul 2024 22:12:58 +0000 Subject: [PATCH] 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 --- src/xstate/mod.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/xstate/mod.rs b/src/xstate/mod.rs index dd0788f..e8aee23 100644 --- a/src/xstate/mod.rs +++ b/src/xstate/mod.rs @@ -812,19 +812,23 @@ impl super::XConnection for Arc { } 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, revert_to: x::InputFocus::None, time: x::CURRENT_TIME, - })); - - unwrap_or_skip_bad_window!(self.send_and_check_request(&x::ChangeProperty { + }) { + log::debug!("SetInputFocus failed ({:?}: {:?})", window, e); + return; + } + if let Err(e) = self.send_and_check_request(&x::ChangeProperty { mode: x::PropMode::Replace, window: self.root_window(), property: atoms.active_win, r#type: x::ATOM_WINDOW, data: &[window], - })); + }) { + log::debug!("ChangeProperty failed ({:?}: {:?})", window, e); + } } fn close_window(&mut self, window: x::Window, atoms: Self::ExtraData) {