pub fn set_mode(&mut self, mode: Mode<X11rbWindowHandle>) -> Result<()> {
        match mode {
            // Prevent resizing and moving of root.
            Mode::MovingWindow(h)
            | Mode::ResizingWindow(h)
            | Mode::ReadyToMove(h)
            | Mode::ReadyToResize(h)
                if h == self.get_default_root_handle() => {}
            Mode::ReadyToMove(_) | Mode::ReadyToResize(_) if self.mode == Mode::Normal => {
                self.mode = mode;
                match self.get_cursor_point() {
                    Ok(loc) => self.mode_origin = loc,
                    Err(e) if e.kind == ErrorKind::RootWindowNotFound => {
                        return Err(e);
                    }
                    _ => (),
                }
                let cursor = match mode {
                    Mode::ReadyToResize(_) | Mode::ResizingWindow(_) => self.cursors.resize,
                    Mode::ReadyToMove(_) | Mode::MovingWindow(_) => self.cursors.move_,
                    Mode::Normal => self.cursors.normal,
                };
                self.grab_pointer(cursor)?;
            }
            Mode::MovingWindow(h) | Mode::ResizingWindow(h)
                if self.mode == Mode::ReadyToMove(h) || self.mode == Mode::ReadyToResize(h) =>
            {
                self.ungrab_pointer()?;
                self.mode = mode;
                let cursor = match mode {
                    Mode::ReadyToResize(_) | Mode::ResizingWindow(_) => self.cursors.resize,
                    Mode::ReadyToMove(_) | Mode::MovingWindow(_) => self.cursors.move_,
                    Mode::Normal => self.cursors.normal,
                };
                self.grab_pointer(cursor)?;
            }
            Mode::Normal => {
                self.ungrab_pointer()?;
                self.mode = mode;
            }
            _ => {}
        }
        Ok(())
    }
Sets the mode within our xwrapper.
display-servers/x11rb-display-server/src/xwrap.rs