pub fn setup_window(
        &self,
        window: xproto::Window,
    ) -> Result<Option<DisplayEvent<X11rbWindowHandle>>> {
        // Check that the window isn't requesting to be unmanaged
        let attrs = self.get_window_attrs(window)?;
        if attrs.override_redirect || self.managed_windows.contains(&window) {
            return Ok(None);
        }
        let handle = WindowHandle(X11rbWindowHandle(window));
        // Gather info about the window from xlib.
        let name = self.get_window_name(window)?;
        let legacy_name = self.get_window_legacy_name(window).ok();
        let class = self.get_window_class(window)?;
        let pid = self.get_window_pid(window)?;
        let r#type = self.get_window_type(window)?;
        let states = self.get_window_states(window)?;
        let actions = self.get_window_actions_atoms(window)?;
        let mut can_resize = actions.contains(&self.atoms.NetWMActionResize);
        let trans = self.get_transient_for(window)?;
        let sizing_hint = self.get_hint_sizing_as_xyhw(window)?;
        let wm_hint = self.get_wmhints(window)?;

        // Build the new window, and fill in info about it.
        let mut w = Window::new(handle, Some(name), Some(pid));
        w.res_name = class
            .as_ref()
            .and_then(|c| String::from_utf8(c.instance().to_vec()).ok());
        w.res_class = class.and_then(|c| String::from_utf8(c.class().to_vec()).ok());
        w.legacy_name = legacy_name;
        w.r#type = r#type.clone();
        w.states = states;
        w.transient = trans.map(|h| WindowHandle(X11rbWindowHandle(h)));

        // Initialise the windows floating with the pre-mapped settings.
        sizing_hint
            .unwrap_or_default()
            .update_window_floating(&mut w);
        let mut requested = Xyhw::default();
        sizing_hint.unwrap_or_default().update(&mut requested);

        if let Some(hint) = sizing_hint {
            // Ignore this for now for non-splashes as it causes issues, e.g. mintstick is non-resizable but is too
            // small, issue #614: https://github.com/leftwm/leftwm/issues/614.
            can_resize = match (r#type, hint.minw, hint.minh, hint.maxw, hint.maxh) {
                (
                    WindowType::Splash,
                    Some(min_width),
                    Some(min_height),
                    Some(max_width),
                    Some(max_height),
                ) => can_resize || min_width != max_width || min_height != max_height,
                _ => true,
            };
            // Use the pre-mapped sizes if they are bigger.
            // hint.w = std::cmp::max(xyhw.w, hint.w);
            // hint.h = std::cmp::max(xyhw.h, hint.h);
            hint.update_window_floating(&mut w);
            hint.update(&mut requested);
        }

        w.requested = Some(requested);
        w.can_resize = can_resize;
        if let Some(hint) = wm_hint {
            w.never_focus = !hint.input.unwrap_or(true);
            w.urgent = hint.urgent;
        }
        // Is this needed? Made it so it doens't overwrite prior sizing.
        if w.floating() && sizing_hint.is_none() {
            let geo = self.get_window_geometry(window)?;
            geo.update_window_floating(&mut w);
        }

        let cursor = self.get_cursor_point()?;
        Ok(Some(DisplayEvent::WindowCreate(w, cursor.0, cursor.1)))
    }
Sets up a window before we manage it.
display-servers/x11rb-display-server/src/xwrap/window.rs