// This file was generated by qtwaylandscanner
// source file is /usr/share/treeland-protocols/treeland-foreign-toplevel-manager-v1.xml

#include "qwayland-server-treeland-foreign-toplevel-manager-v1.h"

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

namespace QtWaylandServer {

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

    treeland_foreign_toplevel_manager_v1::treeland_foreign_toplevel_manager_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);
    }

    treeland_foreign_toplevel_manager_v1::treeland_foreign_toplevel_manager_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);
    }

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

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

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

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

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

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

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

    const struct wl_interface *treeland_foreign_toplevel_manager_v1::interface()
    {
        return &::treeland_foreign_toplevel_manager_v1_interface;
    }

    treeland_foreign_toplevel_manager_v1::Resource *treeland_foreign_toplevel_manager_v1::allocate()
    {
        return new Resource;
    }

    void treeland_foreign_toplevel_manager_v1::destroy_global()
    {
    }

    void treeland_foreign_toplevel_manager_v1::bind_resource(Resource *)
    {
    }

    void treeland_foreign_toplevel_manager_v1::destroy_resource(Resource *)
    {
    }

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

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

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

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


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

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

    treeland_foreign_toplevel_manager_v1::Resource *treeland_foreign_toplevel_manager_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = allocate();
        resource->treeland_foreign_toplevel_manager_v1_object = this;

        wl_resource_set_implementation(handle, &m_treeland_foreign_toplevel_manager_v1_interface, resource, destroy_func);
        resource->handle = handle;
        bind_resource(resource);
        return resource;
    }
    treeland_foreign_toplevel_manager_v1::Resource *treeland_foreign_toplevel_manager_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::treeland_foreign_toplevel_manager_v1_interface, &m_treeland_foreign_toplevel_manager_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::treeland_foreign_toplevel_manager_v1_interface treeland_foreign_toplevel_manager_v1::m_treeland_foreign_toplevel_manager_v1_interface = {
        treeland_foreign_toplevel_manager_v1::handle_stop,
        treeland_foreign_toplevel_manager_v1::handle_get_dock_preview_context
    };

    void treeland_foreign_toplevel_manager_v1::stop(Resource *resource)
    {
        Q_UNUSED(resource);
    }

    void treeland_foreign_toplevel_manager_v1::get_dock_preview_context(Resource *resource, struct ::wl_resource *relative_surface, uint32_t id)
    {
        Q_UNUSED(resource);
        Q_UNUSED(relative_surface);
        Q_UNUSED(id);
    }


    void treeland_foreign_toplevel_manager_v1::handle_stop(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_manager_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_manager_v1 *>(qResource->treeland_foreign_toplevel_manager_v1_object)->stop(
            qResource);
    }

    void treeland_foreign_toplevel_manager_v1::handle_get_dock_preview_context(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *relative_surface,
        uint32_t id)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_manager_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_manager_v1 *>(qResource->treeland_foreign_toplevel_manager_v1_object)->get_dock_preview_context(
            qResource,
            relative_surface,
            id);
    }

    void treeland_foreign_toplevel_manager_v1::send_toplevel(struct ::wl_resource *toplevel)
    {
        Q_ASSERT_X(m_resource, "treeland_foreign_toplevel_manager_v1::toplevel", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call treeland_foreign_toplevel_manager_v1::toplevel as it's not initialised");
            return;
        }
        send_toplevel(
            m_resource->handle,
            toplevel);
    }

    void treeland_foreign_toplevel_manager_v1::send_toplevel(struct ::wl_resource *resource, struct ::wl_resource *toplevel)
    {
        treeland_foreign_toplevel_manager_v1_send_toplevel(
            resource,
            toplevel);
    }


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

    void treeland_foreign_toplevel_manager_v1::send_finished(struct ::wl_resource *resource)
    {
        treeland_foreign_toplevel_manager_v1_send_finished(
            resource);
    }



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

    treeland_foreign_toplevel_handle_v1::treeland_foreign_toplevel_handle_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);
    }

    treeland_foreign_toplevel_handle_v1::treeland_foreign_toplevel_handle_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);
    }

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

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

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

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

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

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

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

    const struct wl_interface *treeland_foreign_toplevel_handle_v1::interface()
    {
        return &::treeland_foreign_toplevel_handle_v1_interface;
    }

    treeland_foreign_toplevel_handle_v1::Resource *treeland_foreign_toplevel_handle_v1::allocate()
    {
        return new Resource;
    }

    void treeland_foreign_toplevel_handle_v1::destroy_global()
    {
    }

    void treeland_foreign_toplevel_handle_v1::bind_resource(Resource *)
    {
    }

    void treeland_foreign_toplevel_handle_v1::destroy_resource(Resource *)
    {
    }

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

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

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

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


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

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

    treeland_foreign_toplevel_handle_v1::Resource *treeland_foreign_toplevel_handle_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = allocate();
        resource->treeland_foreign_toplevel_handle_v1_object = this;

        wl_resource_set_implementation(handle, &m_treeland_foreign_toplevel_handle_v1_interface, resource, destroy_func);
        resource->handle = handle;
        bind_resource(resource);
        return resource;
    }
    treeland_foreign_toplevel_handle_v1::Resource *treeland_foreign_toplevel_handle_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::treeland_foreign_toplevel_handle_v1_interface, &m_treeland_foreign_toplevel_handle_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::treeland_foreign_toplevel_handle_v1_interface treeland_foreign_toplevel_handle_v1::m_treeland_foreign_toplevel_handle_v1_interface = {
        treeland_foreign_toplevel_handle_v1::handle_set_maximized,
        treeland_foreign_toplevel_handle_v1::handle_unset_maximized,
        treeland_foreign_toplevel_handle_v1::handle_set_minimized,
        treeland_foreign_toplevel_handle_v1::handle_unset_minimized,
        treeland_foreign_toplevel_handle_v1::handle_activate,
        treeland_foreign_toplevel_handle_v1::handle_close,
        treeland_foreign_toplevel_handle_v1::handle_set_rectangle,
        treeland_foreign_toplevel_handle_v1::handle_destroy,
        treeland_foreign_toplevel_handle_v1::handle_set_fullscreen,
        treeland_foreign_toplevel_handle_v1::handle_unset_fullscreen
    };

    void treeland_foreign_toplevel_handle_v1::set_maximized(Resource *resource)
    {
        Q_UNUSED(resource);
    }

    void treeland_foreign_toplevel_handle_v1::unset_maximized(Resource *resource)
    {
        Q_UNUSED(resource);
    }

    void treeland_foreign_toplevel_handle_v1::set_minimized(Resource *resource)
    {
        Q_UNUSED(resource);
    }

    void treeland_foreign_toplevel_handle_v1::unset_minimized(Resource *resource)
    {
        Q_UNUSED(resource);
    }

    void treeland_foreign_toplevel_handle_v1::activate(Resource *resource, struct ::wl_resource *seat)
    {
        Q_UNUSED(resource);
        Q_UNUSED(seat);
    }

    void treeland_foreign_toplevel_handle_v1::close(Resource *resource)
    {
        Q_UNUSED(resource);
    }

    void treeland_foreign_toplevel_handle_v1::set_rectangle(Resource *resource, struct ::wl_resource *surface, int32_t x, int32_t y, int32_t width, int32_t height)
    {
        Q_UNUSED(resource);
        Q_UNUSED(surface);
        Q_UNUSED(x);
        Q_UNUSED(y);
        Q_UNUSED(width);
        Q_UNUSED(height);
    }

    void treeland_foreign_toplevel_handle_v1::destroy(Resource *resource)
    {
        Q_UNUSED(resource);
    }

    void treeland_foreign_toplevel_handle_v1::set_fullscreen(Resource *resource, struct ::wl_resource *output)
    {
        Q_UNUSED(resource);
        Q_UNUSED(output);
    }

    void treeland_foreign_toplevel_handle_v1::unset_fullscreen(Resource *resource)
    {
        Q_UNUSED(resource);
    }


    void treeland_foreign_toplevel_handle_v1::handle_set_maximized(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_handle_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_handle_v1 *>(qResource->treeland_foreign_toplevel_handle_v1_object)->set_maximized(
            qResource);
    }

    void treeland_foreign_toplevel_handle_v1::handle_unset_maximized(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_handle_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_handle_v1 *>(qResource->treeland_foreign_toplevel_handle_v1_object)->unset_maximized(
            qResource);
    }

    void treeland_foreign_toplevel_handle_v1::handle_set_minimized(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_handle_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_handle_v1 *>(qResource->treeland_foreign_toplevel_handle_v1_object)->set_minimized(
            qResource);
    }

    void treeland_foreign_toplevel_handle_v1::handle_unset_minimized(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_handle_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_handle_v1 *>(qResource->treeland_foreign_toplevel_handle_v1_object)->unset_minimized(
            qResource);
    }

    void treeland_foreign_toplevel_handle_v1::handle_activate(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *seat)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_handle_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_handle_v1 *>(qResource->treeland_foreign_toplevel_handle_v1_object)->activate(
            qResource,
            seat);
    }

    void treeland_foreign_toplevel_handle_v1::handle_close(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_handle_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_handle_v1 *>(qResource->treeland_foreign_toplevel_handle_v1_object)->close(
            qResource);
    }

    void treeland_foreign_toplevel_handle_v1::handle_set_rectangle(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *surface,
        int32_t x,
        int32_t y,
        int32_t width,
        int32_t height)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_handle_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_handle_v1 *>(qResource->treeland_foreign_toplevel_handle_v1_object)->set_rectangle(
            qResource,
            surface,
            x,
            y,
            width,
            height);
    }

    void treeland_foreign_toplevel_handle_v1::handle_destroy(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_handle_v1_object)) {
            wl_resource_destroy(resource);
            return;
        }
        static_cast<treeland_foreign_toplevel_handle_v1 *>(qResource->treeland_foreign_toplevel_handle_v1_object)->destroy(
            qResource);
    }

    void treeland_foreign_toplevel_handle_v1::handle_set_fullscreen(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *output)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_handle_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_handle_v1 *>(qResource->treeland_foreign_toplevel_handle_v1_object)->set_fullscreen(
            qResource,
            output);
    }

    void treeland_foreign_toplevel_handle_v1::handle_unset_fullscreen(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_foreign_toplevel_handle_v1_object)) {
            return;
        }
        static_cast<treeland_foreign_toplevel_handle_v1 *>(qResource->treeland_foreign_toplevel_handle_v1_object)->unset_fullscreen(
            qResource);
    }

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

    void treeland_foreign_toplevel_handle_v1::send_pid(struct ::wl_resource *resource, uint32_t pid)
    {
        treeland_foreign_toplevel_handle_v1_send_pid(
            resource,
            pid);
    }


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

    void treeland_foreign_toplevel_handle_v1::send_title(struct ::wl_resource *resource, const QString &title)
    {
        treeland_foreign_toplevel_handle_v1_send_title(
            resource,
            title.toUtf8().constData());
    }


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

    void treeland_foreign_toplevel_handle_v1::send_app_id(struct ::wl_resource *resource, const QString &app_id)
    {
        treeland_foreign_toplevel_handle_v1_send_app_id(
            resource,
            app_id.toUtf8().constData());
    }


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

    void treeland_foreign_toplevel_handle_v1::send_identifier(struct ::wl_resource *resource, uint32_t identifier)
    {
        treeland_foreign_toplevel_handle_v1_send_identifier(
            resource,
            identifier);
    }


    void treeland_foreign_toplevel_handle_v1::send_output_enter(struct ::wl_resource *output)
    {
        Q_ASSERT_X(m_resource, "treeland_foreign_toplevel_handle_v1::output_enter", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call treeland_foreign_toplevel_handle_v1::output_enter as it's not initialised");
            return;
        }
        send_output_enter(
            m_resource->handle,
            output);
    }

    void treeland_foreign_toplevel_handle_v1::send_output_enter(struct ::wl_resource *resource, struct ::wl_resource *output)
    {
        treeland_foreign_toplevel_handle_v1_send_output_enter(
            resource,
            output);
    }


    void treeland_foreign_toplevel_handle_v1::send_output_leave(struct ::wl_resource *output)
    {
        Q_ASSERT_X(m_resource, "treeland_foreign_toplevel_handle_v1::output_leave", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call treeland_foreign_toplevel_handle_v1::output_leave as it's not initialised");
            return;
        }
        send_output_leave(
            m_resource->handle,
            output);
    }

    void treeland_foreign_toplevel_handle_v1::send_output_leave(struct ::wl_resource *resource, struct ::wl_resource *output)
    {
        treeland_foreign_toplevel_handle_v1_send_output_leave(
            resource,
            output);
    }


    void treeland_foreign_toplevel_handle_v1::send_state(const QByteArray &state)
    {
        Q_ASSERT_X(m_resource, "treeland_foreign_toplevel_handle_v1::state", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call treeland_foreign_toplevel_handle_v1::state as it's not initialised");
            return;
        }
        send_state(
            m_resource->handle,
            state);
    }

    void treeland_foreign_toplevel_handle_v1::send_state(struct ::wl_resource *resource, const QByteArray &state)
    {
        struct wl_array state_data;
        state_data.size = state.size();
        state_data.data = static_cast<void *>(const_cast<char *>(state.constData()));
        state_data.alloc = 0;

        treeland_foreign_toplevel_handle_v1_send_state(
            resource,
            &state_data);
    }


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

    void treeland_foreign_toplevel_handle_v1::send_done(struct ::wl_resource *resource)
    {
        treeland_foreign_toplevel_handle_v1_send_done(
            resource);
    }


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

    void treeland_foreign_toplevel_handle_v1::send_closed(struct ::wl_resource *resource)
    {
        treeland_foreign_toplevel_handle_v1_send_closed(
            resource);
    }


    void treeland_foreign_toplevel_handle_v1::send_parent(struct ::wl_resource *parent)
    {
        Q_ASSERT_X(m_resource, "treeland_foreign_toplevel_handle_v1::parent", "Uninitialised resource");
        if (Q_UNLIKELY(!m_resource)) {
            qWarning("could not call treeland_foreign_toplevel_handle_v1::parent as it's not initialised");
            return;
        }
        send_parent(
            m_resource->handle,
            parent);
    }

    void treeland_foreign_toplevel_handle_v1::send_parent(struct ::wl_resource *resource, struct ::wl_resource *parent)
    {
        treeland_foreign_toplevel_handle_v1_send_parent(
            resource,
            parent);
    }



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

    treeland_dock_preview_context_v1::treeland_dock_preview_context_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);
    }

    treeland_dock_preview_context_v1::treeland_dock_preview_context_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);
    }

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

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

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

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

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

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

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

    const struct wl_interface *treeland_dock_preview_context_v1::interface()
    {
        return &::treeland_dock_preview_context_v1_interface;
    }

    treeland_dock_preview_context_v1::Resource *treeland_dock_preview_context_v1::allocate()
    {
        return new Resource;
    }

    void treeland_dock_preview_context_v1::destroy_global()
    {
    }

    void treeland_dock_preview_context_v1::bind_resource(Resource *)
    {
    }

    void treeland_dock_preview_context_v1::destroy_resource(Resource *)
    {
    }

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

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

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

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


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

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

    treeland_dock_preview_context_v1::Resource *treeland_dock_preview_context_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = allocate();
        resource->treeland_dock_preview_context_v1_object = this;

        wl_resource_set_implementation(handle, &m_treeland_dock_preview_context_v1_interface, resource, destroy_func);
        resource->handle = handle;
        bind_resource(resource);
        return resource;
    }
    treeland_dock_preview_context_v1::Resource *treeland_dock_preview_context_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::treeland_dock_preview_context_v1_interface, &m_treeland_dock_preview_context_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::treeland_dock_preview_context_v1_interface treeland_dock_preview_context_v1::m_treeland_dock_preview_context_v1_interface = {
        treeland_dock_preview_context_v1::handle_show,
        treeland_dock_preview_context_v1::handle_show_tooltip,
        treeland_dock_preview_context_v1::handle_close,
        treeland_dock_preview_context_v1::handle_destroy
    };

    void treeland_dock_preview_context_v1::show(Resource *resource, wl_array *surfaces, int32_t x, int32_t y, uint32_t direction)
    {
        Q_UNUSED(resource);
        Q_UNUSED(surfaces);
        Q_UNUSED(x);
        Q_UNUSED(y);
        Q_UNUSED(direction);
    }

    void treeland_dock_preview_context_v1::show_tooltip(Resource *resource, const QString &tooltip, int32_t x, int32_t y, uint32_t direction)
    {
        Q_UNUSED(resource);
        Q_UNUSED(tooltip);
        Q_UNUSED(x);
        Q_UNUSED(y);
        Q_UNUSED(direction);
    }

    void treeland_dock_preview_context_v1::close(Resource *resource)
    {
        Q_UNUSED(resource);
    }

    void treeland_dock_preview_context_v1::destroy(Resource *resource)
    {
        Q_UNUSED(resource);
    }


    void treeland_dock_preview_context_v1::handle_show(
        ::wl_client *client,
        struct wl_resource *resource,
        wl_array *surfaces,
        int32_t x,
        int32_t y,
        uint32_t direction)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_dock_preview_context_v1_object)) {
            return;
        }
        static_cast<treeland_dock_preview_context_v1 *>(qResource->treeland_dock_preview_context_v1_object)->show(
            qResource,
            surfaces,
            x,
            y,
            direction);
    }

    void treeland_dock_preview_context_v1::handle_show_tooltip(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *tooltip,
        int32_t x,
        int32_t y,
        uint32_t direction)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_dock_preview_context_v1_object)) {
            return;
        }
        static_cast<treeland_dock_preview_context_v1 *>(qResource->treeland_dock_preview_context_v1_object)->show_tooltip(
            qResource,
            QString::fromUtf8(tooltip),
            x,
            y,
            direction);
    }

    void treeland_dock_preview_context_v1::handle_close(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_dock_preview_context_v1_object)) {
            return;
        }
        static_cast<treeland_dock_preview_context_v1 *>(qResource->treeland_dock_preview_context_v1_object)->close(
            qResource);
    }

    void treeland_dock_preview_context_v1::handle_destroy(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qResource->treeland_dock_preview_context_v1_object)) {
            wl_resource_destroy(resource);
            return;
        }
        static_cast<treeland_dock_preview_context_v1 *>(qResource->treeland_dock_preview_context_v1_object)->destroy(
            qResource);
    }

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

    void treeland_dock_preview_context_v1::send_enter(struct ::wl_resource *resource)
    {
        treeland_dock_preview_context_v1_send_enter(
            resource);
    }


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

    void treeland_dock_preview_context_v1::send_leave(struct ::wl_resource *resource)
    {
        treeland_dock_preview_context_v1_send_leave(
            resource);
    }

}

QT_WARNING_POP
QT_END_NAMESPACE
