// This file was generated by qtwaylandscanner
// source file is qt-text-input-method-unstable-v1.xml

#include <QtWaylandCompositor/private/qwayland-server-qt-text-input-method-unstable-v1.h>

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

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

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

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

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

    qt_text_input_method_v1::~qt_text_input_method_v1()
    {
        for (auto resource : std::as_const(m_resource_map))
            resource->text_input_method_v1_object = nullptr;

        if (m_resource)
            m_resource->text_input_method_v1_object = nullptr;

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

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

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

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

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

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

    const struct wl_interface *qt_text_input_method_v1::interface()
    {
        return &::qt_text_input_method_v1_interface;
    }

    qt_text_input_method_v1::Resource *qt_text_input_method_v1::text_input_method_v1_allocate()
    {
        return new Resource;
    }

    void qt_text_input_method_v1::text_input_method_v1_bind_resource(Resource *)
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_destroy_resource(Resource *)
    {
    }

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

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

    void qt_text_input_method_v1::destroy_func(struct ::wl_resource *client_resource)
    {
        Resource *resource = Resource::fromResource(client_resource);
        Q_ASSERT(resource);
        qt_text_input_method_v1 *that = resource->text_input_method_v1_object;
        if (Q_LIKELY(that)) {
            that->m_resource_map.remove(resource->client(), resource);
            that->text_input_method_v1_destroy_resource(resource);

            that = resource->text_input_method_v1_object;
            if (that && that->m_resource == resource)
                that->m_resource = nullptr;
        }
        delete resource;
    }

    qt_text_input_method_v1::Resource *qt_text_input_method_v1::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, &::qt_text_input_method_v1_interface, version, id);
        return bind(handle);
    }

    qt_text_input_method_v1::Resource *qt_text_input_method_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = text_input_method_v1_allocate();
        resource->text_input_method_v1_object = this;

        wl_resource_set_implementation(handle, &m_qt_text_input_method_v1_interface, resource, destroy_func);
        resource->handle = handle;
        text_input_method_v1_bind_resource(resource);
        return resource;
    }
    qt_text_input_method_v1::Resource *qt_text_input_method_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::qt_text_input_method_v1_interface, &m_qt_text_input_method_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::qt_text_input_method_v1_interface qt_text_input_method_v1::m_qt_text_input_method_v1_interface = {
        qt_text_input_method_v1::handle_destroy,
        qt_text_input_method_v1::handle_enable,
        qt_text_input_method_v1::handle_disable,
        qt_text_input_method_v1::handle_reset,
        qt_text_input_method_v1::handle_commit,
        qt_text_input_method_v1::handle_invoke_action,
        qt_text_input_method_v1::handle_update_hints,
        qt_text_input_method_v1::handle_update_cursor_rectangle,
        qt_text_input_method_v1::handle_update_cursor_position,
        qt_text_input_method_v1::handle_update_surrounding_text,
        qt_text_input_method_v1::handle_update_anchor_position,
        qt_text_input_method_v1::handle_update_absolute_position,
        qt_text_input_method_v1::handle_update_preferred_language,
        qt_text_input_method_v1::handle_start_update,
        qt_text_input_method_v1::handle_end_update,
        qt_text_input_method_v1::handle_show_input_panel,
        qt_text_input_method_v1::handle_hide_input_panel,
        qt_text_input_method_v1::handle_acknowledge_input_method
    };

    void qt_text_input_method_v1::text_input_method_v1_destroy(Resource *)
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_enable(Resource *, struct ::wl_resource *)
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_disable(Resource *, struct ::wl_resource *)
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_reset(Resource *)
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_commit(Resource *)
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_invoke_action(Resource *, int32_t , int32_t )
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_update_hints(Resource *, int32_t )
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_update_cursor_rectangle(Resource *, int32_t , int32_t , int32_t , int32_t )
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_update_cursor_position(Resource *, int32_t )
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_update_surrounding_text(Resource *, const QString &, int32_t )
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_update_anchor_position(Resource *, int32_t )
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_update_absolute_position(Resource *, int32_t )
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_update_preferred_language(Resource *, const QString &)
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_start_update(Resource *, int32_t )
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_end_update(Resource *)
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_show_input_panel(Resource *)
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_hide_input_panel(Resource *)
    {
    }

    void qt_text_input_method_v1::text_input_method_v1_acknowledge_input_method(Resource *)
    {
    }


    void qt_text_input_method_v1::handle_destroy(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            wl_resource_destroy(resource);
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_destroy(
            r);
    }

    void qt_text_input_method_v1::handle_enable(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *surface)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_enable(
            r,
            surface);
    }

    void qt_text_input_method_v1::handle_disable(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *surface)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_disable(
            r,
            surface);
    }

    void qt_text_input_method_v1::handle_reset(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_reset(
            r);
    }

    void qt_text_input_method_v1::handle_commit(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_commit(
            r);
    }

    void qt_text_input_method_v1::handle_invoke_action(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t type,
        int32_t cursor_position)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_invoke_action(
            r,
            type,
            cursor_position);
    }

    void qt_text_input_method_v1::handle_update_hints(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t hints)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_update_hints(
            r,
            hints);
    }

    void qt_text_input_method_v1::handle_update_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);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_update_cursor_rectangle(
            r,
            x,
            y,
            width,
            height);
    }

    void qt_text_input_method_v1::handle_update_cursor_position(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t cursor_position)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_update_cursor_position(
            r,
            cursor_position);
    }

    void qt_text_input_method_v1::handle_update_surrounding_text(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *surrounding_text,
        int32_t text_offset)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_update_surrounding_text(
            r,
            QString::fromUtf8(surrounding_text),
            text_offset);
    }

    void qt_text_input_method_v1::handle_update_anchor_position(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t anchor_position)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_update_anchor_position(
            r,
            anchor_position);
    }

    void qt_text_input_method_v1::handle_update_absolute_position(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t absolute_position)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_update_absolute_position(
            r,
            absolute_position);
    }

    void qt_text_input_method_v1::handle_update_preferred_language(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *preferred_language)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_update_preferred_language(
            r,
            QString::fromUtf8(preferred_language));
    }

    void qt_text_input_method_v1::handle_start_update(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t queries)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_start_update(
            r,
            queries);
    }

    void qt_text_input_method_v1::handle_end_update(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_end_update(
            r);
    }

    void qt_text_input_method_v1::handle_show_input_panel(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_show_input_panel(
            r);
    }

    void qt_text_input_method_v1::handle_hide_input_panel(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_hide_input_panel(
            r);
    }

    void qt_text_input_method_v1::handle_acknowledge_input_method(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_v1 *>(r->text_input_method_v1_object)->text_input_method_v1_acknowledge_input_method(
            r);
    }

    void qt_text_input_method_v1::send_enter(struct ::wl_resource *surface)
    {
        Q_ASSERT_X(m_resource, "qt_text_input_method_v1::enter", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call qt_text_input_method_v1::enter as it's not initialised");
            return;
        }
        send_enter(
            m_resource->handle,
            surface);
    }

    void qt_text_input_method_v1::send_enter(struct ::wl_resource *resource, struct ::wl_resource *surface)
    {
        qt_text_input_method_v1_send_enter(
            resource,
            surface);
    }


    void qt_text_input_method_v1::send_leave(struct ::wl_resource *surface)
    {
        Q_ASSERT_X(m_resource, "qt_text_input_method_v1::leave", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call qt_text_input_method_v1::leave as it's not initialised");
            return;
        }
        send_leave(
            m_resource->handle,
            surface);
    }

    void qt_text_input_method_v1::send_leave(struct ::wl_resource *resource, struct ::wl_resource *surface)
    {
        qt_text_input_method_v1_send_leave(
            resource,
            surface);
    }


    void qt_text_input_method_v1::send_key(int32_t type, int32_t key, int32_t modifiers, int32_t auto_repeat, int32_t count, int32_t native_scan_code, int32_t native_virtual_key, int32_t native_modifiers, const QString &text)
    {
        Q_ASSERT_X(m_resource, "qt_text_input_method_v1::key", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call qt_text_input_method_v1::key as it's not initialised");
            return;
        }
        send_key(
            m_resource->handle,
            type,
            key,
            modifiers,
            auto_repeat,
            count,
            native_scan_code,
            native_virtual_key,
            native_modifiers,
            text);
    }

    void qt_text_input_method_v1::send_key(struct ::wl_resource *resource, int32_t type, int32_t key, int32_t modifiers, int32_t auto_repeat, int32_t count, int32_t native_scan_code, int32_t native_virtual_key, int32_t native_modifiers, const QString &text)
    {
        qt_text_input_method_v1_send_key(
            resource,
            type,
            key,
            modifiers,
            auto_repeat,
            count,
            native_scan_code,
            native_virtual_key,
            native_modifiers,
            text.toUtf8().constData());
    }


    void qt_text_input_method_v1::send_start_input_method_event(uint32_t serial, int32_t surrounding_text_offset)
    {
        Q_ASSERT_X(m_resource, "qt_text_input_method_v1::start_input_method_event", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call qt_text_input_method_v1::start_input_method_event as it's not initialised");
            return;
        }
        send_start_input_method_event(
            m_resource->handle,
            serial,
            surrounding_text_offset);
    }

    void qt_text_input_method_v1::send_start_input_method_event(struct ::wl_resource *resource, uint32_t serial, int32_t surrounding_text_offset)
    {
        qt_text_input_method_v1_send_start_input_method_event(
            resource,
            serial,
            surrounding_text_offset);
    }


    void qt_text_input_method_v1::send_input_method_event_attribute(uint32_t serial, int32_t type, int32_t start, int32_t length, const QString &value)
    {
        Q_ASSERT_X(m_resource, "qt_text_input_method_v1::input_method_event_attribute", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call qt_text_input_method_v1::input_method_event_attribute as it's not initialised");
            return;
        }
        send_input_method_event_attribute(
            m_resource->handle,
            serial,
            type,
            start,
            length,
            value);
    }

    void qt_text_input_method_v1::send_input_method_event_attribute(struct ::wl_resource *resource, uint32_t serial, int32_t type, int32_t start, int32_t length, const QString &value)
    {
        qt_text_input_method_v1_send_input_method_event_attribute(
            resource,
            serial,
            type,
            start,
            length,
            value.toUtf8().constData());
    }


    void qt_text_input_method_v1::send_end_input_method_event(uint32_t serial, const QString &commit_string, const QString &preedit_string, int32_t replacement_start, int32_t replacement_length)
    {
        Q_ASSERT_X(m_resource, "qt_text_input_method_v1::end_input_method_event", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call qt_text_input_method_v1::end_input_method_event as it's not initialised");
            return;
        }
        send_end_input_method_event(
            m_resource->handle,
            serial,
            commit_string,
            preedit_string,
            replacement_start,
            replacement_length);
    }

    void qt_text_input_method_v1::send_end_input_method_event(struct ::wl_resource *resource, uint32_t serial, const QString &commit_string, const QString &preedit_string, int32_t replacement_start, int32_t replacement_length)
    {
        qt_text_input_method_v1_send_end_input_method_event(
            resource,
            serial,
            commit_string.toUtf8().constData(),
            preedit_string.toUtf8().constData(),
            replacement_start,
            replacement_length);
    }


    void qt_text_input_method_v1::send_visible_changed(int32_t visible)
    {
        Q_ASSERT_X(m_resource, "qt_text_input_method_v1::visible_changed", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call qt_text_input_method_v1::visible_changed as it's not initialised");
            return;
        }
        send_visible_changed(
            m_resource->handle,
            visible);
    }

    void qt_text_input_method_v1::send_visible_changed(struct ::wl_resource *resource, int32_t visible)
    {
        qt_text_input_method_v1_send_visible_changed(
            resource,
            visible);
    }


    void qt_text_input_method_v1::send_keyboard_rectangle_changed(wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height)
    {
        Q_ASSERT_X(m_resource, "qt_text_input_method_v1::keyboard_rectangle_changed", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call qt_text_input_method_v1::keyboard_rectangle_changed as it's not initialised");
            return;
        }
        send_keyboard_rectangle_changed(
            m_resource->handle,
            x,
            y,
            width,
            height);
    }

    void qt_text_input_method_v1::send_keyboard_rectangle_changed(struct ::wl_resource *resource, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height)
    {
        qt_text_input_method_v1_send_keyboard_rectangle_changed(
            resource,
            x,
            y,
            width,
            height);
    }


    void qt_text_input_method_v1::send_locale_changed(const QString &locale_name)
    {
        Q_ASSERT_X(m_resource, "qt_text_input_method_v1::locale_changed", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call qt_text_input_method_v1::locale_changed as it's not initialised");
            return;
        }
        send_locale_changed(
            m_resource->handle,
            locale_name);
    }

    void qt_text_input_method_v1::send_locale_changed(struct ::wl_resource *resource, const QString &locale_name)
    {
        qt_text_input_method_v1_send_locale_changed(
            resource,
            locale_name.toUtf8().constData());
    }


    void qt_text_input_method_v1::send_input_direction_changed(int32_t input_direction)
    {
        Q_ASSERT_X(m_resource, "qt_text_input_method_v1::input_direction_changed", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call qt_text_input_method_v1::input_direction_changed as it's not initialised");
            return;
        }
        send_input_direction_changed(
            m_resource->handle,
            input_direction);
    }

    void qt_text_input_method_v1::send_input_direction_changed(struct ::wl_resource *resource, int32_t input_direction)
    {
        qt_text_input_method_v1_send_input_direction_changed(
            resource,
            input_direction);
    }


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

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

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

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

    qt_text_input_method_manager_v1::~qt_text_input_method_manager_v1()
    {
        for (auto resource : std::as_const(m_resource_map))
            resource->text_input_method_manager_v1_object = nullptr;

        if (m_resource)
            m_resource->text_input_method_manager_v1_object = nullptr;

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

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

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

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

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

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

    const struct wl_interface *qt_text_input_method_manager_v1::interface()
    {
        return &::qt_text_input_method_manager_v1_interface;
    }

    qt_text_input_method_manager_v1::Resource *qt_text_input_method_manager_v1::text_input_method_manager_v1_allocate()
    {
        return new Resource;
    }

    void qt_text_input_method_manager_v1::text_input_method_manager_v1_bind_resource(Resource *)
    {
    }

    void qt_text_input_method_manager_v1::text_input_method_manager_v1_destroy_resource(Resource *)
    {
    }

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

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

    void qt_text_input_method_manager_v1::destroy_func(struct ::wl_resource *client_resource)
    {
        Resource *resource = Resource::fromResource(client_resource);
        Q_ASSERT(resource);
        qt_text_input_method_manager_v1 *that = resource->text_input_method_manager_v1_object;
        if (Q_LIKELY(that)) {
            that->m_resource_map.remove(resource->client(), resource);
            that->text_input_method_manager_v1_destroy_resource(resource);

            that = resource->text_input_method_manager_v1_object;
            if (that && that->m_resource == resource)
                that->m_resource = nullptr;
        }
        delete resource;
    }

    qt_text_input_method_manager_v1::Resource *qt_text_input_method_manager_v1::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, &::qt_text_input_method_manager_v1_interface, version, id);
        return bind(handle);
    }

    qt_text_input_method_manager_v1::Resource *qt_text_input_method_manager_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = text_input_method_manager_v1_allocate();
        resource->text_input_method_manager_v1_object = this;

        wl_resource_set_implementation(handle, &m_qt_text_input_method_manager_v1_interface, resource, destroy_func);
        resource->handle = handle;
        text_input_method_manager_v1_bind_resource(resource);
        return resource;
    }
    qt_text_input_method_manager_v1::Resource *qt_text_input_method_manager_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::qt_text_input_method_manager_v1_interface, &m_qt_text_input_method_manager_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::qt_text_input_method_manager_v1_interface qt_text_input_method_manager_v1::m_qt_text_input_method_manager_v1_interface = {
        qt_text_input_method_manager_v1::handle_destroy,
        qt_text_input_method_manager_v1::handle_get_text_input_method
    };

    void qt_text_input_method_manager_v1::text_input_method_manager_v1_destroy(Resource *)
    {
    }

    void qt_text_input_method_manager_v1::text_input_method_manager_v1_get_text_input_method(Resource *, uint32_t, struct ::wl_resource *)
    {
    }


    void qt_text_input_method_manager_v1::handle_destroy(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_manager_v1_object)) {
            wl_resource_destroy(resource);
            return;
        }
        static_cast<qt_text_input_method_manager_v1 *>(r->text_input_method_manager_v1_object)->text_input_method_manager_v1_destroy(
            r);
    }

    void qt_text_input_method_manager_v1::handle_get_text_input_method(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id,
        struct ::wl_resource *seat)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->text_input_method_manager_v1_object)) {
            return;
        }
        static_cast<qt_text_input_method_manager_v1 *>(r->text_input_method_manager_v1_object)->text_input_method_manager_v1_get_text_input_method(
            r,
            id,
            seat);
    }
}

QT_WARNING_POP
QT_END_NAMESPACE
