// This file was generated by qtwaylandscanner
// source file is /build/kwin/src/kwin-5.26.1/src/wayland/protocols/wlr-layer-shell-unstable-v1.xml

#include "qwayland-server-wlr-layer-shell-unstable-v1.h"

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

namespace QtWaylandServer {

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

    zwlr_layer_shell_v1::zwlr_layer_shell_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);
    }

    zwlr_layer_shell_v1::zwlr_layer_shell_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);
    }

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

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

    zwlr_layer_shell_v1::~zwlr_layer_shell_v1()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->zwlr_layer_shell_v1_object = nullptr;

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

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

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

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

    const struct wl_interface *zwlr_layer_shell_v1::interface()
    {
        return &::zwlr_layer_shell_v1_interface;
    }

    zwlr_layer_shell_v1::Resource *zwlr_layer_shell_v1::zwlr_layer_shell_v1_allocate()
    {
        return new Resource;
    }

    void zwlr_layer_shell_v1::zwlr_layer_shell_v1_destroy_global()
    {
    }

    void zwlr_layer_shell_v1::zwlr_layer_shell_v1_bind_resource(Resource *)
    {
    }

    void zwlr_layer_shell_v1::zwlr_layer_shell_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


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

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

    zwlr_layer_shell_v1::Resource *zwlr_layer_shell_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwlr_layer_shell_v1_allocate();
        resource->zwlr_layer_shell_v1_object = this;

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

    const struct ::zwlr_layer_shell_v1_interface zwlr_layer_shell_v1::m_zwlr_layer_shell_v1_interface = {
        zwlr_layer_shell_v1::handle_get_layer_surface,
        zwlr_layer_shell_v1::handle_destroy
    };

    void zwlr_layer_shell_v1::zwlr_layer_shell_v1_get_layer_surface(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *, uint32_t , const QString &)
    {
    }

    void zwlr_layer_shell_v1::zwlr_layer_shell_v1_destroy(Resource *)
    {
    }


    void zwlr_layer_shell_v1::handle_get_layer_surface(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id,
        struct ::wl_resource *surface,
        struct ::wl_resource *output,
        uint32_t layer,
        const char *scope)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwlr_layer_shell_v1_object)) {
            return;
        }
        static_cast<zwlr_layer_shell_v1 *>(r->zwlr_layer_shell_v1_object)->zwlr_layer_shell_v1_get_layer_surface(
            r,
            id,
            surface,
            output,
            layer,
            QString::fromUtf8(scope));
    }

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


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

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

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

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

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

    zwlr_layer_surface_v1::~zwlr_layer_surface_v1()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->zwlr_layer_surface_v1_object = nullptr;

        if (m_resource)
            m_resource->zwlr_layer_surface_v1_object = nullptr;

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

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

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

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

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

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

    const struct wl_interface *zwlr_layer_surface_v1::interface()
    {
        return &::zwlr_layer_surface_v1_interface;
    }

    zwlr_layer_surface_v1::Resource *zwlr_layer_surface_v1::zwlr_layer_surface_v1_allocate()
    {
        return new Resource;
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_destroy_global()
    {
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_bind_resource(Resource *)
    {
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


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

        wl_global_remove(m_global);

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

    zwlr_layer_surface_v1::Resource *zwlr_layer_surface_v1::bind(struct ::wl_client *client, uint32_t id, int version)
    {
        Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData());
        struct ::wl_resource *handle = wl_resource_create(client, &::zwlr_layer_surface_v1_interface, version, id);
        return bind(handle);
    }

    zwlr_layer_surface_v1::Resource *zwlr_layer_surface_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwlr_layer_surface_v1_allocate();
        resource->zwlr_layer_surface_v1_object = this;

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

    const struct ::zwlr_layer_surface_v1_interface zwlr_layer_surface_v1::m_zwlr_layer_surface_v1_interface = {
        zwlr_layer_surface_v1::handle_set_size,
        zwlr_layer_surface_v1::handle_set_anchor,
        zwlr_layer_surface_v1::handle_set_exclusive_zone,
        zwlr_layer_surface_v1::handle_set_margin,
        zwlr_layer_surface_v1::handle_set_keyboard_interactivity,
        zwlr_layer_surface_v1::handle_get_popup,
        zwlr_layer_surface_v1::handle_ack_configure,
        zwlr_layer_surface_v1::handle_destroy,
        zwlr_layer_surface_v1::handle_set_layer
    };

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_set_size(Resource *, uint32_t , uint32_t )
    {
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_set_anchor(Resource *, uint32_t )
    {
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_set_exclusive_zone(Resource *, int32_t )
    {
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_set_margin(Resource *, int32_t , int32_t , int32_t , int32_t )
    {
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_set_keyboard_interactivity(Resource *, uint32_t )
    {
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_get_popup(Resource *, struct ::wl_resource *)
    {
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_ack_configure(Resource *, uint32_t )
    {
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_destroy(Resource *)
    {
    }

    void zwlr_layer_surface_v1::zwlr_layer_surface_v1_set_layer(Resource *, uint32_t )
    {
    }


    void zwlr_layer_surface_v1::handle_set_size(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t width,
        uint32_t height)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwlr_layer_surface_v1_object)) {
            return;
        }
        static_cast<zwlr_layer_surface_v1 *>(r->zwlr_layer_surface_v1_object)->zwlr_layer_surface_v1_set_size(
            r,
            width,
            height);
    }

    void zwlr_layer_surface_v1::handle_set_anchor(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t anchor)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwlr_layer_surface_v1_object)) {
            return;
        }
        static_cast<zwlr_layer_surface_v1 *>(r->zwlr_layer_surface_v1_object)->zwlr_layer_surface_v1_set_anchor(
            r,
            anchor);
    }

    void zwlr_layer_surface_v1::handle_set_exclusive_zone(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t zone)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwlr_layer_surface_v1_object)) {
            return;
        }
        static_cast<zwlr_layer_surface_v1 *>(r->zwlr_layer_surface_v1_object)->zwlr_layer_surface_v1_set_exclusive_zone(
            r,
            zone);
    }

    void zwlr_layer_surface_v1::handle_set_margin(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t top,
        int32_t right,
        int32_t bottom,
        int32_t left)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwlr_layer_surface_v1_object)) {
            return;
        }
        static_cast<zwlr_layer_surface_v1 *>(r->zwlr_layer_surface_v1_object)->zwlr_layer_surface_v1_set_margin(
            r,
            top,
            right,
            bottom,
            left);
    }

    void zwlr_layer_surface_v1::handle_set_keyboard_interactivity(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t keyboard_interactivity)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwlr_layer_surface_v1_object)) {
            return;
        }
        static_cast<zwlr_layer_surface_v1 *>(r->zwlr_layer_surface_v1_object)->zwlr_layer_surface_v1_set_keyboard_interactivity(
            r,
            keyboard_interactivity);
    }

    void zwlr_layer_surface_v1::handle_get_popup(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *popup)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwlr_layer_surface_v1_object)) {
            return;
        }
        static_cast<zwlr_layer_surface_v1 *>(r->zwlr_layer_surface_v1_object)->zwlr_layer_surface_v1_get_popup(
            r,
            popup);
    }

    void zwlr_layer_surface_v1::handle_ack_configure(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t serial)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwlr_layer_surface_v1_object)) {
            return;
        }
        static_cast<zwlr_layer_surface_v1 *>(r->zwlr_layer_surface_v1_object)->zwlr_layer_surface_v1_ack_configure(
            r,
            serial);
    }

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

    void zwlr_layer_surface_v1::handle_set_layer(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t layer)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwlr_layer_surface_v1_object)) {
            return;
        }
        static_cast<zwlr_layer_surface_v1 *>(r->zwlr_layer_surface_v1_object)->zwlr_layer_surface_v1_set_layer(
            r,
            layer);
    }

    void zwlr_layer_surface_v1::send_configure(uint32_t serial, uint32_t width, uint32_t height)
    {
        Q_ASSERT_X(m_resource, "zwlr_layer_surface_v1::configure", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call zwlr_layer_surface_v1::configure as it's not initialised");
            return;
        }
        send_configure(
            m_resource->handle,
            serial,
            width,
            height);
    }

    void zwlr_layer_surface_v1::send_configure(struct ::wl_resource *resource, uint32_t serial, uint32_t width, uint32_t height)
    {
        zwlr_layer_surface_v1_send_configure(
            resource,
            serial,
            width,
            height);
    }


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

    void zwlr_layer_surface_v1::send_closed(struct ::wl_resource *resource)
    {
        zwlr_layer_surface_v1_send_closed(
            resource);
    }

}

QT_WARNING_POP
QT_END_NAMESPACE
