// This file was generated by qtwaylandscanner
// source file is //usr/share/wayland-protocols/staging/drm-lease/drm-lease-v1.xml

#include "qwayland-server-drm-lease-v1.h"

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

namespace QtWaylandServer {

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

    wp_drm_lease_device_v1::wp_drm_lease_device_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);
    }

    wp_drm_lease_device_v1::wp_drm_lease_device_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);
    }

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

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

    wp_drm_lease_device_v1::~wp_drm_lease_device_v1()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->wp_drm_lease_device_v1_object = nullptr;

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

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

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

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

    const struct wl_interface *wp_drm_lease_device_v1::interface()
    {
        return &::wp_drm_lease_device_v1_interface;
    }

    wp_drm_lease_device_v1::Resource *wp_drm_lease_device_v1::wp_drm_lease_device_v1_allocate()
    {
        return new Resource;
    }

    void wp_drm_lease_device_v1::wp_drm_lease_device_v1_destroy_global()
    {
    }

    void wp_drm_lease_device_v1::wp_drm_lease_device_v1_bind_resource(Resource *)
    {
    }

    void wp_drm_lease_device_v1::wp_drm_lease_device_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void wp_drm_lease_device_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);
    }

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

    wp_drm_lease_device_v1::Resource *wp_drm_lease_device_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = wp_drm_lease_device_v1_allocate();
        resource->wp_drm_lease_device_v1_object = this;

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

    const struct ::wp_drm_lease_device_v1_interface wp_drm_lease_device_v1::m_wp_drm_lease_device_v1_interface = {
        wp_drm_lease_device_v1::handle_create_lease_request,
        wp_drm_lease_device_v1::handle_release
    };

    void wp_drm_lease_device_v1::wp_drm_lease_device_v1_create_lease_request(Resource *, uint32_t)
    {
    }

    void wp_drm_lease_device_v1::wp_drm_lease_device_v1_release(Resource *)
    {
    }


    void wp_drm_lease_device_v1::handle_create_lease_request(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->wp_drm_lease_device_v1_object)) {
            return;
        }
        static_cast<wp_drm_lease_device_v1 *>(r->wp_drm_lease_device_v1_object)->wp_drm_lease_device_v1_create_lease_request(
            r,
            id);
    }

    void wp_drm_lease_device_v1::handle_release(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->wp_drm_lease_device_v1_object)) {
            return;
        }
        static_cast<wp_drm_lease_device_v1 *>(r->wp_drm_lease_device_v1_object)->wp_drm_lease_device_v1_release(
            r);
    }

    void wp_drm_lease_device_v1::send_drm_fd(int32_t fd)
    {
        Q_ASSERT_X(m_resource, "wp_drm_lease_device_v1::drm_fd", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call wp_drm_lease_device_v1::drm_fd as it's not initialised");
            return;
        }
        send_drm_fd(
            m_resource->handle,
            fd);
    }

    void wp_drm_lease_device_v1::send_drm_fd(struct ::wl_resource *resource, int32_t fd)
    {
        wp_drm_lease_device_v1_send_drm_fd(
            resource,
            fd);
    }


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

    void wp_drm_lease_device_v1::send_connector(struct ::wl_resource *resource, struct ::wl_resource *id)
    {
        wp_drm_lease_device_v1_send_connector(
            resource,
            id);
    }


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

    void wp_drm_lease_device_v1::send_done(struct ::wl_resource *resource)
    {
        wp_drm_lease_device_v1_send_done(
            resource);
    }


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

    void wp_drm_lease_device_v1::send_released(struct ::wl_resource *resource)
    {
        wp_drm_lease_device_v1_send_released(
            resource);
    }



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

    wp_drm_lease_connector_v1::wp_drm_lease_connector_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);
    }

    wp_drm_lease_connector_v1::wp_drm_lease_connector_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);
    }

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

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

    wp_drm_lease_connector_v1::~wp_drm_lease_connector_v1()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->wp_drm_lease_connector_v1_object = nullptr;

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

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

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

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

    const struct wl_interface *wp_drm_lease_connector_v1::interface()
    {
        return &::wp_drm_lease_connector_v1_interface;
    }

    wp_drm_lease_connector_v1::Resource *wp_drm_lease_connector_v1::wp_drm_lease_connector_v1_allocate()
    {
        return new Resource;
    }

    void wp_drm_lease_connector_v1::wp_drm_lease_connector_v1_destroy_global()
    {
    }

    void wp_drm_lease_connector_v1::wp_drm_lease_connector_v1_bind_resource(Resource *)
    {
    }

    void wp_drm_lease_connector_v1::wp_drm_lease_connector_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void wp_drm_lease_connector_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);
    }

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

    wp_drm_lease_connector_v1::Resource *wp_drm_lease_connector_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = wp_drm_lease_connector_v1_allocate();
        resource->wp_drm_lease_connector_v1_object = this;

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

    const struct ::wp_drm_lease_connector_v1_interface wp_drm_lease_connector_v1::m_wp_drm_lease_connector_v1_interface = {
        wp_drm_lease_connector_v1::handle_destroy
    };

    void wp_drm_lease_connector_v1::wp_drm_lease_connector_v1_destroy(Resource *)
    {
    }


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

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

    void wp_drm_lease_connector_v1::send_name(struct ::wl_resource *resource, const QString &name)
    {
        wp_drm_lease_connector_v1_send_name(
            resource,
            name.toUtf8().constData());
    }


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

    void wp_drm_lease_connector_v1::send_description(struct ::wl_resource *resource, const QString &description)
    {
        wp_drm_lease_connector_v1_send_description(
            resource,
            description.toUtf8().constData());
    }


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

    void wp_drm_lease_connector_v1::send_connector_id(struct ::wl_resource *resource, uint32_t connector_id)
    {
        wp_drm_lease_connector_v1_send_connector_id(
            resource,
            connector_id);
    }


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

    void wp_drm_lease_connector_v1::send_done(struct ::wl_resource *resource)
    {
        wp_drm_lease_connector_v1_send_done(
            resource);
    }


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

    void wp_drm_lease_connector_v1::send_withdrawn(struct ::wl_resource *resource)
    {
        wp_drm_lease_connector_v1_send_withdrawn(
            resource);
    }



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

    wp_drm_lease_request_v1::wp_drm_lease_request_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);
    }

    wp_drm_lease_request_v1::wp_drm_lease_request_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);
    }

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

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

    wp_drm_lease_request_v1::~wp_drm_lease_request_v1()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->wp_drm_lease_request_v1_object = nullptr;

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

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

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

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

    const struct wl_interface *wp_drm_lease_request_v1::interface()
    {
        return &::wp_drm_lease_request_v1_interface;
    }

    wp_drm_lease_request_v1::Resource *wp_drm_lease_request_v1::wp_drm_lease_request_v1_allocate()
    {
        return new Resource;
    }

    void wp_drm_lease_request_v1::wp_drm_lease_request_v1_destroy_global()
    {
    }

    void wp_drm_lease_request_v1::wp_drm_lease_request_v1_bind_resource(Resource *)
    {
    }

    void wp_drm_lease_request_v1::wp_drm_lease_request_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void wp_drm_lease_request_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);
    }

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

    wp_drm_lease_request_v1::Resource *wp_drm_lease_request_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = wp_drm_lease_request_v1_allocate();
        resource->wp_drm_lease_request_v1_object = this;

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

    const struct ::wp_drm_lease_request_v1_interface wp_drm_lease_request_v1::m_wp_drm_lease_request_v1_interface = {
        wp_drm_lease_request_v1::handle_request_connector,
        wp_drm_lease_request_v1::handle_submit
    };

    void wp_drm_lease_request_v1::wp_drm_lease_request_v1_request_connector(Resource *, struct ::wl_resource *)
    {
    }

    void wp_drm_lease_request_v1::wp_drm_lease_request_v1_submit(Resource *, uint32_t)
    {
    }


    void wp_drm_lease_request_v1::handle_request_connector(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *connector)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->wp_drm_lease_request_v1_object)) {
            return;
        }
        static_cast<wp_drm_lease_request_v1 *>(r->wp_drm_lease_request_v1_object)->wp_drm_lease_request_v1_request_connector(
            r,
            connector);
    }

    void wp_drm_lease_request_v1::handle_submit(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->wp_drm_lease_request_v1_object)) {
            wl_resource_destroy(resource);
            return;
        }
        static_cast<wp_drm_lease_request_v1 *>(r->wp_drm_lease_request_v1_object)->wp_drm_lease_request_v1_submit(
            r,
            id);
    }


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

    wp_drm_lease_v1::wp_drm_lease_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);
    }

    wp_drm_lease_v1::wp_drm_lease_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);
    }

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

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

    wp_drm_lease_v1::~wp_drm_lease_v1()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->wp_drm_lease_v1_object = nullptr;

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

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

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

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

    const struct wl_interface *wp_drm_lease_v1::interface()
    {
        return &::wp_drm_lease_v1_interface;
    }

    wp_drm_lease_v1::Resource *wp_drm_lease_v1::wp_drm_lease_v1_allocate()
    {
        return new Resource;
    }

    void wp_drm_lease_v1::wp_drm_lease_v1_destroy_global()
    {
    }

    void wp_drm_lease_v1::wp_drm_lease_v1_bind_resource(Resource *)
    {
    }

    void wp_drm_lease_v1::wp_drm_lease_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void wp_drm_lease_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);
    }

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

    wp_drm_lease_v1::Resource *wp_drm_lease_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = wp_drm_lease_v1_allocate();
        resource->wp_drm_lease_v1_object = this;

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

    const struct ::wp_drm_lease_v1_interface wp_drm_lease_v1::m_wp_drm_lease_v1_interface = {
        wp_drm_lease_v1::handle_destroy
    };

    void wp_drm_lease_v1::wp_drm_lease_v1_destroy(Resource *)
    {
    }


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

    void wp_drm_lease_v1::send_lease_fd(int32_t leased_fd)
    {
        Q_ASSERT_X(m_resource, "wp_drm_lease_v1::lease_fd", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call wp_drm_lease_v1::lease_fd as it's not initialised");
            return;
        }
        send_lease_fd(
            m_resource->handle,
            leased_fd);
    }

    void wp_drm_lease_v1::send_lease_fd(struct ::wl_resource *resource, int32_t leased_fd)
    {
        wp_drm_lease_v1_send_lease_fd(
            resource,
            leased_fd);
    }


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

    void wp_drm_lease_v1::send_finished(struct ::wl_resource *resource)
    {
        wp_drm_lease_v1_send_finished(
            resource);
    }

}

QT_WARNING_POP
QT_END_NAMESPACE
