#include "qwayland-custom.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_example_extension::qt_example_extension(struct ::wl_registry *registry, int id, int version)
    {
        init(registry, id, version);
    }

    qt_example_extension::qt_example_extension(struct ::qt_example_extension *obj)
        : m_qt_example_extension(obj)
    {
        init_listener();
    }

    qt_example_extension::qt_example_extension()
        : m_qt_example_extension(nullptr)
    {
    }

    qt_example_extension::~qt_example_extension()
    {
    }

    void qt_example_extension::init(struct ::wl_registry *registry, int id, int version)
    {
        m_qt_example_extension = static_cast<struct ::qt_example_extension *>(wlRegistryBind(registry, id, &qt_example_extension_interface, version));
        init_listener();
    }

    void qt_example_extension::init(struct ::qt_example_extension *obj)
    {
        m_qt_example_extension = obj;
        init_listener();
    }

    qt_example_extension *qt_example_extension::fromObject(struct ::qt_example_extension *object)
    {
        if (wl_proxy_get_listener((struct ::wl_proxy *)object) != (void *)&m_qt_example_extension_listener)
            return nullptr;
        return static_cast<qt_example_extension *>(qt_example_extension_get_user_data(object));
    }

    bool qt_example_extension::isInitialized() const
    {
        return m_qt_example_extension != nullptr;
    }

    const struct wl_interface *qt_example_extension::interface()
    {
        return &::qt_example_extension_interface;
    }

    void qt_example_extension::register_surface(struct ::wl_surface *surface)
    {
        qt_example_extension_register_surface(
            m_qt_example_extension,
            surface);
    }

    void qt_example_extension::bounce(struct ::wl_surface *surface, uint32_t duration)
    {
        qt_example_extension_bounce(
            m_qt_example_extension,
            surface,
            duration);
    }

    void qt_example_extension::spin(struct ::wl_surface *surface, uint32_t duration)
    {
        qt_example_extension_spin(
            m_qt_example_extension,
            surface,
            duration);
    }

    struct ::qt_example_local_object *qt_example_extension::create_local_object(const QString &color, const QString &text)
    {
        return qt_example_extension_create_local_object(
            m_qt_example_extension,
            color.toUtf8().constData(),
            text.toUtf8().constData());
    }

    void qt_example_extension::example_extension_close(struct ::wl_surface *)
    {
    }

    void qt_example_extension::handle_close(
        void *data,
        struct ::qt_example_extension *object,
        struct ::wl_surface *surface)
    {
        Q_UNUSED(object);
        static_cast<qt_example_extension *>(data)->example_extension_close(
            surface);
    }

    void qt_example_extension::example_extension_set_font_size(struct ::wl_surface *, uint32_t )
    {
    }

    void qt_example_extension::handle_set_font_size(
        void *data,
        struct ::qt_example_extension *object,
        struct ::wl_surface *surface,
        uint32_t pixel_size)
    {
        Q_UNUSED(object);
        static_cast<qt_example_extension *>(data)->example_extension_set_font_size(
            surface,
            pixel_size);
    }

    void qt_example_extension::example_extension_set_window_decoration(uint32_t )
    {
    }

    void qt_example_extension::handle_set_window_decoration(
        void *data,
        struct ::qt_example_extension *object,
        uint32_t state)
    {
        Q_UNUSED(object);
        static_cast<qt_example_extension *>(data)->example_extension_set_window_decoration(
            state);
    }

    const struct qt_example_extension_listener qt_example_extension::m_qt_example_extension_listener = {
        qt_example_extension::handle_close,
        qt_example_extension::handle_set_font_size,
        qt_example_extension::handle_set_window_decoration
    };

    void qt_example_extension::init_listener()
    {
        qt_example_extension_add_listener(m_qt_example_extension, &m_qt_example_extension_listener, this);
    }

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

    qt_example_local_object::qt_example_local_object(struct ::qt_example_local_object *obj)
        : m_qt_example_local_object(obj)
    {
        init_listener();
    }

    qt_example_local_object::qt_example_local_object()
        : m_qt_example_local_object(nullptr)
    {
    }

    qt_example_local_object::~qt_example_local_object()
    {
    }

    void qt_example_local_object::init(struct ::wl_registry *registry, int id, int version)
    {
        m_qt_example_local_object = static_cast<struct ::qt_example_local_object *>(wlRegistryBind(registry, id, &qt_example_local_object_interface, version));
        init_listener();
    }

    void qt_example_local_object::init(struct ::qt_example_local_object *obj)
    {
        m_qt_example_local_object = obj;
        init_listener();
    }

    qt_example_local_object *qt_example_local_object::fromObject(struct ::qt_example_local_object *object)
    {
        if (wl_proxy_get_listener((struct ::wl_proxy *)object) != (void *)&m_qt_example_local_object_listener)
            return nullptr;
        return static_cast<qt_example_local_object *>(qt_example_local_object_get_user_data(object));
    }

    bool qt_example_local_object::isInitialized() const
    {
        return m_qt_example_local_object != nullptr;
    }

    const struct wl_interface *qt_example_local_object::interface()
    {
        return &::qt_example_local_object_interface;
    }

    void qt_example_local_object::set_text(const QString &text)
    {
        qt_example_local_object_set_text(
            m_qt_example_local_object,
            text.toUtf8().constData());
    }

    void qt_example_local_object::example_local_object_clicked()
    {
    }

    void qt_example_local_object::handle_clicked(
        void *data,
        struct ::qt_example_local_object *object)
    {
        Q_UNUSED(object);
        static_cast<qt_example_local_object *>(data)->example_local_object_clicked();
    }

    const struct qt_example_local_object_listener qt_example_local_object::m_qt_example_local_object_listener = {
        qt_example_local_object::handle_clicked
    };

    void qt_example_local_object::init_listener()
    {
        qt_example_local_object_add_listener(m_qt_example_local_object, &m_qt_example_local_object_listener, this);
    }
}

QT_WARNING_POP
QT_END_NAMESPACE
