// This file was generated by qtwaylandscanner
// source file is xdg-foreign-unstable-v2.xml

#include "qwayland-server-xdg-foreign-unstable-v2.h"

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

namespace QtWaylandServer {

    int zxdg_exporter_v2::deferred_destroy_global_func(void *data) {
        auto object = static_cast<zxdg_exporter_v2 *>(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->zxdg_exporter_v2_destroy_global();
        return 0;
    }

    zxdg_exporter_v2::zxdg_exporter_v2(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);
    }

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

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

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

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

        if (m_resource)
            m_resource->zxdg_exporter_v2_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 zxdg_exporter_v2::init(struct ::wl_client *client, int id, int version)
    {
        m_resource = bind(client, id, version);
    }

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

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

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

    zxdg_exporter_v2::Resource *zxdg_exporter_v2::add(struct ::wl_resource *resource)
    {
        return *m_resource_map.insert(wl_resource_get_client(resource), bind(resource));
    }

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

    const struct wl_interface *zxdg_exporter_v2::interface()
    {
        return &::zxdg_exporter_v2_interface;
    }

    zxdg_exporter_v2::Resource *zxdg_exporter_v2::zxdg_exporter_v2_allocate()
    {
        return new Resource;
    }

    void zxdg_exporter_v2::zxdg_exporter_v2_destroy_global()
    {
    }

    void zxdg_exporter_v2::zxdg_exporter_v2_bind_resource(Resource *)
    {
    }

    void zxdg_exporter_v2::zxdg_exporter_v2_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void zxdg_exporter_v2::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, 300000);
    }

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

    zxdg_exporter_v2::Resource *zxdg_exporter_v2::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zxdg_exporter_v2_allocate();
        resource->zxdg_exporter_v2_object = this;

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

    const struct ::zxdg_exporter_v2_interface zxdg_exporter_v2::m_zxdg_exporter_v2_interface = {
        zxdg_exporter_v2::handle_destroy,
        zxdg_exporter_v2::handle_export_toplevel
    };

    void zxdg_exporter_v2::zxdg_exporter_v2_destroy(Resource *)
    {
    }

    void zxdg_exporter_v2::zxdg_exporter_v2_export_toplevel(Resource *, uint32_t, struct ::wl_resource *)
    {
    }


    void zxdg_exporter_v2::handle_destroy(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->zxdg_exporter_v2_object)) {
            wl_resource_destroy(resource);
            return;
        }
        static_cast<zxdg_exporter_v2 *>(qtResource->zxdg_exporter_v2_object)->zxdg_exporter_v2_destroy(
            qtResource);
    }

    void zxdg_exporter_v2::handle_export_toplevel(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id,
        struct ::wl_resource *surface)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->zxdg_exporter_v2_object)) {
            return;
        }
        static_cast<zxdg_exporter_v2 *>(qtResource->zxdg_exporter_v2_object)->zxdg_exporter_v2_export_toplevel(
            qtResource,
            id,
            surface);
    }


    int zxdg_importer_v2::deferred_destroy_global_func(void *data) {
        auto object = static_cast<zxdg_importer_v2 *>(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->zxdg_importer_v2_destroy_global();
        return 0;
    }

    zxdg_importer_v2::zxdg_importer_v2(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);
    }

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

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

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

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

        if (m_resource)
            m_resource->zxdg_importer_v2_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 zxdg_importer_v2::init(struct ::wl_client *client, int id, int version)
    {
        m_resource = bind(client, id, version);
    }

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

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

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

    zxdg_importer_v2::Resource *zxdg_importer_v2::add(struct ::wl_resource *resource)
    {
        return *m_resource_map.insert(wl_resource_get_client(resource), bind(resource));
    }

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

    const struct wl_interface *zxdg_importer_v2::interface()
    {
        return &::zxdg_importer_v2_interface;
    }

    zxdg_importer_v2::Resource *zxdg_importer_v2::zxdg_importer_v2_allocate()
    {
        return new Resource;
    }

    void zxdg_importer_v2::zxdg_importer_v2_destroy_global()
    {
    }

    void zxdg_importer_v2::zxdg_importer_v2_bind_resource(Resource *)
    {
    }

    void zxdg_importer_v2::zxdg_importer_v2_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void zxdg_importer_v2::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, 300000);
    }

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

    zxdg_importer_v2::Resource *zxdg_importer_v2::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zxdg_importer_v2_allocate();
        resource->zxdg_importer_v2_object = this;

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

    const struct ::zxdg_importer_v2_interface zxdg_importer_v2::m_zxdg_importer_v2_interface = {
        zxdg_importer_v2::handle_destroy,
        zxdg_importer_v2::handle_import_toplevel
    };

    void zxdg_importer_v2::zxdg_importer_v2_destroy(Resource *)
    {
    }

    void zxdg_importer_v2::zxdg_importer_v2_import_toplevel(Resource *, uint32_t, const QString &)
    {
    }


    void zxdg_importer_v2::handle_destroy(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->zxdg_importer_v2_object)) {
            wl_resource_destroy(resource);
            return;
        }
        static_cast<zxdg_importer_v2 *>(qtResource->zxdg_importer_v2_object)->zxdg_importer_v2_destroy(
            qtResource);
    }

    void zxdg_importer_v2::handle_import_toplevel(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id,
        const char *handle)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->zxdg_importer_v2_object)) {
            return;
        }
        static_cast<zxdg_importer_v2 *>(qtResource->zxdg_importer_v2_object)->zxdg_importer_v2_import_toplevel(
            qtResource,
            id,
            QString::fromUtf8(handle));
    }


    int zxdg_exported_v2::deferred_destroy_global_func(void *data) {
        auto object = static_cast<zxdg_exported_v2 *>(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->zxdg_exported_v2_destroy_global();
        return 0;
    }

    zxdg_exported_v2::zxdg_exported_v2(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);
    }

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

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

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

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

        if (m_resource)
            m_resource->zxdg_exported_v2_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 zxdg_exported_v2::init(struct ::wl_client *client, int id, int version)
    {
        m_resource = bind(client, id, version);
    }

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

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

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

    zxdg_exported_v2::Resource *zxdg_exported_v2::add(struct ::wl_resource *resource)
    {
        return *m_resource_map.insert(wl_resource_get_client(resource), bind(resource));
    }

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

    const struct wl_interface *zxdg_exported_v2::interface()
    {
        return &::zxdg_exported_v2_interface;
    }

    zxdg_exported_v2::Resource *zxdg_exported_v2::zxdg_exported_v2_allocate()
    {
        return new Resource;
    }

    void zxdg_exported_v2::zxdg_exported_v2_destroy_global()
    {
    }

    void zxdg_exported_v2::zxdg_exported_v2_bind_resource(Resource *)
    {
    }

    void zxdg_exported_v2::zxdg_exported_v2_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void zxdg_exported_v2::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, 300000);
    }

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

    zxdg_exported_v2::Resource *zxdg_exported_v2::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zxdg_exported_v2_allocate();
        resource->zxdg_exported_v2_object = this;

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

    const struct ::zxdg_exported_v2_interface zxdg_exported_v2::m_zxdg_exported_v2_interface = {
        zxdg_exported_v2::handle_destroy
    };

    void zxdg_exported_v2::zxdg_exported_v2_destroy(Resource *)
    {
    }


    void zxdg_exported_v2::handle_destroy(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->zxdg_exported_v2_object)) {
            wl_resource_destroy(resource);
            return;
        }
        static_cast<zxdg_exported_v2 *>(qtResource->zxdg_exported_v2_object)->zxdg_exported_v2_destroy(
            qtResource);
    }

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

    void zxdg_exported_v2::send_handle(struct ::wl_resource *resource, const QString &handle)
    {
        zxdg_exported_v2_send_handle(
            resource,
            handle.toUtf8().constData());
    }



    int zxdg_imported_v2::deferred_destroy_global_func(void *data) {
        auto object = static_cast<zxdg_imported_v2 *>(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->zxdg_imported_v2_destroy_global();
        return 0;
    }

    zxdg_imported_v2::zxdg_imported_v2(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);
    }

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

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

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

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

        if (m_resource)
            m_resource->zxdg_imported_v2_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 zxdg_imported_v2::init(struct ::wl_client *client, int id, int version)
    {
        m_resource = bind(client, id, version);
    }

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

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

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

    zxdg_imported_v2::Resource *zxdg_imported_v2::add(struct ::wl_resource *resource)
    {
        return *m_resource_map.insert(wl_resource_get_client(resource), bind(resource));
    }

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

    const struct wl_interface *zxdg_imported_v2::interface()
    {
        return &::zxdg_imported_v2_interface;
    }

    zxdg_imported_v2::Resource *zxdg_imported_v2::zxdg_imported_v2_allocate()
    {
        return new Resource;
    }

    void zxdg_imported_v2::zxdg_imported_v2_destroy_global()
    {
    }

    void zxdg_imported_v2::zxdg_imported_v2_bind_resource(Resource *)
    {
    }

    void zxdg_imported_v2::zxdg_imported_v2_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void zxdg_imported_v2::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, 300000);
    }

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

    zxdg_imported_v2::Resource *zxdg_imported_v2::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zxdg_imported_v2_allocate();
        resource->zxdg_imported_v2_object = this;

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

    const struct ::zxdg_imported_v2_interface zxdg_imported_v2::m_zxdg_imported_v2_interface = {
        zxdg_imported_v2::handle_destroy,
        zxdg_imported_v2::handle_set_parent_of
    };

    void zxdg_imported_v2::zxdg_imported_v2_destroy(Resource *)
    {
    }

    void zxdg_imported_v2::zxdg_imported_v2_set_parent_of(Resource *, struct ::wl_resource *)
    {
    }


    void zxdg_imported_v2::handle_destroy(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->zxdg_imported_v2_object)) {
            wl_resource_destroy(resource);
            return;
        }
        static_cast<zxdg_imported_v2 *>(qtResource->zxdg_imported_v2_object)->zxdg_imported_v2_destroy(
            qtResource);
    }

    void zxdg_imported_v2::handle_set_parent_of(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *surface)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->zxdg_imported_v2_object)) {
            return;
        }
        static_cast<zxdg_imported_v2 *>(qtResource->zxdg_imported_v2_object)->zxdg_imported_v2_set_parent_of(
            qtResource,
            surface);
    }

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

    void zxdg_imported_v2::send_destroyed(struct ::wl_resource *resource)
    {
        zxdg_imported_v2_send_destroyed(
            resource);
    }

}

QT_WARNING_POP
QT_END_NAMESPACE
