pub fn window_destroyed_handler(&mut self, handle: &WindowHandle<H>) -> bool {
        // Get the previous focused window else find the next or previous window on the workspace.
        let new_handle = if let Some(Some(last_focused_window)) = self
            .state
            .focus_manager
            .window_history
            .iter()
            // Take the first window that is not the destroyed window.
            .find(|w| w != &&Some(*handle))
        {
            Some(*last_focused_window)
        } else {
            self.get_next_or_previous_handle(handle)
        };
        // If there is a parent we would want to focus it.
        let (transient, floating, visible) =
            match self.state.windows.iter().find(|w| &w.handle == handle) {
                Some(window) => (window.transient, window.floating(), window.visible()),
                None => return false,
            };
        self.state
            .focus_manager
            .tags_last_window
            .retain(|_, h| h != handle);
        self.state.windows.retain(|w| &w.handle != handle);

        self.state.handle_single_border(self.config.border_width());

        // Make sure the workspaces do not draw on the docks.
        update_workspace_avoid_list(&mut self.state);

        let focused = self.state.focus_manager.window_history.front();
        // Make sure focus is recalculated if we closed the currently focused window
        if focused == Some(&Some(*handle)) {
            if self.state.focus_manager.behaviour.is_sloppy()
                && self.state.focus_manager.sloppy_mouse_follows_focus
            {
                let act = DisplayAction::FocusWindowUnderCursor;
                self.state.actions.push_back(act);
                // Make sure we actually update the focus, as the currently
                // focused window will be removed from history.
                self.state.focus_manager.window_history.push_front(None);
            } else if let Some(parent) =
                find_transient_parent(&self.state.windows, transient).map(|p| p.handle)
            {
                self.state.focus_window(&parent);
            } else if let Some(handle) = new_handle {
                self.state.focus_window(&handle);
            } else {
                let act = DisplayAction::Unfocus(Some(*handle), floating);
                self.state.actions.push_back(act);
                self.state.focus_manager.window_history.push_front(None);
            }
        }

        // Remove destroyed window from history.
        self.state
            .focus_manager
            .window_history
            .retain(|w| w != &Some(*handle));

        // Only update windows if this window is visible.
        visible
    }
`window_destroyed_handler` is called when the display server sends
the `DisplayEvent::WindowDestroy(handle)` event.

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