//! The xdg_wm_base interface is exposed as a global object enabling clients to turn
//! their wl_surfaces into windows in a desktop environment. it defines the basic
//! functionality needed for clients and the compositor to create windows that can
//! be dragged, resized, maximized, etc, as well as creating transient windows such
//! as popup menus.

//
//
//              GENERATED BY OUR WAYLAND-SCANNER. DO NOT EDIT!
//
//

#![allow(unused)]
#![allow(clippy::from_over_into)]
#![allow(clippy::match_single_binding)]

use crate::wl::{
    Array, Connection, Handle, Interface, Message, NewId, ObjectId, Opcode, Payload, PayloadType,
    RawMessage, SendError,
};
use alloc::rc::Rc;
use alloc::string::String;
use core::cell::RefCell;
use smallvec::smallvec;

use crate::wl::protocols::common::wl_buffer::WlBuffer;
use crate::wl::protocols::common::wl_callback::WlCallback;
use crate::wl::protocols::common::wl_compositor::WlCompositor;
use crate::wl::protocols::common::wl_data_device::WlDataDevice;
use crate::wl::protocols::common::wl_data_device_manager::WlDataDeviceManager;
use crate::wl::protocols::common::wl_data_offer::WlDataOffer;
use crate::wl::protocols::common::wl_data_source::WlDataSource;
use crate::wl::protocols::common::wl_display::WlDisplay;
use crate::wl::protocols::common::wl_keyboard::WlKeyboard;
use crate::wl::protocols::common::wl_output::WlOutput;
use crate::wl::protocols::common::wl_pointer::WlPointer;
use crate::wl::protocols::common::wl_region::WlRegion;
use crate::wl::protocols::common::wl_registry::WlRegistry;
use crate::wl::protocols::common::wl_seat::WlSeat;
use crate::wl::protocols::common::wl_shell::WlShell;
use crate::wl::protocols::common::wl_shell_surface::WlShellSurface;
use crate::wl::protocols::common::wl_shm::WlShm;
use crate::wl::protocols::common::wl_shm_pool::WlShmPool;
use crate::wl::protocols::common::wl_subcompositor::WlSubcompositor;
use crate::wl::protocols::common::wl_subsurface::WlSubsurface;
use crate::wl::protocols::common::wl_surface::WlSurface;
use crate::wl::protocols::common::wl_touch::WlTouch;
use crate::wl::protocols::common::xdg_popup::XdgPopup;
use crate::wl::protocols::common::xdg_positioner::XdgPositioner;
use crate::wl::protocols::common::xdg_surface::XdgSurface;
use crate::wl::protocols::common::xdg_toplevel::XdgToplevel;

use crate::wl::protocols::common::xdg_wm_base::*;

pub trait XdgWmBaseExt {
    /// The ping event asks the client if it's still alive. pass the serial specified in
    /// the event back to the compositor by sending a "pong" request back with the
    /// specified serial. see xdg_wm_base.pong. compositors can use this to determine if
    /// the client is still alive. it's unspecified what will happen if the client
    /// doesn't respond to the ping request, or in what timeframe. clients should try to
    /// respond in a reasonable amount of time. a compositor is free to ping in any way
    /// it wants, but a client must always respond to any xdg_wm_base object it created.
    fn ping(&self, serial: u32) -> Result<(), SendError>;
}

impl XdgWmBaseExt for XdgWmBase {
    /// The ping event asks the client if it's still alive. pass the serial specified in
    /// the event back to the compositor by sending a "pong" request back with the
    /// specified serial. see xdg_wm_base.pong. compositors can use this to determine if
    /// the client is still alive. it's unspecified what will happen if the client
    /// doesn't respond to the ping request, or in what timeframe. clients should try to
    /// respond in a reasonable amount of time. a compositor is free to ping in any way
    /// it wants, but a client must always respond to any xdg_wm_base object it created.
    fn ping(&self, serial: u32) -> Result<(), SendError> {
        self.connection()
            .borrow_mut()
            .send(Event::Ping { serial }.into_raw(self.id()))
    }
}
