// This file was generated by qtwaylandscanner
// source file is plugin-manager-v1.xml

#include "qwayland-server-plugin-manager-v1.h"

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

namespace QtWaylandServer {
    plugin_manager_v1::plugin_manager_v1(struct ::wl_client *client, uint32_t id, int version)
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
        init(client, id, version);
    }

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

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

    plugin_manager_v1::plugin_manager_v1()
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
    }

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

        if (m_resource)
            m_resource->plugin_manager_v1_object = nullptr;

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

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

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

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

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

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

    const struct wl_interface *plugin_manager_v1::interface()
    {
        return &::plugin_manager_v1_interface;
    }

    plugin_manager_v1::Resource *plugin_manager_v1::plugin_manager_v1_allocate()
    {
        return new Resource;
    }

    void plugin_manager_v1::plugin_manager_v1_bind_resource(Resource *)
    {
    }

    void plugin_manager_v1::plugin_manager_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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

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

    plugin_manager_v1::Resource *plugin_manager_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = plugin_manager_v1_allocate();
        resource->plugin_manager_v1_object = this;

        wl_resource_set_implementation(handle, &m_plugin_manager_v1_interface, resource, destroy_func);
        resource->handle = handle;
        plugin_manager_v1_bind_resource(resource);
        return resource;
    }
    plugin_manager_v1::Resource *plugin_manager_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::plugin_manager_v1_interface, &m_plugin_manager_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::plugin_manager_v1_interface plugin_manager_v1::m_plugin_manager_v1_interface = {
        plugin_manager_v1::handle_destroy,
        plugin_manager_v1::handle_request_message,
        plugin_manager_v1::handle_create_popup_at,
        plugin_manager_v1::handle_create_plugin,
        plugin_manager_v1::handle_move_xembed_window
    };

    void plugin_manager_v1::plugin_manager_v1_destroy(Resource *)
    {
    }

    void plugin_manager_v1::plugin_manager_v1_request_message(Resource *, const QString &, const QString &, const QString &)
    {
    }

    void plugin_manager_v1::plugin_manager_v1_create_popup_at(Resource *, const QString &, const QString &, int32_t , int32_t , int32_t , struct ::wl_resource *, uint32_t)
    {
    }

    void plugin_manager_v1::plugin_manager_v1_create_plugin(Resource *, const QString &, const QString &, const QString &, int32_t , int32_t , int32_t , struct ::wl_resource *, uint32_t)
    {
    }

    void plugin_manager_v1::plugin_manager_v1_move_xembed_window(Resource *, uint32_t , const QString &, const QString &, uint32_t)
    {
    }


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

    void plugin_manager_v1::handle_request_message(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *plugin_id,
        const char *item_key,
        const char *msg)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_manager_v1_object)) {
            return;
        }
        static_cast<plugin_manager_v1 *>(r->plugin_manager_v1_object)->plugin_manager_v1_request_message(
            r,
            QString::fromUtf8(plugin_id),
            QString::fromUtf8(item_key),
            QString::fromUtf8(msg));
    }

    void plugin_manager_v1::handle_create_popup_at(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *plugin_id,
        const char *item_key,
        int32_t type,
        int32_t x,
        int32_t y,
        struct ::wl_resource *surface,
        uint32_t id)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_manager_v1_object)) {
            return;
        }
        static_cast<plugin_manager_v1 *>(r->plugin_manager_v1_object)->plugin_manager_v1_create_popup_at(
            r,
            QString::fromUtf8(plugin_id),
            QString::fromUtf8(item_key),
            type,
            x,
            y,
            surface,
            id);
    }

    void plugin_manager_v1::handle_create_plugin(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *plugin_id,
        const char *item_key,
        const char *display_name,
        int32_t plugin_flags,
        int32_t type,
        int32_t size_policy,
        struct ::wl_resource *surface,
        uint32_t id)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_manager_v1_object)) {
            return;
        }
        static_cast<plugin_manager_v1 *>(r->plugin_manager_v1_object)->plugin_manager_v1_create_plugin(
            r,
            QString::fromUtf8(plugin_id),
            QString::fromUtf8(item_key),
            QString::fromUtf8(display_name),
            plugin_flags,
            type,
            size_policy,
            surface,
            id);
    }

    void plugin_manager_v1::handle_move_xembed_window(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t xembed_winid,
        const char *plugin_id,
        const char *item_key,
        uint32_t callback)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_manager_v1_object)) {
            return;
        }
        static_cast<plugin_manager_v1 *>(r->plugin_manager_v1_object)->plugin_manager_v1_move_xembed_window(
            r,
            xembed_winid,
            QString::fromUtf8(plugin_id),
            QString::fromUtf8(item_key),
            callback);
    }

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

    void plugin_manager_v1::send_position_changed(struct ::wl_resource *resource, uint32_t dock_position)
    {
        plugin_manager_v1_send_position_changed(
            resource,
            dock_position);
    }


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

    void plugin_manager_v1::send_color_theme_changed(struct ::wl_resource *resource, uint32_t dock_color_theme)
    {
        plugin_manager_v1_send_color_theme_changed(
            resource,
            dock_color_theme);
    }


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

    void plugin_manager_v1::send_active_color_changed(struct ::wl_resource *resource, const QString &active_color, const QString &dark_active_color)
    {
        plugin_manager_v1_send_active_color_changed(
            resource,
            active_color.toUtf8().constData(),
            dark_active_color.toUtf8().constData());
    }


    void plugin_manager_v1::send_font_changed(const QString &font_name, int32_t font_point_size)
    {
        Q_ASSERT_X(m_resource, "plugin_manager_v1::font_changed", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call plugin_manager_v1::font_changed as it's not initialised");
            return;
        }
        send_font_changed(
            m_resource->handle,
            font_name,
            font_point_size);
    }

    void plugin_manager_v1::send_font_changed(struct ::wl_resource *resource, const QString &font_name, int32_t font_point_size)
    {
        plugin_manager_v1_send_font_changed(
            resource,
            font_name.toUtf8().constData(),
            font_point_size);
    }


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

    void plugin_manager_v1::send_theme_changed(struct ::wl_resource *resource, const QString &theme_name, const QString &icon_theme_name)
    {
        plugin_manager_v1_send_theme_changed(
            resource,
            theme_name.toUtf8().constData(),
            icon_theme_name.toUtf8().constData());
    }


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

    void plugin_manager_v1::send_event_message(struct ::wl_resource *resource, const QString &msg)
    {
        plugin_manager_v1_send_event_message(
            resource,
            msg.toUtf8().constData());
    }


    plugin_popup::plugin_popup(struct ::wl_client *client, uint32_t id, int version)
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
        init(client, id, version);
    }

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

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

    plugin_popup::plugin_popup()
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
    }

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

        if (m_resource)
            m_resource->plugin_popup_object = nullptr;

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

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

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

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

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

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

    const struct wl_interface *plugin_popup::interface()
    {
        return &::plugin_popup_interface;
    }

    plugin_popup::Resource *plugin_popup::plugin_popup_allocate()
    {
        return new Resource;
    }

    void plugin_popup::plugin_popup_bind_resource(Resource *)
    {
    }

    void plugin_popup::plugin_popup_destroy_resource(Resource *)
    {
    }

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

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

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

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

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

    plugin_popup::Resource *plugin_popup::bind(struct ::wl_resource *handle)
    {
        Resource *resource = plugin_popup_allocate();
        resource->plugin_popup_object = this;

        wl_resource_set_implementation(handle, &m_plugin_popup_interface, resource, destroy_func);
        resource->handle = handle;
        plugin_popup_bind_resource(resource);
        return resource;
    }
    plugin_popup::Resource *plugin_popup::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::plugin_popup_interface, &m_plugin_popup_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::plugin_popup_interface plugin_popup::m_plugin_popup_interface = {
        plugin_popup::handle_destroy,
        plugin_popup::handle_set_position,
        plugin_popup::handle_source_size,
        plugin_popup::handle_set_cursor
    };

    void plugin_popup::plugin_popup_destroy(Resource *)
    {
    }

    void plugin_popup::plugin_popup_set_position(Resource *, int32_t , int32_t )
    {
    }

    void plugin_popup::plugin_popup_source_size(Resource *, int32_t , int32_t )
    {
    }

    void plugin_popup::plugin_popup_set_cursor(Resource *, int32_t )
    {
    }


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

    void plugin_popup::handle_set_position(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t x,
        int32_t y)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_popup_object)) {
            return;
        }
        static_cast<plugin_popup *>(r->plugin_popup_object)->plugin_popup_set_position(
            r,
            x,
            y);
    }

    void plugin_popup::handle_source_size(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t width,
        int32_t height)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_popup_object)) {
            return;
        }
        static_cast<plugin_popup *>(r->plugin_popup_object)->plugin_popup_source_size(
            r,
            width,
            height);
    }

    void plugin_popup::handle_set_cursor(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t cursor_shape)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_popup_object)) {
            return;
        }
        static_cast<plugin_popup *>(r->plugin_popup_object)->plugin_popup_set_cursor(
            r,
            cursor_shape);
    }

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

    void plugin_popup::send_close(struct ::wl_resource *resource)
    {
        plugin_popup_send_close(
            resource);
    }


    void plugin_popup::send_geometry(int32_t x, int32_t y, int32_t width, int32_t height)
    {
        Q_ASSERT_X(m_resource, "plugin_popup::geometry", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call plugin_popup::geometry as it's not initialised");
            return;
        }
        send_geometry(
            m_resource->handle,
            x,
            y,
            width,
            height);
    }

    void plugin_popup::send_geometry(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
    {
        plugin_popup_send_geometry(
            resource,
            x,
            y,
            width,
            height);
    }


    plugin::plugin(struct ::wl_client *client, uint32_t id, int version)
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
        init(client, id, version);
    }

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

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

    plugin::plugin()
        : m_resource_map()
        , m_resource(nullptr)
        , m_global(nullptr)
    {
    }

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

        if (m_resource)
            m_resource->plugin_object = nullptr;

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

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

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

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

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

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

    const struct wl_interface *plugin::interface()
    {
        return &::plugin_interface;
    }

    plugin::Resource *plugin::plugin_allocate()
    {
        return new Resource;
    }

    void plugin::plugin_bind_resource(Resource *)
    {
    }

    void plugin::plugin_destroy_resource(Resource *)
    {
    }

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

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

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

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

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

    plugin::Resource *plugin::bind(struct ::wl_resource *handle)
    {
        Resource *resource = plugin_allocate();
        resource->plugin_object = this;

        wl_resource_set_implementation(handle, &m_plugin_interface, resource, destroy_func);
        resource->handle = handle;
        plugin_bind_resource(resource);
        return resource;
    }
    plugin::Resource *plugin::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::plugin_interface, &m_plugin_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::plugin_interface plugin::m_plugin_interface = {
        plugin::handle_destroy,
        plugin::handle_mouse_event,
        plugin::handle_dcc_icon,
        plugin::handle_request_shutdown,
        plugin::handle_source_size,
        plugin::handle_close_quick_panel
    };

    void plugin::plugin_destroy(Resource *)
    {
    }

    void plugin::plugin_mouse_event(Resource *, int32_t )
    {
    }

    void plugin::plugin_dcc_icon(Resource *, const QString &)
    {
    }

    void plugin::plugin_request_shutdown(Resource *, const QString &)
    {
    }

    void plugin::plugin_source_size(Resource *, int32_t , int32_t )
    {
    }

    void plugin::plugin_close_quick_panel(Resource *)
    {
    }


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

    void plugin::handle_mouse_event(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t type)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_object)) {
            return;
        }
        static_cast<plugin *>(r->plugin_object)->plugin_mouse_event(
            r,
            type);
    }

    void plugin::handle_dcc_icon(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *type)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_object)) {
            return;
        }
        static_cast<plugin *>(r->plugin_object)->plugin_dcc_icon(
            r,
            QString::fromUtf8(type));
    }

    void plugin::handle_request_shutdown(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *type)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_object)) {
            return;
        }
        static_cast<plugin *>(r->plugin_object)->plugin_request_shutdown(
            r,
            QString::fromUtf8(type));
    }

    void plugin::handle_source_size(
        ::wl_client *client,
        struct wl_resource *resource,
        int32_t width,
        int32_t height)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_object)) {
            return;
        }
        static_cast<plugin *>(r->plugin_object)->plugin_source_size(
            r,
            width,
            height);
    }

    void plugin::handle_close_quick_panel(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->plugin_object)) {
            return;
        }
        static_cast<plugin *>(r->plugin_object)->plugin_close_quick_panel(
            r);
    }

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

    void plugin::send_close(struct ::wl_resource *resource)
    {
        plugin_send_close(
            resource);
    }


    void plugin::send_geometry(int32_t x, int32_t y, int32_t width, int32_t height)
    {
        Q_ASSERT_X(m_resource, "plugin::geometry", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call plugin::geometry as it's not initialised");
            return;
        }
        send_geometry(
            m_resource->handle,
            x,
            y,
            width,
            height);
    }

    void plugin::send_geometry(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
    {
        plugin_send_geometry(
            resource,
            x,
            y,
            width,
            height);
    }


    void plugin::send_margin(int32_t spacing)
    {
        Q_ASSERT_X(m_resource, "plugin::margin", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call plugin::margin as it's not initialised");
            return;
        }
        send_margin(
            m_resource->handle,
            spacing);
    }

    void plugin::send_margin(struct ::wl_resource *resource, int32_t spacing)
    {
        plugin_send_margin(
            resource,
            spacing);
    }


    void plugin::send_raw_global_pos(int32_t x, int32_t y)
    {
        Q_ASSERT_X(m_resource, "plugin::raw_global_pos", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call plugin::raw_global_pos as it's not initialised");
            return;
        }
        send_raw_global_pos(
            m_resource->handle,
            x,
            y);
    }

    void plugin::send_raw_global_pos(struct ::wl_resource *resource, int32_t x, int32_t y)
    {
        plugin_send_raw_global_pos(
            resource,
            x,
            y);
    }

}

QT_WARNING_POP
QT_END_NAMESPACE
