// This file was generated by qtwaylandscanner
// source file is zkde-screencast-unstable-v1.xml

#include "qwayland-server-zkde-screencast-unstable-v1.h"

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

namespace QtWaylandServer {

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

    zkde_screencast_unstable_v1::zkde_screencast_unstable_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);
    }

    zkde_screencast_unstable_v1::zkde_screencast_unstable_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);
    }

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

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

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

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

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

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

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

    const struct wl_interface *zkde_screencast_unstable_v1::interface()
    {
        return &::zkde_screencast_unstable_v1_interface;
    }

    zkde_screencast_unstable_v1::Resource *zkde_screencast_unstable_v1::zkde_screencast_unstable_v1_allocate()
    {
        return new Resource;
    }

    void zkde_screencast_unstable_v1::zkde_screencast_unstable_v1_destroy_global()
    {
    }

    void zkde_screencast_unstable_v1::zkde_screencast_unstable_v1_bind_resource(Resource *)
    {
    }

    void zkde_screencast_unstable_v1::zkde_screencast_unstable_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


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

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

    zkde_screencast_unstable_v1::Resource *zkde_screencast_unstable_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zkde_screencast_unstable_v1_allocate();
        resource->zkde_screencast_unstable_v1_object = this;

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

    const struct ::zkde_screencast_unstable_v1_interface zkde_screencast_unstable_v1::m_zkde_screencast_unstable_v1_interface = {
        zkde_screencast_unstable_v1::handle_stream_output,
        zkde_screencast_unstable_v1::handle_stream_window,
        zkde_screencast_unstable_v1::handle_destroy,
        zkde_screencast_unstable_v1::handle_stream_virtual_output,
        zkde_screencast_unstable_v1::handle_stream_region,
        zkde_screencast_unstable_v1::handle_stream_virtual_output_with_description
    };

    void zkde_screencast_unstable_v1::zkde_screencast_unstable_v1_stream_output(Resource *, uint32_t, struct ::wl_resource *, uint32_t )
    {
    }

    void zkde_screencast_unstable_v1::zkde_screencast_unstable_v1_stream_window(Resource *, uint32_t, const QString &, uint32_t )
    {
    }

    void zkde_screencast_unstable_v1::zkde_screencast_unstable_v1_destroy(Resource *)
    {
    }

    void zkde_screencast_unstable_v1::zkde_screencast_unstable_v1_stream_virtual_output(Resource *, uint32_t, const QString &, int32_t , int32_t , wl_fixed_t , uint32_t )
    {
    }

    void zkde_screencast_unstable_v1::zkde_screencast_unstable_v1_stream_region(Resource *, uint32_t, int32_t , int32_t , uint32_t , uint32_t , wl_fixed_t , uint32_t )
    {
    }

    void zkde_screencast_unstable_v1::zkde_screencast_unstable_v1_stream_virtual_output_with_description(Resource *, uint32_t, const QString &, const QString &, int32_t , int32_t , wl_fixed_t , uint32_t )
    {
    }


    void zkde_screencast_unstable_v1::handle_stream_output(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t stream,
        struct ::wl_resource *output,
        uint32_t pointer)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zkde_screencast_unstable_v1_object)) {
            return;
        }
        static_cast<zkde_screencast_unstable_v1 *>(r->zkde_screencast_unstable_v1_object)->zkde_screencast_unstable_v1_stream_output(
            r,
            stream,
            output,
            pointer);
    }

    void zkde_screencast_unstable_v1::handle_stream_window(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t stream,
        const char *window_uuid,
        uint32_t pointer)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zkde_screencast_unstable_v1_object)) {
            return;
        }
        static_cast<zkde_screencast_unstable_v1 *>(r->zkde_screencast_unstable_v1_object)->zkde_screencast_unstable_v1_stream_window(
            r,
            stream,
            QString::fromUtf8(window_uuid),
            pointer);
    }

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

    void zkde_screencast_unstable_v1::handle_stream_virtual_output(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t stream,
        const char *name,
        int32_t width,
        int32_t height,
        wl_fixed_t scale,
        uint32_t pointer)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zkde_screencast_unstable_v1_object)) {
            return;
        }
        static_cast<zkde_screencast_unstable_v1 *>(r->zkde_screencast_unstable_v1_object)->zkde_screencast_unstable_v1_stream_virtual_output(
            r,
            stream,
            QString::fromUtf8(name),
            width,
            height,
            scale,
            pointer);
    }

    void zkde_screencast_unstable_v1::handle_stream_region(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t stream,
        int32_t x,
        int32_t y,
        uint32_t width,
        uint32_t height,
        wl_fixed_t scale,
        uint32_t pointer)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zkde_screencast_unstable_v1_object)) {
            return;
        }
        static_cast<zkde_screencast_unstable_v1 *>(r->zkde_screencast_unstable_v1_object)->zkde_screencast_unstable_v1_stream_region(
            r,
            stream,
            x,
            y,
            width,
            height,
            scale,
            pointer);
    }

    void zkde_screencast_unstable_v1::handle_stream_virtual_output_with_description(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t stream,
        const char *name,
        const char *description,
        int32_t width,
        int32_t height,
        wl_fixed_t scale,
        uint32_t pointer)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zkde_screencast_unstable_v1_object)) {
            return;
        }
        static_cast<zkde_screencast_unstable_v1 *>(r->zkde_screencast_unstable_v1_object)->zkde_screencast_unstable_v1_stream_virtual_output_with_description(
            r,
            stream,
            QString::fromUtf8(name),
            QString::fromUtf8(description),
            width,
            height,
            scale,
            pointer);
    }


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

    zkde_screencast_stream_unstable_v1::zkde_screencast_stream_unstable_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);
    }

    zkde_screencast_stream_unstable_v1::zkde_screencast_stream_unstable_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);
    }

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

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

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

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

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

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

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

    const struct wl_interface *zkde_screencast_stream_unstable_v1::interface()
    {
        return &::zkde_screencast_stream_unstable_v1_interface;
    }

    zkde_screencast_stream_unstable_v1::Resource *zkde_screencast_stream_unstable_v1::zkde_screencast_stream_unstable_v1_allocate()
    {
        return new Resource;
    }

    void zkde_screencast_stream_unstable_v1::zkde_screencast_stream_unstable_v1_destroy_global()
    {
    }

    void zkde_screencast_stream_unstable_v1::zkde_screencast_stream_unstable_v1_bind_resource(Resource *)
    {
    }

    void zkde_screencast_stream_unstable_v1::zkde_screencast_stream_unstable_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


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

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

    zkde_screencast_stream_unstable_v1::Resource *zkde_screencast_stream_unstable_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zkde_screencast_stream_unstable_v1_allocate();
        resource->zkde_screencast_stream_unstable_v1_object = this;

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

    const struct ::zkde_screencast_stream_unstable_v1_interface zkde_screencast_stream_unstable_v1::m_zkde_screencast_stream_unstable_v1_interface = {
        zkde_screencast_stream_unstable_v1::handle_close
    };

    void zkde_screencast_stream_unstable_v1::zkde_screencast_stream_unstable_v1_close(Resource *)
    {
    }


    void zkde_screencast_stream_unstable_v1::handle_close(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zkde_screencast_stream_unstable_v1_object)) {
            wl_resource_destroy(resource);
            return;
        }
        static_cast<zkde_screencast_stream_unstable_v1 *>(r->zkde_screencast_stream_unstable_v1_object)->zkde_screencast_stream_unstable_v1_close(
            r);
    }

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

    void zkde_screencast_stream_unstable_v1::send_closed(struct ::wl_resource *resource)
    {
        zkde_screencast_stream_unstable_v1_send_closed(
            resource);
    }


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

    void zkde_screencast_stream_unstable_v1::send_created(struct ::wl_resource *resource, uint32_t node)
    {
        zkde_screencast_stream_unstable_v1_send_created(
            resource,
            node);
    }


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

    void zkde_screencast_stream_unstable_v1::send_failed(struct ::wl_resource *resource, const QString &error)
    {
        zkde_screencast_stream_unstable_v1_send_failed(
            resource,
            error.toUtf8().constData());
    }


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

    void zkde_screencast_stream_unstable_v1::send_serial(struct ::wl_resource *resource, uint32_t object_serial_hi, uint32_t object_serial_low)
    {
        zkde_screencast_stream_unstable_v1_send_serial(
            resource,
            object_serial_hi,
            object_serial_low);
    }

}

QT_WARNING_POP
QT_END_NAMESPACE
