pub fn window_created_handler(&mut self, mut window: Window<H>, x: i32, y: i32) -> bool {
        // Don't add the window if the manager already knows about it.
        if self.state.windows.iter().any(|w| w.handle == window.handle) {
            return false;
        }

        // Setup any predefined hooks.
        self.config
            .setup_predefined_window(&mut self.state, &mut window);

        // TODO: this seems very janky.
        let mut is_first = false;
        let mut on_same_tag = true;
        // Random value
        let mut layout = MAIN_AND_VERT_STACK.to_string();
        setup_window(
            &mut self.state,
            &mut window,
            (x, y),
            &mut layout,
            &mut is_first,
            &mut on_same_tag,
        );
        self.config.load_window(&mut window);
        insert_window(&mut self.state, &mut window, &layout);

        let follow_mouse = self.state.focus_manager.focus_new_windows
            && self.state.focus_manager.behaviour.is_sloppy()
            && self.state.focus_manager.sloppy_mouse_follows_focus
            && on_same_tag;

        // Let the DS know we are managing this window.
        let act = DisplayAction::AddedWindow(window.handle, window.floating(), follow_mouse);
        self.state.actions.push_back(act);

        // Let the DS know the correct desktop to find this window.
        if window.tag.is_some() {
            let act = DisplayAction::SetWindowTag(window.handle, window.tag);
            self.state.actions.push_back(act);
        }

        // Tell the WM to reevaluate the stacking order, so the new window is put in the correct layer
        self.state.sort_windows();

        // if `single_window_border` is `false`, remove borders if there is a single visible window
        self.state.handle_single_border(self.config.border_width());

        // `is_first` and `on_same_tag` are set by `setup_window`
        // TODO: remove focus_new_windows variable from focus_manager,
        // TODO: use self.config.focus_new_windows() instead
        if (self.state.focus_manager.focus_new_windows || is_first) && on_same_tag {
            self.state.focus_window(&window.handle);
        }

        // run the `on_new_window_cmd` set in `config.ron`
        if let Some(cmd) = &self.config.on_new_window_cmd() {
            exec_shell(cmd, &mut self.children);
        }

        true
    }
`window_created_handler` is called when the display server sends
the event `DisplayEvent::WindowCreate(w, x, y)`.

Returns true if changes need to be rendered.
leftwm-core/src/handlers/window_handler.rs