pub(crate) fn translate(event: &Event, xw: &mut XWrap) -> Option<DisplayEvent<X11rbWindowHandle>> {
    let is_normal = xw.mode == Mode::Normal;
    let is_sloppy = xw.focus_behaviour.is_sloppy();

    let res = match event {
        Event::MapRequest(e) => xw.setup_window(e.window),
        Event::UnmapNotify(e) => from_unmap_event(e, xw),
        Event::DestroyNotify(e) => from_destroy_notify(e, xw),
        Event::FocusIn(e) => from_focus_in(e, xw),
        Event::ClientMessage(e) if is_normal => client_message::from_event(e, xw),
        Event::PropertyNotify(e) if is_normal => property_notify::from_event(e, xw),
        Event::ConfigureRequest(e) if is_normal => from_configure_request(e, xw),
        Event::EnterNotify(e) if is_normal && is_sloppy => Ok(from_enter_notify(e, xw)),
        Event::MotionNotify(e) => from_motion_notify(e, xw),
        Event::ButtonPress(e) => Ok(Some(from_button_press(e, xw))),
        Event::ButtonRelease(e) if !is_normal => from_button_release(e, xw),
        _ => return None,
    };
    match res {
        Ok(display_event) => display_event,
        Err(e) => {
            tracing::error!(
                "An error occured when processing the event {:?}: {}",
                event,
                e
            );
            #[cfg(debug_assertions)]
            {
                let trace = e.backtrace;
                if trace.status() == BacktraceStatus::Captured {
                    tracing::error!("{}", trace);
                }
            }
            None
        }
    }
}
Translate events from x11rb to leftwm's `DisplayEvent`
display-servers/x11rb-display-server/src/event_translate.rs