//! Event handlers for dealing with window focus. use xcb::x::{EnterNotifyEvent, FocusInEvent, NotifyDetail, NotifyMode}; use crate::WM; impl WM<'_> { /// When a new window is entered, focus it. pub fn handle_enter_notify(&mut self, e: &EnterNotifyEvent) { if (e.mode() != NotifyMode::Normal || e.detail() == NotifyDetail::Inferior) && e.event() != self.conn.root() { return; } if let Some((mon, pos)) = self.clients.find_client_pos(e.event()) { self.clients.refocus(&self.conn, mon, pos); } } /// When a window attempts to focus in, refocus the actually focused window to deal with some broken clients. pub fn handle_focus_in(&mut self, e: &FocusInEvent) { if !self.clients.is_focused(e.event()) { if let Some(pos) = self.clients.focused_pos() { self.clients.refocus(&self.conn, pos.0, pos.1); } } } }