// This file was generated by qtwaylandscanner
// source file is /build/qt5-wayland/src/kde-qtwayland/src/extensions/xcomposite.xml

#include "qwayland-xcomposite.h"

QT_BEGIN_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers")

namespace QtWayland {

static inline void *wlRegistryBind(struct ::wl_registry *registry, uint32_t name, const struct ::wl_interface *interface, uint32_t version)
{
    const uint32_t bindOpCode = 0;
#if (WAYLAND_VERSION_MAJOR == 1 && WAYLAND_VERSION_MINOR > 10) || WAYLAND_VERSION_MAJOR > 1
    return (void *) wl_proxy_marshal_constructor_versioned((struct wl_proxy *) registry,
        bindOpCode, interface, version, name, interface->name, version, nullptr);
#else
    return (void *) wl_proxy_marshal_constructor((struct wl_proxy *) registry,
        bindOpCode, interface, name, interface->name, version, nullptr);
#endif
}

    qt_xcomposite::qt_xcomposite(struct ::wl_registry *registry, int id, int version)
    {
        init(registry, id, version);
    }

    qt_xcomposite::qt_xcomposite(struct ::qt_xcomposite *obj)
        : m_qt_xcomposite(obj)
    {
        init_listener();
    }

    qt_xcomposite::qt_xcomposite()
        : m_qt_xcomposite(nullptr)
    {
    }

    qt_xcomposite::~qt_xcomposite()
    {
    }

    void qt_xcomposite::init(struct ::wl_registry *registry, int id, int version)
    {
        m_qt_xcomposite = static_cast<struct ::qt_xcomposite *>(wlRegistryBind(registry, id, &qt_xcomposite_interface, version));
        init_listener();
    }

    void qt_xcomposite::init(struct ::qt_xcomposite *obj)
    {
        m_qt_xcomposite = obj;
        init_listener();
    }

    qt_xcomposite *qt_xcomposite::fromObject(struct ::qt_xcomposite *object)
    {
        if (wl_proxy_get_listener((struct ::wl_proxy *)object) != (void *)&m_qt_xcomposite_listener)
            return nullptr;
        return static_cast<qt_xcomposite *>(qt_xcomposite_get_user_data(object));
    }

    bool qt_xcomposite::isInitialized() const
    {
        return m_qt_xcomposite != nullptr;
    }

    const struct wl_interface *qt_xcomposite::interface()
    {
        return &::qt_xcomposite_interface;
    }

    struct ::wl_buffer *qt_xcomposite::create_buffer(uint32_t x_window, int32_t width, int32_t height)
    {
        return qt_xcomposite_create_buffer(
            m_qt_xcomposite,
            x_window,
            width,
            height);
    }

    void qt_xcomposite::xcomposite_root(const QString &, uint32_t )
    {
    }

    void qt_xcomposite::handle_root(
        void *data,
        struct ::qt_xcomposite *object,
        const char *display_name,
        uint32_t root_window)
    {
        Q_UNUSED(object);
        static_cast<qt_xcomposite *>(data)->xcomposite_root(
            QString::fromUtf8(display_name),
            root_window);
    }

    const struct qt_xcomposite_listener qt_xcomposite::m_qt_xcomposite_listener = {
        qt_xcomposite::handle_root,
    };

    void qt_xcomposite::init_listener()
    {
        qt_xcomposite_add_listener(m_qt_xcomposite, &m_qt_xcomposite_listener, this);
    }
}

QT_WARNING_POP
QT_END_NAMESPACE
