// This file was generated by qtwaylandscanner
// source file is /usr/share/plasma-wayland-protocols/kde-output-management-v2.xml

#include "qwayland-server-kde-output-management-v2.h"

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

namespace QtWaylandServer {

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

    kde_output_management_v2::kde_output_management_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);
    }

    kde_output_management_v2::kde_output_management_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);
    }

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

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

    kde_output_management_v2::~kde_output_management_v2()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->kde_output_management_v2_object = nullptr;

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

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

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

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

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

    const struct wl_interface *kde_output_management_v2::interface()
    {
        return &::kde_output_management_v2_interface;
    }

    kde_output_management_v2::Resource *kde_output_management_v2::kde_output_management_v2_allocate()
    {
        return new Resource;
    }

    void kde_output_management_v2::kde_output_management_v2_destroy_global()
    {
    }

    void kde_output_management_v2::kde_output_management_v2_bind_resource(Resource *)
    {
    }

    void kde_output_management_v2::kde_output_management_v2_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void kde_output_management_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, 5000);
    }

    kde_output_management_v2::Resource *kde_output_management_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, &::kde_output_management_v2_interface, version, id);
        return bind(handle);
    }

    kde_output_management_v2::Resource *kde_output_management_v2::bind(struct ::wl_resource *handle)
    {
        Resource *resource = kde_output_management_v2_allocate();
        resource->kde_output_management_v2_object = this;

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

    const struct ::kde_output_management_v2_interface kde_output_management_v2::m_kde_output_management_v2_interface = {
        kde_output_management_v2::handle_create_configuration
    };

    void kde_output_management_v2::kde_output_management_v2_create_configuration(Resource *, uint32_t)
    {
    }


    void kde_output_management_v2::handle_create_configuration(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_management_v2_object)) {
            return;
        }
        static_cast<kde_output_management_v2 *>(r->kde_output_management_v2_object)->kde_output_management_v2_create_configuration(
            r,
            id);
    }


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

    kde_output_configuration_v2::kde_output_configuration_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);
    }

    kde_output_configuration_v2::kde_output_configuration_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);
    }

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

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

    kde_output_configuration_v2::~kde_output_configuration_v2()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->kde_output_configuration_v2_object = nullptr;

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

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

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

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

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

    const struct wl_interface *kde_output_configuration_v2::interface()
    {
        return &::kde_output_configuration_v2_interface;
    }

    kde_output_configuration_v2::Resource *kde_output_configuration_v2::kde_output_configuration_v2_allocate()
    {
        return new Resource;
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_destroy_global()
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_bind_resource(Resource *)
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_destroy_resource(Resource *)
    {
    }

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

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

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

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


    void kde_output_configuration_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, 5000);
    }

    kde_output_configuration_v2::Resource *kde_output_configuration_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, &::kde_output_configuration_v2_interface, version, id);
        return bind(handle);
    }

    kde_output_configuration_v2::Resource *kde_output_configuration_v2::bind(struct ::wl_resource *handle)
    {
        Resource *resource = kde_output_configuration_v2_allocate();
        resource->kde_output_configuration_v2_object = this;

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

    const struct ::kde_output_configuration_v2_interface kde_output_configuration_v2::m_kde_output_configuration_v2_interface = {
        kde_output_configuration_v2::handle_enable,
        kde_output_configuration_v2::handle_mode,
        kde_output_configuration_v2::handle_transform,
        kde_output_configuration_v2::handle_position,
        kde_output_configuration_v2::handle_scale,
        kde_output_configuration_v2::handle_apply,
        kde_output_configuration_v2::handle_destroy,
        kde_output_configuration_v2::handle_overscan,
        kde_output_configuration_v2::handle_set_vrr_policy,
        kde_output_configuration_v2::handle_set_rgb_range,
        kde_output_configuration_v2::handle_set_primary_output
    };

    void kde_output_configuration_v2::kde_output_configuration_v2_enable(Resource *, struct ::wl_resource *, int32_t )
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_mode(Resource *, struct ::wl_resource *, struct ::wl_resource *)
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_transform(Resource *, struct ::wl_resource *, int32_t )
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_position(Resource *, struct ::wl_resource *, int32_t , int32_t )
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_scale(Resource *, struct ::wl_resource *, wl_fixed_t )
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_apply(Resource *)
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_destroy(Resource *)
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_overscan(Resource *, struct ::wl_resource *, uint32_t )
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_set_vrr_policy(Resource *, struct ::wl_resource *, uint32_t )
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_set_rgb_range(Resource *, struct ::wl_resource *, uint32_t )
    {
    }

    void kde_output_configuration_v2::kde_output_configuration_v2_set_primary_output(Resource *, struct ::wl_resource *)
    {
    }


    void kde_output_configuration_v2::handle_enable(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *outputdevice,
        int32_t enable)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_configuration_v2_object)) {
            return;
        }
        static_cast<kde_output_configuration_v2 *>(r->kde_output_configuration_v2_object)->kde_output_configuration_v2_enable(
            r,
            outputdevice,
            enable);
    }

    void kde_output_configuration_v2::handle_mode(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *outputdevice,
        struct ::wl_resource *mode)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_configuration_v2_object)) {
            return;
        }
        static_cast<kde_output_configuration_v2 *>(r->kde_output_configuration_v2_object)->kde_output_configuration_v2_mode(
            r,
            outputdevice,
            mode);
    }

    void kde_output_configuration_v2::handle_transform(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *outputdevice,
        int32_t transform)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_configuration_v2_object)) {
            return;
        }
        static_cast<kde_output_configuration_v2 *>(r->kde_output_configuration_v2_object)->kde_output_configuration_v2_transform(
            r,
            outputdevice,
            transform);
    }

    void kde_output_configuration_v2::handle_position(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *outputdevice,
        int32_t x,
        int32_t y)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_configuration_v2_object)) {
            return;
        }
        static_cast<kde_output_configuration_v2 *>(r->kde_output_configuration_v2_object)->kde_output_configuration_v2_position(
            r,
            outputdevice,
            x,
            y);
    }

    void kde_output_configuration_v2::handle_scale(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *outputdevice,
        wl_fixed_t scale)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_configuration_v2_object)) {
            return;
        }
        static_cast<kde_output_configuration_v2 *>(r->kde_output_configuration_v2_object)->kde_output_configuration_v2_scale(
            r,
            outputdevice,
            scale);
    }

    void kde_output_configuration_v2::handle_apply(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_configuration_v2_object)) {
            return;
        }
        static_cast<kde_output_configuration_v2 *>(r->kde_output_configuration_v2_object)->kde_output_configuration_v2_apply(
            r);
    }

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

    void kde_output_configuration_v2::handle_overscan(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *outputdevice,
        uint32_t overscan)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_configuration_v2_object)) {
            return;
        }
        static_cast<kde_output_configuration_v2 *>(r->kde_output_configuration_v2_object)->kde_output_configuration_v2_overscan(
            r,
            outputdevice,
            overscan);
    }

    void kde_output_configuration_v2::handle_set_vrr_policy(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *outputdevice,
        uint32_t policy)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_configuration_v2_object)) {
            return;
        }
        static_cast<kde_output_configuration_v2 *>(r->kde_output_configuration_v2_object)->kde_output_configuration_v2_set_vrr_policy(
            r,
            outputdevice,
            policy);
    }

    void kde_output_configuration_v2::handle_set_rgb_range(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *outputdevice,
        uint32_t rgb_range)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_configuration_v2_object)) {
            return;
        }
        static_cast<kde_output_configuration_v2 *>(r->kde_output_configuration_v2_object)->kde_output_configuration_v2_set_rgb_range(
            r,
            outputdevice,
            rgb_range);
    }

    void kde_output_configuration_v2::handle_set_primary_output(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *output)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->kde_output_configuration_v2_object)) {
            return;
        }
        static_cast<kde_output_configuration_v2 *>(r->kde_output_configuration_v2_object)->kde_output_configuration_v2_set_primary_output(
            r,
            output);
    }

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

    void kde_output_configuration_v2::send_applied(struct ::wl_resource *resource)
    {
        kde_output_configuration_v2_send_applied(
            resource);
    }


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

    void kde_output_configuration_v2::send_failed(struct ::wl_resource *resource)
    {
        kde_output_configuration_v2_send_failed(
            resource);
    }

}

QT_WARNING_POP
QT_END_NAMESPACE
