// This file was generated by qtwaylandscanner
// source file is frog-color-management-v1.xml

#include "qwayland-server-frog-color-management-v1.h"

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

namespace QtWaylandServer {

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

    frog_color_management_factory_v1::frog_color_management_factory_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);
    }

    frog_color_management_factory_v1::frog_color_management_factory_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);
    }

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

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

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

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

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

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

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

    const struct wl_interface *frog_color_management_factory_v1::interface()
    {
        return &::frog_color_management_factory_v1_interface;
    }

    frog_color_management_factory_v1::Resource *frog_color_management_factory_v1::frog_color_management_factory_v1_allocate()
    {
        return new Resource;
    }

    void frog_color_management_factory_v1::frog_color_management_factory_v1_destroy_global()
    {
    }

    void frog_color_management_factory_v1::frog_color_management_factory_v1_bind_resource(Resource *)
    {
    }

    void frog_color_management_factory_v1::frog_color_management_factory_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


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

    frog_color_management_factory_v1::Resource *frog_color_management_factory_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, &::frog_color_management_factory_v1_interface, version, id);
        return bind(handle);
    }

    frog_color_management_factory_v1::Resource *frog_color_management_factory_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = frog_color_management_factory_v1_allocate();
        resource->frog_color_management_factory_v1_object = this;

        wl_resource_set_implementation(handle, &m_frog_color_management_factory_v1_interface, resource, destroy_func);
        resource->handle = handle;
        frog_color_management_factory_v1_bind_resource(resource);
        return resource;
    }
    frog_color_management_factory_v1::Resource *frog_color_management_factory_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::frog_color_management_factory_v1_interface, &m_frog_color_management_factory_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::frog_color_management_factory_v1_interface frog_color_management_factory_v1::m_frog_color_management_factory_v1_interface = {
        frog_color_management_factory_v1::handle_destroy,
        frog_color_management_factory_v1::handle_get_color_managed_surface
    };

    void frog_color_management_factory_v1::frog_color_management_factory_v1_destroy(Resource *)
    {
    }

    void frog_color_management_factory_v1::frog_color_management_factory_v1_get_color_managed_surface(Resource *, struct ::wl_resource *, uint32_t)
    {
    }


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

    void frog_color_management_factory_v1::handle_get_color_managed_surface(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *surface,
        uint32_t callback)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->frog_color_management_factory_v1_object)) {
            return;
        }
        static_cast<frog_color_management_factory_v1 *>(qtResource->frog_color_management_factory_v1_object)->frog_color_management_factory_v1_get_color_managed_surface(
            qtResource,
            surface,
            callback);
    }


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

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

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

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

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

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

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

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

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

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

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

    const struct wl_interface *frog_color_managed_surface::interface()
    {
        return &::frog_color_managed_surface_interface;
    }

    frog_color_managed_surface::Resource *frog_color_managed_surface::frog_color_managed_surface_allocate()
    {
        return new Resource;
    }

    void frog_color_managed_surface::frog_color_managed_surface_destroy_global()
    {
    }

    void frog_color_managed_surface::frog_color_managed_surface_bind_resource(Resource *)
    {
    }

    void frog_color_managed_surface::frog_color_managed_surface_destroy_resource(Resource *)
    {
    }

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

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

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

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


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

        wl_global_remove(m_global);

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

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

    frog_color_managed_surface::Resource *frog_color_managed_surface::bind(struct ::wl_resource *handle)
    {
        Resource *resource = frog_color_managed_surface_allocate();
        resource->frog_color_managed_surface_object = this;

        wl_resource_set_implementation(handle, &m_frog_color_managed_surface_interface, resource, destroy_func);
        resource->handle = handle;
        frog_color_managed_surface_bind_resource(resource);
        return resource;
    }
    frog_color_managed_surface::Resource *frog_color_managed_surface::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::frog_color_managed_surface_interface, &m_frog_color_managed_surface_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::frog_color_managed_surface_interface frog_color_managed_surface::m_frog_color_managed_surface_interface = {
        frog_color_managed_surface::handle_destroy,
        frog_color_managed_surface::handle_set_known_transfer_function,
        frog_color_managed_surface::handle_set_known_container_color_volume,
        frog_color_managed_surface::handle_set_render_intent,
        frog_color_managed_surface::handle_set_hdr_metadata
    };

    void frog_color_managed_surface::frog_color_managed_surface_destroy(Resource *)
    {
    }

    void frog_color_managed_surface::frog_color_managed_surface_set_known_transfer_function(Resource *, uint32_t )
    {
    }

    void frog_color_managed_surface::frog_color_managed_surface_set_known_container_color_volume(Resource *, uint32_t )
    {
    }

    void frog_color_managed_surface::frog_color_managed_surface_set_render_intent(Resource *, uint32_t )
    {
    }

    void frog_color_managed_surface::frog_color_managed_surface_set_hdr_metadata(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t , uint32_t , uint32_t , uint32_t , uint32_t , uint32_t , uint32_t , uint32_t )
    {
    }


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

    void frog_color_managed_surface::handle_set_known_transfer_function(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t transfer_function)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->frog_color_managed_surface_object)) {
            return;
        }
        static_cast<frog_color_managed_surface *>(qtResource->frog_color_managed_surface_object)->frog_color_managed_surface_set_known_transfer_function(
            qtResource,
            transfer_function);
    }

    void frog_color_managed_surface::handle_set_known_container_color_volume(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t primaries)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->frog_color_managed_surface_object)) {
            return;
        }
        static_cast<frog_color_managed_surface *>(qtResource->frog_color_managed_surface_object)->frog_color_managed_surface_set_known_container_color_volume(
            qtResource,
            primaries);
    }

    void frog_color_managed_surface::handle_set_render_intent(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t render_intent)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->frog_color_managed_surface_object)) {
            return;
        }
        static_cast<frog_color_managed_surface *>(qtResource->frog_color_managed_surface_object)->frog_color_managed_surface_set_render_intent(
            qtResource,
            render_intent);
    }

    void frog_color_managed_surface::handle_set_hdr_metadata(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t mastering_display_primary_red_x,
        uint32_t mastering_display_primary_red_y,
        uint32_t mastering_display_primary_green_x,
        uint32_t mastering_display_primary_green_y,
        uint32_t mastering_display_primary_blue_x,
        uint32_t mastering_display_primary_blue_y,
        uint32_t mastering_white_point_x,
        uint32_t mastering_white_point_y,
        uint32_t max_display_mastering_luminance,
        uint32_t min_display_mastering_luminance,
        uint32_t max_cll,
        uint32_t max_fall)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->frog_color_managed_surface_object)) {
            return;
        }
        static_cast<frog_color_managed_surface *>(qtResource->frog_color_managed_surface_object)->frog_color_managed_surface_set_hdr_metadata(
            qtResource,
            mastering_display_primary_red_x,
            mastering_display_primary_red_y,
            mastering_display_primary_green_x,
            mastering_display_primary_green_y,
            mastering_display_primary_blue_x,
            mastering_display_primary_blue_y,
            mastering_white_point_x,
            mastering_white_point_y,
            max_display_mastering_luminance,
            min_display_mastering_luminance,
            max_cll,
            max_fall);
    }

    void frog_color_managed_surface::send_preferred_metadata(uint32_t transfer_function, uint32_t output_display_primary_red_x, uint32_t output_display_primary_red_y, uint32_t output_display_primary_green_x, uint32_t output_display_primary_green_y, uint32_t output_display_primary_blue_x, uint32_t output_display_primary_blue_y, uint32_t output_white_point_x, uint32_t output_white_point_y, uint32_t max_luminance, uint32_t min_luminance, uint32_t max_full_frame_luminance)
    {
        Q_ASSERT_X(m_resource, "frog_color_managed_surface::preferred_metadata", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call frog_color_managed_surface::preferred_metadata as it's not initialised");
            return;
        }
        send_preferred_metadata(
            m_resource->handle,
            transfer_function,
            output_display_primary_red_x,
            output_display_primary_red_y,
            output_display_primary_green_x,
            output_display_primary_green_y,
            output_display_primary_blue_x,
            output_display_primary_blue_y,
            output_white_point_x,
            output_white_point_y,
            max_luminance,
            min_luminance,
            max_full_frame_luminance);
    }

    void frog_color_managed_surface::send_preferred_metadata(struct ::wl_resource *resource, uint32_t transfer_function, uint32_t output_display_primary_red_x, uint32_t output_display_primary_red_y, uint32_t output_display_primary_green_x, uint32_t output_display_primary_green_y, uint32_t output_display_primary_blue_x, uint32_t output_display_primary_blue_y, uint32_t output_white_point_x, uint32_t output_white_point_y, uint32_t max_luminance, uint32_t min_luminance, uint32_t max_full_frame_luminance)
    {
        frog_color_managed_surface_send_preferred_metadata(
            resource,
            transfer_function,
            output_display_primary_red_x,
            output_display_primary_red_y,
            output_display_primary_green_x,
            output_display_primary_green_y,
            output_display_primary_blue_x,
            output_display_primary_blue_y,
            output_white_point_x,
            output_white_point_y,
            max_luminance,
            min_luminance,
            max_full_frame_luminance);
    }

}

QT_WARNING_POP
QT_END_NAMESPACE
