// This file was generated by qtwaylandscanner
// source file is //usr/share/wayland-protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml

#include "qwayland-server-pointer-constraints-unstable-v1.h"

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

namespace QtWaylandServer {

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

    zwp_pointer_constraints_v1::zwp_pointer_constraints_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);
    }

    zwp_pointer_constraints_v1::zwp_pointer_constraints_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);
    }

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

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

    zwp_pointer_constraints_v1::~zwp_pointer_constraints_v1()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->zwp_pointer_constraints_v1_object = nullptr;

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

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

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

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

    const struct wl_interface *zwp_pointer_constraints_v1::interface()
    {
        return &::zwp_pointer_constraints_v1_interface;
    }

    zwp_pointer_constraints_v1::Resource *zwp_pointer_constraints_v1::zwp_pointer_constraints_v1_allocate()
    {
        return new Resource;
    }

    void zwp_pointer_constraints_v1::zwp_pointer_constraints_v1_destroy_global()
    {
    }

    void zwp_pointer_constraints_v1::zwp_pointer_constraints_v1_bind_resource(Resource *)
    {
    }

    void zwp_pointer_constraints_v1::zwp_pointer_constraints_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


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

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

    zwp_pointer_constraints_v1::Resource *zwp_pointer_constraints_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwp_pointer_constraints_v1_allocate();
        resource->zwp_pointer_constraints_v1_object = this;

        wl_resource_set_implementation(handle, &m_zwp_pointer_constraints_v1_interface, resource, destroy_func);
        resource->handle = handle;
        zwp_pointer_constraints_v1_bind_resource(resource);
        return resource;
    }
    zwp_pointer_constraints_v1::Resource *zwp_pointer_constraints_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::zwp_pointer_constraints_v1_interface, &m_zwp_pointer_constraints_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::zwp_pointer_constraints_v1_interface zwp_pointer_constraints_v1::m_zwp_pointer_constraints_v1_interface = {
        zwp_pointer_constraints_v1::handle_destroy,
        zwp_pointer_constraints_v1::handle_lock_pointer,
        zwp_pointer_constraints_v1::handle_confine_pointer
    };

    void zwp_pointer_constraints_v1::zwp_pointer_constraints_v1_destroy(Resource *)
    {
    }

    void zwp_pointer_constraints_v1::zwp_pointer_constraints_v1_lock_pointer(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *, struct ::wl_resource *, uint32_t )
    {
    }

    void zwp_pointer_constraints_v1::zwp_pointer_constraints_v1_confine_pointer(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *, struct ::wl_resource *, uint32_t )
    {
    }


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

    void zwp_pointer_constraints_v1::handle_lock_pointer(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id,
        struct ::wl_resource *surface,
        struct ::wl_resource *pointer,
        struct ::wl_resource *region,
        uint32_t lifetime)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_pointer_constraints_v1_object)) {
            return;
        }
        static_cast<zwp_pointer_constraints_v1 *>(r->zwp_pointer_constraints_v1_object)->zwp_pointer_constraints_v1_lock_pointer(
            r,
            id,
            surface,
            pointer,
            region,
            lifetime);
    }

    void zwp_pointer_constraints_v1::handle_confine_pointer(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id,
        struct ::wl_resource *surface,
        struct ::wl_resource *pointer,
        struct ::wl_resource *region,
        uint32_t lifetime)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_pointer_constraints_v1_object)) {
            return;
        }
        static_cast<zwp_pointer_constraints_v1 *>(r->zwp_pointer_constraints_v1_object)->zwp_pointer_constraints_v1_confine_pointer(
            r,
            id,
            surface,
            pointer,
            region,
            lifetime);
    }


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

    zwp_locked_pointer_v1::zwp_locked_pointer_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);
    }

    zwp_locked_pointer_v1::zwp_locked_pointer_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);
    }

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

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

    zwp_locked_pointer_v1::~zwp_locked_pointer_v1()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->zwp_locked_pointer_v1_object = nullptr;

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

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

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

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

    const struct wl_interface *zwp_locked_pointer_v1::interface()
    {
        return &::zwp_locked_pointer_v1_interface;
    }

    zwp_locked_pointer_v1::Resource *zwp_locked_pointer_v1::zwp_locked_pointer_v1_allocate()
    {
        return new Resource;
    }

    void zwp_locked_pointer_v1::zwp_locked_pointer_v1_destroy_global()
    {
    }

    void zwp_locked_pointer_v1::zwp_locked_pointer_v1_bind_resource(Resource *)
    {
    }

    void zwp_locked_pointer_v1::zwp_locked_pointer_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


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

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

    zwp_locked_pointer_v1::Resource *zwp_locked_pointer_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwp_locked_pointer_v1_allocate();
        resource->zwp_locked_pointer_v1_object = this;

        wl_resource_set_implementation(handle, &m_zwp_locked_pointer_v1_interface, resource, destroy_func);
        resource->handle = handle;
        zwp_locked_pointer_v1_bind_resource(resource);
        return resource;
    }
    zwp_locked_pointer_v1::Resource *zwp_locked_pointer_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::zwp_locked_pointer_v1_interface, &m_zwp_locked_pointer_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::zwp_locked_pointer_v1_interface zwp_locked_pointer_v1::m_zwp_locked_pointer_v1_interface = {
        zwp_locked_pointer_v1::handle_destroy,
        zwp_locked_pointer_v1::handle_set_cursor_position_hint,
        zwp_locked_pointer_v1::handle_set_region
    };

    void zwp_locked_pointer_v1::zwp_locked_pointer_v1_destroy(Resource *)
    {
    }

    void zwp_locked_pointer_v1::zwp_locked_pointer_v1_set_cursor_position_hint(Resource *, wl_fixed_t , wl_fixed_t )
    {
    }

    void zwp_locked_pointer_v1::zwp_locked_pointer_v1_set_region(Resource *, struct ::wl_resource *)
    {
    }


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

    void zwp_locked_pointer_v1::handle_set_cursor_position_hint(
        ::wl_client *client,
        struct wl_resource *resource,
        wl_fixed_t surface_x,
        wl_fixed_t surface_y)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_locked_pointer_v1_object)) {
            return;
        }
        static_cast<zwp_locked_pointer_v1 *>(r->zwp_locked_pointer_v1_object)->zwp_locked_pointer_v1_set_cursor_position_hint(
            r,
            surface_x,
            surface_y);
    }

    void zwp_locked_pointer_v1::handle_set_region(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *region)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_locked_pointer_v1_object)) {
            return;
        }
        static_cast<zwp_locked_pointer_v1 *>(r->zwp_locked_pointer_v1_object)->zwp_locked_pointer_v1_set_region(
            r,
            region);
    }

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

    void zwp_locked_pointer_v1::send_locked(struct ::wl_resource *resource)
    {
        zwp_locked_pointer_v1_send_locked(
            resource);
    }


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

    void zwp_locked_pointer_v1::send_unlocked(struct ::wl_resource *resource)
    {
        zwp_locked_pointer_v1_send_unlocked(
            resource);
    }



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

    zwp_confined_pointer_v1::zwp_confined_pointer_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);
    }

    zwp_confined_pointer_v1::zwp_confined_pointer_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);
    }

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

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

    zwp_confined_pointer_v1::~zwp_confined_pointer_v1()
    {
        for (auto resource : qAsConst(m_resource_map))
            resource->zwp_confined_pointer_v1_object = nullptr;

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

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

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

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

    const struct wl_interface *zwp_confined_pointer_v1::interface()
    {
        return &::zwp_confined_pointer_v1_interface;
    }

    zwp_confined_pointer_v1::Resource *zwp_confined_pointer_v1::zwp_confined_pointer_v1_allocate()
    {
        return new Resource;
    }

    void zwp_confined_pointer_v1::zwp_confined_pointer_v1_destroy_global()
    {
    }

    void zwp_confined_pointer_v1::zwp_confined_pointer_v1_bind_resource(Resource *)
    {
    }

    void zwp_confined_pointer_v1::zwp_confined_pointer_v1_destroy_resource(Resource *)
    {
    }

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

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

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

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


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

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

    zwp_confined_pointer_v1::Resource *zwp_confined_pointer_v1::bind(struct ::wl_resource *handle)
    {
        Resource *resource = zwp_confined_pointer_v1_allocate();
        resource->zwp_confined_pointer_v1_object = this;

        wl_resource_set_implementation(handle, &m_zwp_confined_pointer_v1_interface, resource, destroy_func);
        resource->handle = handle;
        zwp_confined_pointer_v1_bind_resource(resource);
        return resource;
    }
    zwp_confined_pointer_v1::Resource *zwp_confined_pointer_v1::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::zwp_confined_pointer_v1_interface, &m_zwp_confined_pointer_v1_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::zwp_confined_pointer_v1_interface zwp_confined_pointer_v1::m_zwp_confined_pointer_v1_interface = {
        zwp_confined_pointer_v1::handle_destroy,
        zwp_confined_pointer_v1::handle_set_region
    };

    void zwp_confined_pointer_v1::zwp_confined_pointer_v1_destroy(Resource *)
    {
    }

    void zwp_confined_pointer_v1::zwp_confined_pointer_v1_set_region(Resource *, struct ::wl_resource *)
    {
    }


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

    void zwp_confined_pointer_v1::handle_set_region(
        ::wl_client *client,
        struct wl_resource *resource,
        struct ::wl_resource *region)
    {
        Q_UNUSED(client);
        Resource *r = Resource::fromResource(resource);
        if (Q_UNLIKELY(!r->zwp_confined_pointer_v1_object)) {
            return;
        }
        static_cast<zwp_confined_pointer_v1 *>(r->zwp_confined_pointer_v1_object)->zwp_confined_pointer_v1_set_region(
            r,
            region);
    }

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

    void zwp_confined_pointer_v1::send_confined(struct ::wl_resource *resource)
    {
        zwp_confined_pointer_v1_send_confined(
            resource);
    }


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

    void zwp_confined_pointer_v1::send_unconfined(struct ::wl_resource *resource)
    {
        zwp_confined_pointer_v1_send_unconfined(
            resource);
    }

}

QT_WARNING_POP
QT_END_NAMESPACE
