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

#include "qwayland-server-input-method-unstable-v1.h"

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

namespace QtWaylandServer {

    int zwp_input_method_context_v1::deferred_destroy_global_func(void *data) {
        auto object = static_cast<zwp_input_method_context_v1 *>(data);
        wl_global_destroy(object->m_global);
        object->m_global = nullptr;
        wl_event_source_remove(object->m_globalRemovedEvent);
        object->m_globalRemovedEvent = nullptr;
        wl_list_remove(&object->m_displayDestroyedListener.link);
        object->zwp_input_method_context_v1_destroy_global();
        return 0;
    }

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

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

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

    zwp_input_method_context_v1::zwp_input_method_context_v1()
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
        , m_display(nullptr)
        , m_globalRemovedEvent(nullptr)
    {
    }

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

        if (m_resource)
            m_resource->zwp_input_method_context_v1_object = nullptr;

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

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

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

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

    zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::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_input_method_context_v1::init(struct ::wl_display *display, int version)
    {
        m_display = display;
        m_global = wl_global_create(display, &::zwp_input_method_context_v1_interface, version, this, bind_func);
        m_displayDestroyedListener.notify = zwp_input_method_context_v1::display_destroy_func;
        m_displayDestroyedListener.parent = this;
        wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
    }

    const struct wl_interface *zwp_input_method_context_v1::interface()
    {
        return &::zwp_input_method_context_v1_interface;
    }

    zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::zwp_input_method_context_v1_allocate()
    {
        return new Resource;
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_destroy_global()
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_bind_resource(Resource *)
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void zwp_input_method_context_v1::globalRemove()
    {
        if (!m_global || m_globalRemovedEvent)
            return;

        wl_global_remove(m_global);

        struct wl_event_loop *event_loop = wl_display_get_event_loop(m_display);
        m_globalRemovedEvent = wl_event_loop_add_timer(event_loop, deferred_destroy_global_func, this);
        wl_event_source_timer_update(m_globalRemovedEvent, 5000);
    }

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

    zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwp_input_method_context_v1_allocate();
        resource->zwp_input_method_context_v1_object = this;

        wl_resource_set_implementation(handle, &m_zwp_input_method_context_v1_interface, resource, destroy_func);
        resource->handle = handle;
        zwp_input_method_context_v1_bind_resource(resource);
        return resource;
    }
    zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::zwp_input_method_context_v1_interface, &m_zwp_input_method_context_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::zwp_input_method_context_v1_interface zwp_input_method_context_v1::m_zwp_input_method_context_v1_interface = {
        zwp_input_method_context_v1::handle_destroy,
        zwp_input_method_context_v1::handle_commit_string,
        zwp_input_method_context_v1::handle_preedit_string,
        zwp_input_method_context_v1::handle_preedit_styling,
        zwp_input_method_context_v1::handle_preedit_cursor,
        zwp_input_method_context_v1::handle_delete_surrounding_text,
        zwp_input_method_context_v1::handle_cursor_position,
        zwp_input_method_context_v1::handle_modifiers_map,
        zwp_input_method_context_v1::handle_keysym,
        zwp_input_method_context_v1::handle_grab_keyboard,
        zwp_input_method_context_v1::handle_key,
        zwp_input_method_context_v1::handle_modifiers,
        zwp_input_method_context_v1::handle_language,
        zwp_input_method_context_v1::handle_text_direction
    };

    void zwp_input_method_context_v1::zwp_input_method_context_v1_destroy(Resource *)
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_commit_string(Resource *, uint32_t , const QString &)
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_preedit_string(Resource *, uint32_t , const QString &, const QString &)
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_preedit_styling(Resource *, uint32_t , uint32_t , uint32_t )
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_preedit_cursor(Resource *, int32_t )
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_delete_surrounding_text(Resource *, int32_t , uint32_t )
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_cursor_position(Resource *, int32_t , int32_t )
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_modifiers_map(Resource *, wl_array *)
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_keysym(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t )
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_grab_keyboard(Resource *, uint32_t)
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_key(Resource *, uint32_t , uint32_t , uint32_t , uint32_t )
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_modifiers(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t )
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_language(Resource *, uint32_t , const QString &)
    {
    }

    void zwp_input_method_context_v1::zwp_input_method_context_v1_text_direction(Resource *, uint32_t , uint32_t )
    {
    }


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

    void zwp_input_method_context_v1::handle_commit_string(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t serial,
        const char *text)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_commit_string(
            r,
            serial,
            QString::fromUtf8(text));
    }

    void zwp_input_method_context_v1::handle_preedit_string(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t serial,
        const char *text,
        const char *commit)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_preedit_string(
            r,
            serial,
            QString::fromUtf8(text),
            QString::fromUtf8(commit));
    }

    void zwp_input_method_context_v1::handle_preedit_styling(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t index,
        uint32_t length,
        uint32_t style)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_preedit_styling(
            r,
            index,
            length,
            style);
    }

    void zwp_input_method_context_v1::handle_preedit_cursor(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t index)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_preedit_cursor(
            r,
            index);
    }

    void zwp_input_method_context_v1::handle_delete_surrounding_text(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t index,
        uint32_t length)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_delete_surrounding_text(
            r,
            index,
            length);
    }

    void zwp_input_method_context_v1::handle_cursor_position(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t index,
        int32_t anchor)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_cursor_position(
            r,
            index,
            anchor);
    }

    void zwp_input_method_context_v1::handle_modifiers_map(
        ::wl_client *client,
        struct wl_resource *resource,
        wl_array *map)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_modifiers_map(
            r,
            map);
    }

    void zwp_input_method_context_v1::handle_keysym(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t serial,
        uint32_t time,
        uint32_t sym,
        uint32_t state,
        uint32_t modifiers)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_keysym(
            r,
            serial,
            time,
            sym,
            state,
            modifiers);
    }

    void zwp_input_method_context_v1::handle_grab_keyboard(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t keyboard)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_grab_keyboard(
            r,
            keyboard);
    }

    void zwp_input_method_context_v1::handle_key(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t serial,
        uint32_t time,
        uint32_t key,
        uint32_t state)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_key(
            r,
            serial,
            time,
            key,
            state);
    }

    void zwp_input_method_context_v1::handle_modifiers(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t serial,
        uint32_t mods_depressed,
        uint32_t mods_latched,
        uint32_t mods_locked,
        uint32_t group)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_modifiers(
            r,
            serial,
            mods_depressed,
            mods_latched,
            mods_locked,
            group);
    }

    void zwp_input_method_context_v1::handle_language(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t serial,
        const char *language)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_language(
            r,
            serial,
            QString::fromUtf8(language));
    }

    void zwp_input_method_context_v1::handle_text_direction(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t serial,
        uint32_t direction)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_method_context_v1_object)) {
            return;
        }
        static_cast<zwp_input_method_context_v1 *>(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_text_direction(
            r,
            serial,
            direction);
    }

    void zwp_input_method_context_v1::send_surrounding_text(const QString &text, uint32_t cursor, uint32_t anchor)
    {
        Q_ASSERT_X(m_resource, "zwp_input_method_context_v1::surrounding_text", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call zwp_input_method_context_v1::surrounding_text as it's not initialised");
            return;
        }
        send_surrounding_text(
            m_resource->handle,
            text,
            cursor,
            anchor);
    }

    void zwp_input_method_context_v1::send_surrounding_text(struct ::wl_resource *resource, const QString &text, uint32_t cursor, uint32_t anchor)
    {
        zwp_input_method_context_v1_send_surrounding_text(
            resource,
            text.toUtf8().constData(),
            cursor,
            anchor);
    }


    void zwp_input_method_context_v1::send_reset()
    {
        Q_ASSERT_X(m_resource, "zwp_input_method_context_v1::reset", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call zwp_input_method_context_v1::reset as it's not initialised");
            return;
        }
        send_reset(
            m_resource->handle);
    }

    void zwp_input_method_context_v1::send_reset(struct ::wl_resource *resource)
    {
        zwp_input_method_context_v1_send_reset(
            resource);
    }


    void zwp_input_method_context_v1::send_content_type(uint32_t hint, uint32_t purpose)
    {
        Q_ASSERT_X(m_resource, "zwp_input_method_context_v1::content_type", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call zwp_input_method_context_v1::content_type as it's not initialised");
            return;
        }
        send_content_type(
            m_resource->handle,
            hint,
            purpose);
    }

    void zwp_input_method_context_v1::send_content_type(struct ::wl_resource *resource, uint32_t hint, uint32_t purpose)
    {
        zwp_input_method_context_v1_send_content_type(
            resource,
            hint,
            purpose);
    }


    void zwp_input_method_context_v1::send_invoke_action(uint32_t button, uint32_t index)
    {
        Q_ASSERT_X(m_resource, "zwp_input_method_context_v1::invoke_action", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call zwp_input_method_context_v1::invoke_action as it's not initialised");
            return;
        }
        send_invoke_action(
            m_resource->handle,
            button,
            index);
    }

    void zwp_input_method_context_v1::send_invoke_action(struct ::wl_resource *resource, uint32_t button, uint32_t index)
    {
        zwp_input_method_context_v1_send_invoke_action(
            resource,
            button,
            index);
    }


    void zwp_input_method_context_v1::send_commit_state(uint32_t serial)
    {
        Q_ASSERT_X(m_resource, "zwp_input_method_context_v1::commit_state", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call zwp_input_method_context_v1::commit_state as it's not initialised");
            return;
        }
        send_commit_state(
            m_resource->handle,
            serial);
    }

    void zwp_input_method_context_v1::send_commit_state(struct ::wl_resource *resource, uint32_t serial)
    {
        zwp_input_method_context_v1_send_commit_state(
            resource,
            serial);
    }


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

    void zwp_input_method_context_v1::send_preferred_language(struct ::wl_resource *resource, const QString &language)
    {
        zwp_input_method_context_v1_send_preferred_language(
            resource,
            language.toUtf8().constData());
    }



    int zwp_input_method_v1::deferred_destroy_global_func(void *data) {
        auto object = static_cast<zwp_input_method_v1 *>(data);
        wl_global_destroy(object->m_global);
        object->m_global = nullptr;
        wl_event_source_remove(object->m_globalRemovedEvent);
        object->m_globalRemovedEvent = nullptr;
        wl_list_remove(&object->m_displayDestroyedListener.link);
        object->zwp_input_method_v1_destroy_global();
        return 0;
    }

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

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

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

    zwp_input_method_v1::zwp_input_method_v1()
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
        , m_display(nullptr)
        , m_globalRemovedEvent(nullptr)
    {
    }

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

        if (m_resource)
            m_resource->zwp_input_method_v1_object = nullptr;

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

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

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

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

    zwp_input_method_v1::Resource *zwp_input_method_v1::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_input_method_v1::init(struct ::wl_display *display, int version)
    {
        m_display = display;
        m_global = wl_global_create(display, &::zwp_input_method_v1_interface, version, this, bind_func);
        m_displayDestroyedListener.notify = zwp_input_method_v1::display_destroy_func;
        m_displayDestroyedListener.parent = this;
        wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
    }

    const struct wl_interface *zwp_input_method_v1::interface()
    {
        return &::zwp_input_method_v1_interface;
    }

    zwp_input_method_v1::Resource *zwp_input_method_v1::zwp_input_method_v1_allocate()
    {
        return new Resource;
    }

    void zwp_input_method_v1::zwp_input_method_v1_destroy_global()
    {
    }

    void zwp_input_method_v1::zwp_input_method_v1_bind_resource(Resource *)
    {
    }

    void zwp_input_method_v1::zwp_input_method_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void zwp_input_method_v1::globalRemove()
    {
        if (!m_global || m_globalRemovedEvent)
            return;

        wl_global_remove(m_global);

        struct wl_event_loop *event_loop = wl_display_get_event_loop(m_display);
        m_globalRemovedEvent = wl_event_loop_add_timer(event_loop, deferred_destroy_global_func, this);
        wl_event_source_timer_update(m_globalRemovedEvent, 5000);
    }

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

    zwp_input_method_v1::Resource *zwp_input_method_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwp_input_method_v1_allocate();
        resource->zwp_input_method_v1_object = this;

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

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

    void zwp_input_method_v1::send_activate(struct ::wl_resource *resource, struct ::wl_resource *id)
    {
        zwp_input_method_v1_send_activate(
            resource,
            id);
    }


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

    void zwp_input_method_v1::send_deactivate(struct ::wl_resource *resource, struct ::wl_resource *context)
    {
        zwp_input_method_v1_send_deactivate(
            resource,
            context);
    }



    int zwp_input_panel_v1::deferred_destroy_global_func(void *data) {
        auto object = static_cast<zwp_input_panel_v1 *>(data);
        wl_global_destroy(object->m_global);
        object->m_global = nullptr;
        wl_event_source_remove(object->m_globalRemovedEvent);
        object->m_globalRemovedEvent = nullptr;
        wl_list_remove(&object->m_displayDestroyedListener.link);
        object->zwp_input_panel_v1_destroy_global();
        return 0;
    }

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

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

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

    zwp_input_panel_v1::zwp_input_panel_v1()
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
        , m_display(nullptr)
        , m_globalRemovedEvent(nullptr)
    {
    }

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

        if (m_resource)
            m_resource->zwp_input_panel_v1_object = nullptr;

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

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

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

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

    zwp_input_panel_v1::Resource *zwp_input_panel_v1::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_input_panel_v1::init(struct ::wl_display *display, int version)
    {
        m_display = display;
        m_global = wl_global_create(display, &::zwp_input_panel_v1_interface, version, this, bind_func);
        m_displayDestroyedListener.notify = zwp_input_panel_v1::display_destroy_func;
        m_displayDestroyedListener.parent = this;
        wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
    }

    const struct wl_interface *zwp_input_panel_v1::interface()
    {
        return &::zwp_input_panel_v1_interface;
    }

    zwp_input_panel_v1::Resource *zwp_input_panel_v1::zwp_input_panel_v1_allocate()
    {
        return new Resource;
    }

    void zwp_input_panel_v1::zwp_input_panel_v1_destroy_global()
    {
    }

    void zwp_input_panel_v1::zwp_input_panel_v1_bind_resource(Resource *)
    {
    }

    void zwp_input_panel_v1::zwp_input_panel_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void zwp_input_panel_v1::globalRemove()
    {
        if (!m_global || m_globalRemovedEvent)
            return;

        wl_global_remove(m_global);

        struct wl_event_loop *event_loop = wl_display_get_event_loop(m_display);
        m_globalRemovedEvent = wl_event_loop_add_timer(event_loop, deferred_destroy_global_func, this);
        wl_event_source_timer_update(m_globalRemovedEvent, 5000);
    }

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

    zwp_input_panel_v1::Resource *zwp_input_panel_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwp_input_panel_v1_allocate();
        resource->zwp_input_panel_v1_object = this;

        wl_resource_set_implementation(handle, &m_zwp_input_panel_v1_interface, resource, destroy_func);
        resource->handle = handle;
        zwp_input_panel_v1_bind_resource(resource);
        return resource;
    }
    zwp_input_panel_v1::Resource *zwp_input_panel_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::zwp_input_panel_v1_interface, &m_zwp_input_panel_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::zwp_input_panel_v1_interface zwp_input_panel_v1::m_zwp_input_panel_v1_interface = {
        zwp_input_panel_v1::handle_get_input_panel_surface
    };

    void zwp_input_panel_v1::zwp_input_panel_v1_get_input_panel_surface(Resource *, uint32_t, struct ::wl_resource *)
    {
    }


    void zwp_input_panel_v1::handle_get_input_panel_surface(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id,
        struct ::wl_resource *surface)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_panel_v1_object)) {
            return;
        }
        static_cast<zwp_input_panel_v1 *>(r->zwp_input_panel_v1_object)->zwp_input_panel_v1_get_input_panel_surface(
            r,
            id,
            surface);
    }


    int zwp_input_panel_surface_v1::deferred_destroy_global_func(void *data) {
        auto object = static_cast<zwp_input_panel_surface_v1 *>(data);
        wl_global_destroy(object->m_global);
        object->m_global = nullptr;
        wl_event_source_remove(object->m_globalRemovedEvent);
        object->m_globalRemovedEvent = nullptr;
        wl_list_remove(&object->m_displayDestroyedListener.link);
        object->zwp_input_panel_surface_v1_destroy_global();
        return 0;
    }

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

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

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

    zwp_input_panel_surface_v1::zwp_input_panel_surface_v1()
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
        , m_display(nullptr)
        , m_globalRemovedEvent(nullptr)
    {
    }

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

        if (m_resource)
            m_resource->zwp_input_panel_surface_v1_object = nullptr;

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

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

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

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

    zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::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_input_panel_surface_v1::init(struct ::wl_display *display, int version)
    {
        m_display = display;
        m_global = wl_global_create(display, &::zwp_input_panel_surface_v1_interface, version, this, bind_func);
        m_displayDestroyedListener.notify = zwp_input_panel_surface_v1::display_destroy_func;
        m_displayDestroyedListener.parent = this;
        wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
    }

    const struct wl_interface *zwp_input_panel_surface_v1::interface()
    {
        return &::zwp_input_panel_surface_v1_interface;
    }

    zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_allocate()
    {
        return new Resource;
    }

    void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_destroy_global()
    {
    }

    void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_bind_resource(Resource *)
    {
    }

    void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void zwp_input_panel_surface_v1::globalRemove()
    {
        if (!m_global || m_globalRemovedEvent)
            return;

        wl_global_remove(m_global);

        struct wl_event_loop *event_loop = wl_display_get_event_loop(m_display);
        m_globalRemovedEvent = wl_event_loop_add_timer(event_loop, deferred_destroy_global_func, this);
        wl_event_source_timer_update(m_globalRemovedEvent, 5000);
    }

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

    zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwp_input_panel_surface_v1_allocate();
        resource->zwp_input_panel_surface_v1_object = this;

        wl_resource_set_implementation(handle, &m_zwp_input_panel_surface_v1_interface, resource, destroy_func);
        resource->handle = handle;
        zwp_input_panel_surface_v1_bind_resource(resource);
        return resource;
    }
    zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::zwp_input_panel_surface_v1_interface, &m_zwp_input_panel_surface_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::zwp_input_panel_surface_v1_interface zwp_input_panel_surface_v1::m_zwp_input_panel_surface_v1_interface = {
        zwp_input_panel_surface_v1::handle_set_toplevel,
        zwp_input_panel_surface_v1::handle_set_overlay_panel
    };

    void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_set_toplevel(Resource *, struct ::wl_resource *, uint32_t )
    {
    }

    void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_set_overlay_panel(Resource *)
    {
    }


    void zwp_input_panel_surface_v1::handle_set_toplevel(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *output,
        uint32_t position)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_panel_surface_v1_object)) {
            return;
        }
        static_cast<zwp_input_panel_surface_v1 *>(r->zwp_input_panel_surface_v1_object)->zwp_input_panel_surface_v1_set_toplevel(
            r,
            output,
            position);
    }

    void zwp_input_panel_surface_v1::handle_set_overlay_panel(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_input_panel_surface_v1_object)) {
            return;
        }
        static_cast<zwp_input_panel_surface_v1 *>(r->zwp_input_panel_surface_v1_object)->zwp_input_panel_surface_v1_set_overlay_panel(
            r);
    }
}

QT_WARNING_POP
QT_END_NAMESPACE
