#include <QtWaylandClient/private/qwayland-touch-extension.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_touch_extension::qt_touch_extension(struct ::wl_registry *registry, int id, int version)
    {
        init(registry, id, version);
    }

    qt_touch_extension::qt_touch_extension(struct ::qt_touch_extension *obj)
        : m_qt_touch_extension(obj)
    {
        init_listener();
    }

    qt_touch_extension::qt_touch_extension()
        : m_qt_touch_extension(nullptr)
    {
    }

    qt_touch_extension::~qt_touch_extension()
    {
    }

    void qt_touch_extension::init(struct ::wl_registry *registry, int id, int version)
    {
        m_qt_touch_extension = static_cast<struct ::qt_touch_extension *>(wlRegistryBind(registry, id, &qt_touch_extension_interface, version));
        init_listener();
    }

    void qt_touch_extension::init(struct ::qt_touch_extension *obj)
    {
        m_qt_touch_extension = obj;
        init_listener();
    }

    qt_touch_extension *qt_touch_extension::fromObject(struct ::qt_touch_extension *object)
    {
        if (wl_proxy_get_listener((struct ::wl_proxy *)object) != (void *)&m_qt_touch_extension_listener)
            return nullptr;
        return static_cast<qt_touch_extension *>(qt_touch_extension_get_user_data(object));
    }

    bool qt_touch_extension::isInitialized() const
    {
        return m_qt_touch_extension != nullptr;
    }

    const struct wl_interface *qt_touch_extension::interface()
    {
        return &::qt_touch_extension_interface;
    }

    void qt_touch_extension::dummy()
    {
        qt_touch_extension_dummy(
            m_qt_touch_extension);
    }

    void qt_touch_extension::touch_extension_touch(uint32_t , uint32_t , uint32_t , int32_t , int32_t , int32_t , int32_t , int32_t , int32_t , uint32_t , int32_t , int32_t , uint32_t , wl_array *)
    {
    }

    void qt_touch_extension::handle_touch(
        void *data,
        struct ::qt_touch_extension *object,
        uint32_t time,
        uint32_t id,
        uint32_t state,
        int32_t x,
        int32_t y,
        int32_t normalized_x,
        int32_t normalized_y,
        int32_t width,
        int32_t height,
        uint32_t pressure,
        int32_t velocity_x,
        int32_t velocity_y,
        uint32_t flags,
        wl_array *rawdata)
    {
        Q_UNUSED(object);
        static_cast<qt_touch_extension *>(data)->touch_extension_touch(
            time,
            id,
            state,
            x,
            y,
            normalized_x,
            normalized_y,
            width,
            height,
            pressure,
            velocity_x,
            velocity_y,
            flags,
            rawdata);
    }

    void qt_touch_extension::touch_extension_configure(uint32_t )
    {
    }

    void qt_touch_extension::handle_configure(
        void *data,
        struct ::qt_touch_extension *object,
        uint32_t flags)
    {
        Q_UNUSED(object);
        static_cast<qt_touch_extension *>(data)->touch_extension_configure(
            flags);
    }

    const struct qt_touch_extension_listener qt_touch_extension::m_qt_touch_extension_listener = {
        qt_touch_extension::handle_touch,
        qt_touch_extension::handle_configure
    };

    void qt_touch_extension::init_listener()
    {
        qt_touch_extension_add_listener(m_qt_touch_extension, &m_qt_touch_extension_listener, this);
    }
}

QT_WARNING_POP
QT_END_NAMESPACE
