#include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v2.h>

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

namespace QtWaylandServer {
    zwp_text_input_v2::zwp_text_input_v2(struct ::wl_client *client, int id, int version)
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
        init(client, id, version);
    }

    zwp_text_input_v2::zwp_text_input_v2(struct ::wl_display *display, int version)
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
        init(display, version);
    }

    zwp_text_input_v2::zwp_text_input_v2(struct ::wl_resource *resource)
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
        init(resource);
    }

    zwp_text_input_v2::zwp_text_input_v2()
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
    }

    zwp_text_input_v2::~zwp_text_input_v2()
    {
        for (auto resource : qAsConst(m_resource_map))
            wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr);

        if (m_global) {
            wl_global_destroy(m_global);
            wl_list_remove(&m_displayDestroyedListener.link);
        }
    }

    void zwp_text_input_v2::init(struct ::wl_client *client, int id, int version)
    {
        m_resource = bind(client, id, version);
    }

    void zwp_text_input_v2::init(struct ::wl_resource *resource)
    {
        m_resource = bind(resource);
    }

    zwp_text_input_v2::Resource *zwp_text_input_v2::add(struct ::wl_client *client, int version)
    {
        Resource *resource = bind(client, 0, version);
        m_resource_map.insert(client, resource);
        return resource;
    }

    zwp_text_input_v2::Resource *zwp_text_input_v2::add(struct ::wl_client *client, int id, int version)
    {
        Resource *resource = bind(client, id, version);
        m_resource_map.insert(client, resource);
        return resource;
    }

    void zwp_text_input_v2::init(struct ::wl_display *display, int version)
    {
        m_global = wl_global_create(display, &::zwp_text_input_v2_interface, version, this, bind_func);
        m_globalVersion = version;
        m_displayDestroyedListener.notify = zwp_text_input_v2::display_destroy_func;
        m_displayDestroyedListener.parent = this;
        wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
    }

    const struct wl_interface *zwp_text_input_v2::interface()
    {
        return &::zwp_text_input_v2_interface;
    }

    zwp_text_input_v2::Resource *zwp_text_input_v2::zwp_text_input_v2_allocate()
    {
        return new Resource;
    }

    void zwp_text_input_v2::zwp_text_input_v2_bind_resource(Resource *)
    {
    }

    void zwp_text_input_v2::zwp_text_input_v2_destroy_resource(Resource *)
    {
    }

    void zwp_text_input_v2::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
    {
        zwp_text_input_v2 *that = static_cast<zwp_text_input_v2 *>(data);
        that->add(client, id, qMin(that->m_globalVersion, version));
    }

    void zwp_text_input_v2::display_destroy_func(struct ::wl_listener *listener, void *data)
    {
        Q_UNUSED(data);
        zwp_text_input_v2 *that = static_cast<zwp_text_input_v2::DisplayDestroyedListener *>(listener)->parent;
        that->m_global = nullptr;
    }

    void zwp_text_input_v2::destroy_func(struct ::wl_resource *client_resource)
    {
        Resource *resource = Resource::fromResource(client_resource);
        Q_ASSERT(resource);
        zwp_text_input_v2 *that = resource->zwp_text_input_v2_object;
        that->m_resource_map.remove(resource->client(), resource);
        that->zwp_text_input_v2_destroy_resource(resource);
        delete resource;
    }

    zwp_text_input_v2::Resource *zwp_text_input_v2::bind(struct ::wl_client *client, uint32_t id, int version)
    {
        Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData());
        struct ::wl_resource *handle = wl_resource_create(client, &::zwp_text_input_v2_interface, version, id);
        return bind(handle);
    }

    zwp_text_input_v2::Resource *zwp_text_input_v2::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwp_text_input_v2_allocate();
        resource->zwp_text_input_v2_object = this;

        wl_resource_set_implementation(handle, &m_zwp_text_input_v2_interface, resource, destroy_func);
        resource->handle = handle;
        zwp_text_input_v2_bind_resource(resource);
        return resource;
    }
    zwp_text_input_v2::Resource *zwp_text_input_v2::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::zwp_text_input_v2_interface, &m_zwp_text_input_v2_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::zwp_text_input_v2_interface zwp_text_input_v2::m_zwp_text_input_v2_interface = {
        zwp_text_input_v2::handle_destroy,
        zwp_text_input_v2::handle_enable,
        zwp_text_input_v2::handle_disable,
        zwp_text_input_v2::handle_show_input_panel,
        zwp_text_input_v2::handle_hide_input_panel,
        zwp_text_input_v2::handle_set_surrounding_text,
        zwp_text_input_v2::handle_set_content_type,
        zwp_text_input_v2::handle_set_cursor_rectangle,
        zwp_text_input_v2::handle_set_preferred_language,
        zwp_text_input_v2::handle_update_state
    };

    void zwp_text_input_v2::zwp_text_input_v2_destroy(Resource *)
    {
    }

    void zwp_text_input_v2::zwp_text_input_v2_enable(Resource *, struct ::wl_resource *)
    {
    }

    void zwp_text_input_v2::zwp_text_input_v2_disable(Resource *, struct ::wl_resource *)
    {
    }

    void zwp_text_input_v2::zwp_text_input_v2_show_input_panel(Resource *)
    {
    }

    void zwp_text_input_v2::zwp_text_input_v2_hide_input_panel(Resource *)
    {
    }

    void zwp_text_input_v2::zwp_text_input_v2_set_surrounding_text(Resource *, const QString &, int32_t , int32_t )
    {
    }

    void zwp_text_input_v2::zwp_text_input_v2_set_content_type(Resource *, uint32_t , uint32_t )
    {
    }

    void zwp_text_input_v2::zwp_text_input_v2_set_cursor_rectangle(Resource *, int32_t , int32_t , int32_t , int32_t )
    {
    }

    void zwp_text_input_v2::zwp_text_input_v2_set_preferred_language(Resource *, const QString &)
    {
    }

    void zwp_text_input_v2::zwp_text_input_v2_update_state(Resource *, uint32_t , uint32_t )
    {
    }


    void zwp_text_input_v2::handle_destroy(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_v2 *>(r->zwp_text_input_v2_object)->zwp_text_input_v2_destroy(
            r);
    }

    void zwp_text_input_v2::handle_enable(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *surface)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_v2 *>(r->zwp_text_input_v2_object)->zwp_text_input_v2_enable(
            r,
            surface);
    }

    void zwp_text_input_v2::handle_disable(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *surface)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_v2 *>(r->zwp_text_input_v2_object)->zwp_text_input_v2_disable(
            r,
            surface);
    }

    void zwp_text_input_v2::handle_show_input_panel(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_v2 *>(r->zwp_text_input_v2_object)->zwp_text_input_v2_show_input_panel(
            r);
    }

    void zwp_text_input_v2::handle_hide_input_panel(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_v2 *>(r->zwp_text_input_v2_object)->zwp_text_input_v2_hide_input_panel(
            r);
    }

    void zwp_text_input_v2::handle_set_surrounding_text(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *text,
        int32_t cursor,
        int32_t anchor)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_v2 *>(r->zwp_text_input_v2_object)->zwp_text_input_v2_set_surrounding_text(
            r,
            QString::fromUtf8(text),
            cursor,
            anchor);
    }

    void zwp_text_input_v2::handle_set_content_type(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t hint,
        uint32_t purpose)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_v2 *>(r->zwp_text_input_v2_object)->zwp_text_input_v2_set_content_type(
            r,
            hint,
            purpose);
    }

    void zwp_text_input_v2::handle_set_cursor_rectangle(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t x,
        int32_t y,
        int32_t width,
        int32_t height)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_v2 *>(r->zwp_text_input_v2_object)->zwp_text_input_v2_set_cursor_rectangle(
            r,
            x,
            y,
            width,
            height);
    }

    void zwp_text_input_v2::handle_set_preferred_language(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *language)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_v2 *>(r->zwp_text_input_v2_object)->zwp_text_input_v2_set_preferred_language(
            r,
            QString::fromUtf8(language));
    }

    void zwp_text_input_v2::handle_update_state(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t serial,
        uint32_t reason)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_v2 *>(r->zwp_text_input_v2_object)->zwp_text_input_v2_update_state(
            r,
            serial,
            reason);
    }

    void zwp_text_input_v2::send_enter(uint32_t serial, struct ::wl_resource *surface)
    {
        send_enter(
            m_resource->handle,
            serial,
            surface);
    }

    void zwp_text_input_v2::send_enter(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface)
    {
        zwp_text_input_v2_send_enter(
            resource,
            serial,
            surface);
    }


    void zwp_text_input_v2::send_leave(uint32_t serial, struct ::wl_resource *surface)
    {
        send_leave(
            m_resource->handle,
            serial,
            surface);
    }

    void zwp_text_input_v2::send_leave(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface)
    {
        zwp_text_input_v2_send_leave(
            resource,
            serial,
            surface);
    }


    void zwp_text_input_v2::send_input_panel_state(uint32_t state, int32_t x, int32_t y, int32_t width, int32_t height)
    {
        send_input_panel_state(
            m_resource->handle,
            state,
            x,
            y,
            width,
            height);
    }

    void zwp_text_input_v2::send_input_panel_state(struct ::wl_resource *resource, uint32_t state, int32_t x, int32_t y, int32_t width, int32_t height)
    {
        zwp_text_input_v2_send_input_panel_state(
            resource,
            state,
            x,
            y,
            width,
            height);
    }


    void zwp_text_input_v2::send_preedit_string(const QString &text, const QString &commit)
    {
        send_preedit_string(
            m_resource->handle,
            text,
            commit);
    }

    void zwp_text_input_v2::send_preedit_string(struct ::wl_resource *resource, const QString &text, const QString &commit)
    {
        zwp_text_input_v2_send_preedit_string(
            resource,
            text.toUtf8().constData(),
            commit.toUtf8().constData());
    }


    void zwp_text_input_v2::send_preedit_styling(uint32_t index, uint32_t length, uint32_t style)
    {
        send_preedit_styling(
            m_resource->handle,
            index,
            length,
            style);
    }

    void zwp_text_input_v2::send_preedit_styling(struct ::wl_resource *resource, uint32_t index, uint32_t length, uint32_t style)
    {
        zwp_text_input_v2_send_preedit_styling(
            resource,
            index,
            length,
            style);
    }


    void zwp_text_input_v2::send_preedit_cursor(int32_t index)
    {
        send_preedit_cursor(
            m_resource->handle,
            index);
    }

    void zwp_text_input_v2::send_preedit_cursor(struct ::wl_resource *resource, int32_t index)
    {
        zwp_text_input_v2_send_preedit_cursor(
            resource,
            index);
    }


    void zwp_text_input_v2::send_commit_string(const QString &text)
    {
        send_commit_string(
            m_resource->handle,
            text);
    }

    void zwp_text_input_v2::send_commit_string(struct ::wl_resource *resource, const QString &text)
    {
        zwp_text_input_v2_send_commit_string(
            resource,
            text.toUtf8().constData());
    }


    void zwp_text_input_v2::send_cursor_position(int32_t index, int32_t anchor)
    {
        send_cursor_position(
            m_resource->handle,
            index,
            anchor);
    }

    void zwp_text_input_v2::send_cursor_position(struct ::wl_resource *resource, int32_t index, int32_t anchor)
    {
        zwp_text_input_v2_send_cursor_position(
            resource,
            index,
            anchor);
    }


    void zwp_text_input_v2::send_delete_surrounding_text(uint32_t before_length, uint32_t after_length)
    {
        send_delete_surrounding_text(
            m_resource->handle,
            before_length,
            after_length);
    }

    void zwp_text_input_v2::send_delete_surrounding_text(struct ::wl_resource *resource, uint32_t before_length, uint32_t after_length)
    {
        zwp_text_input_v2_send_delete_surrounding_text(
            resource,
            before_length,
            after_length);
    }


    void zwp_text_input_v2::send_modifiers_map(const QByteArray &map)
    {
        send_modifiers_map(
            m_resource->handle,
            map);
    }

    void zwp_text_input_v2::send_modifiers_map(struct ::wl_resource *resource, const QByteArray &map)
    {
        struct wl_array map_data;
        map_data.size = map.size();
        map_data.data = static_cast<void *>(const_cast<char *>(map.constData()));
        map_data.alloc = 0;

        zwp_text_input_v2_send_modifiers_map(
            resource,
            &map_data);
    }


    void zwp_text_input_v2::send_keysym(uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers)
    {
        send_keysym(
            m_resource->handle,
            time,
            sym,
            state,
            modifiers);
    }

    void zwp_text_input_v2::send_keysym(struct ::wl_resource *resource, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers)
    {
        zwp_text_input_v2_send_keysym(
            resource,
            time,
            sym,
            state,
            modifiers);
    }


    void zwp_text_input_v2::send_language(const QString &language)
    {
        send_language(
            m_resource->handle,
            language);
    }

    void zwp_text_input_v2::send_language(struct ::wl_resource *resource, const QString &language)
    {
        zwp_text_input_v2_send_language(
            resource,
            language.toUtf8().constData());
    }


    void zwp_text_input_v2::send_text_direction(uint32_t direction)
    {
        send_text_direction(
            m_resource->handle,
            direction);
    }

    void zwp_text_input_v2::send_text_direction(struct ::wl_resource *resource, uint32_t direction)
    {
        zwp_text_input_v2_send_text_direction(
            resource,
            direction);
    }


    void zwp_text_input_v2::send_configure_surrounding_text(int32_t before_cursor, int32_t after_cursor)
    {
        send_configure_surrounding_text(
            m_resource->handle,
            before_cursor,
            after_cursor);
    }

    void zwp_text_input_v2::send_configure_surrounding_text(struct ::wl_resource *resource, int32_t before_cursor, int32_t after_cursor)
    {
        zwp_text_input_v2_send_configure_surrounding_text(
            resource,
            before_cursor,
            after_cursor);
    }


    void zwp_text_input_v2::send_input_method_changed(uint32_t serial, uint32_t flags)
    {
        send_input_method_changed(
            m_resource->handle,
            serial,
            flags);
    }

    void zwp_text_input_v2::send_input_method_changed(struct ::wl_resource *resource, uint32_t serial, uint32_t flags)
    {
        zwp_text_input_v2_send_input_method_changed(
            resource,
            serial,
            flags);
    }


    zwp_text_input_manager_v2::zwp_text_input_manager_v2(struct ::wl_client *client, int id, int version)
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
        init(client, id, version);
    }

    zwp_text_input_manager_v2::zwp_text_input_manager_v2(struct ::wl_display *display, int version)
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
        init(display, version);
    }

    zwp_text_input_manager_v2::zwp_text_input_manager_v2(struct ::wl_resource *resource)
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
        init(resource);
    }

    zwp_text_input_manager_v2::zwp_text_input_manager_v2()
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
    }

    zwp_text_input_manager_v2::~zwp_text_input_manager_v2()
    {
        for (auto resource : qAsConst(m_resource_map))
            wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr);

        if (m_global) {
            wl_global_destroy(m_global);
            wl_list_remove(&m_displayDestroyedListener.link);
        }
    }

    void zwp_text_input_manager_v2::init(struct ::wl_client *client, int id, int version)
    {
        m_resource = bind(client, id, version);
    }

    void zwp_text_input_manager_v2::init(struct ::wl_resource *resource)
    {
        m_resource = bind(resource);
    }

    zwp_text_input_manager_v2::Resource *zwp_text_input_manager_v2::add(struct ::wl_client *client, int version)
    {
        Resource *resource = bind(client, 0, version);
        m_resource_map.insert(client, resource);
        return resource;
    }

    zwp_text_input_manager_v2::Resource *zwp_text_input_manager_v2::add(struct ::wl_client *client, int id, int version)
    {
        Resource *resource = bind(client, id, version);
        m_resource_map.insert(client, resource);
        return resource;
    }

    void zwp_text_input_manager_v2::init(struct ::wl_display *display, int version)
    {
        m_global = wl_global_create(display, &::zwp_text_input_manager_v2_interface, version, this, bind_func);
        m_globalVersion = version;
        m_displayDestroyedListener.notify = zwp_text_input_manager_v2::display_destroy_func;
        m_displayDestroyedListener.parent = this;
        wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
    }

    const struct wl_interface *zwp_text_input_manager_v2::interface()
    {
        return &::zwp_text_input_manager_v2_interface;
    }

    zwp_text_input_manager_v2::Resource *zwp_text_input_manager_v2::zwp_text_input_manager_v2_allocate()
    {
        return new Resource;
    }

    void zwp_text_input_manager_v2::zwp_text_input_manager_v2_bind_resource(Resource *)
    {
    }

    void zwp_text_input_manager_v2::zwp_text_input_manager_v2_destroy_resource(Resource *)
    {
    }

    void zwp_text_input_manager_v2::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
    {
        zwp_text_input_manager_v2 *that = static_cast<zwp_text_input_manager_v2 *>(data);
        that->add(client, id, qMin(that->m_globalVersion, version));
    }

    void zwp_text_input_manager_v2::display_destroy_func(struct ::wl_listener *listener, void *data)
    {
        Q_UNUSED(data);
        zwp_text_input_manager_v2 *that = static_cast<zwp_text_input_manager_v2::DisplayDestroyedListener *>(listener)->parent;
        that->m_global = nullptr;
    }

    void zwp_text_input_manager_v2::destroy_func(struct ::wl_resource *client_resource)
    {
        Resource *resource = Resource::fromResource(client_resource);
        Q_ASSERT(resource);
        zwp_text_input_manager_v2 *that = resource->zwp_text_input_manager_v2_object;
        that->m_resource_map.remove(resource->client(), resource);
        that->zwp_text_input_manager_v2_destroy_resource(resource);
        delete resource;
    }

    zwp_text_input_manager_v2::Resource *zwp_text_input_manager_v2::bind(struct ::wl_client *client, uint32_t id, int version)
    {
        Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData());
        struct ::wl_resource *handle = wl_resource_create(client, &::zwp_text_input_manager_v2_interface, version, id);
        return bind(handle);
    }

    zwp_text_input_manager_v2::Resource *zwp_text_input_manager_v2::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwp_text_input_manager_v2_allocate();
        resource->zwp_text_input_manager_v2_object = this;

        wl_resource_set_implementation(handle, &m_zwp_text_input_manager_v2_interface, resource, destroy_func);
        resource->handle = handle;
        zwp_text_input_manager_v2_bind_resource(resource);
        return resource;
    }
    zwp_text_input_manager_v2::Resource *zwp_text_input_manager_v2::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::zwp_text_input_manager_v2_interface, &m_zwp_text_input_manager_v2_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::zwp_text_input_manager_v2_interface zwp_text_input_manager_v2::m_zwp_text_input_manager_v2_interface = {
        zwp_text_input_manager_v2::handle_destroy,
        zwp_text_input_manager_v2::handle_get_text_input
    };

    void zwp_text_input_manager_v2::zwp_text_input_manager_v2_destroy(Resource *)
    {
    }

    void zwp_text_input_manager_v2::zwp_text_input_manager_v2_get_text_input(Resource *, uint32_t, struct ::wl_resource *)
    {
    }


    void zwp_text_input_manager_v2::handle_destroy(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_manager_v2 *>(r->zwp_text_input_manager_v2_object)->zwp_text_input_manager_v2_destroy(
            r);
    }

    void zwp_text_input_manager_v2::handle_get_text_input(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id,
        struct ::wl_resource *seat)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        static_cast<zwp_text_input_manager_v2 *>(r->zwp_text_input_manager_v2_object)->zwp_text_input_manager_v2_get_text_input(
            r,
            id,
            seat);
    }
}

QT_WARNING_POP
QT_END_NAMESPACE
