// This file was generated by qtwaylandscanner
// source file is fake-input.xml

#include "qwayland-server-fake-input.h"

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

namespace QtWaylandServer {

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

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

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

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

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

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

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

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

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

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

    org_kde_kwin_fake_input::Resource *org_kde_kwin_fake_input::add(struct ::wl_resource *resource)
    {
        return *m_resource_map.insert(wl_resource_get_client(resource), bind(resource));
    }

    void org_kde_kwin_fake_input::init(struct ::wl_display *display, int version)
    {
        m_display = display;
        m_global = wl_global_create(display, &::org_kde_kwin_fake_input_interface, version, this, bind_func);
        m_displayDestroyedListener.notify = org_kde_kwin_fake_input::display_destroy_func;
        m_displayDestroyedListener.parent = this;
#ifdef HAVE_ACK_GLOBAL_REMOVE
        wl_global_set_withdrawn_listener(m_global, [](wl_global *global) {
            auto object = static_cast<org_kde_kwin_fake_input *>(wl_global_get_user_data(global));
            object->org_kde_kwin_fake_input_destroy_global();
        });
#endif
        wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
    }

    const struct wl_interface *org_kde_kwin_fake_input::interface()
    {
        return &::org_kde_kwin_fake_input_interface;
    }

    org_kde_kwin_fake_input::Resource *org_kde_kwin_fake_input::org_kde_kwin_fake_input_allocate()
    {
        return new Resource;
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_destroy_global()
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_bind_resource(Resource *)
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_destroy_resource(Resource *)
    {
    }

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

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

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

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


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

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

        wl_global_remove(m_global);
    }

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

    org_kde_kwin_fake_input::Resource *org_kde_kwin_fake_input::bind(struct ::wl_resource *handle)
    {
        Resource *resource = org_kde_kwin_fake_input_allocate();
        resource->org_kde_kwin_fake_input_object = this;

        wl_resource_set_implementation(handle, &m_org_kde_kwin_fake_input_interface, resource, destroy_func);
        resource->handle = handle;
        org_kde_kwin_fake_input_bind_resource(resource);
        return resource;
    }
    org_kde_kwin_fake_input::Resource *org_kde_kwin_fake_input::Resource::fromResource(struct ::wl_resource *resource)
    {
        if (Q_UNLIKELY(!resource))
            return nullptr;
        if (wl_resource_instance_of(resource, &::org_kde_kwin_fake_input_interface, &m_org_kde_kwin_fake_input_interface))
            return static_cast<Resource *>(wl_resource_get_user_data(resource));
        return nullptr;
    }

    const struct ::org_kde_kwin_fake_input_interface org_kde_kwin_fake_input::m_org_kde_kwin_fake_input_interface = {
        org_kde_kwin_fake_input::handle_authenticate,
        org_kde_kwin_fake_input::handle_pointer_motion,
        org_kde_kwin_fake_input::handle_button,
        org_kde_kwin_fake_input::handle_axis,
        org_kde_kwin_fake_input::handle_touch_down,
        org_kde_kwin_fake_input::handle_touch_motion,
        org_kde_kwin_fake_input::handle_touch_up,
        org_kde_kwin_fake_input::handle_touch_cancel,
        org_kde_kwin_fake_input::handle_touch_frame,
        org_kde_kwin_fake_input::handle_pointer_motion_absolute,
        org_kde_kwin_fake_input::handle_keyboard_key,
        org_kde_kwin_fake_input::handle_destroy,
        org_kde_kwin_fake_input::handle_keyboard_keysym
    };

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_authenticate(Resource *, const QString &, const QString &)
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_pointer_motion(Resource *, wl_fixed_t , wl_fixed_t )
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_button(Resource *, uint32_t , uint32_t )
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_axis(Resource *, uint32_t , wl_fixed_t )
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_touch_down(Resource *, uint32_t , wl_fixed_t , wl_fixed_t )
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_touch_motion(Resource *, uint32_t , wl_fixed_t , wl_fixed_t )
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_touch_up(Resource *, uint32_t )
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_touch_cancel(Resource *)
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_touch_frame(Resource *)
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_pointer_motion_absolute(Resource *, wl_fixed_t , wl_fixed_t )
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_keyboard_key(Resource *, uint32_t , uint32_t )
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_destroy(Resource *)
    {
    }

    void org_kde_kwin_fake_input::org_kde_kwin_fake_input_keyboard_keysym(Resource *, uint32_t , uint32_t )
    {
    }


    void org_kde_kwin_fake_input::handle_authenticate(
        ::wl_client *client,
        struct wl_resource *resource,
        const char *application,
        const char *reason)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_authenticate(
            qtResource,
            QString::fromUtf8(application),
            QString::fromUtf8(reason));
    }

    void org_kde_kwin_fake_input::handle_pointer_motion(
        ::wl_client *client,
        struct wl_resource *resource,
        wl_fixed_t delta_x,
        wl_fixed_t delta_y)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_pointer_motion(
            qtResource,
            delta_x,
            delta_y);
    }

    void org_kde_kwin_fake_input::handle_button(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t button,
        uint32_t state)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_button(
            qtResource,
            button,
            state);
    }

    void org_kde_kwin_fake_input::handle_axis(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t axis,
        wl_fixed_t value)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_axis(
            qtResource,
            axis,
            value);
    }

    void org_kde_kwin_fake_input::handle_touch_down(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id,
        wl_fixed_t x,
        wl_fixed_t y)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_touch_down(
            qtResource,
            id,
            x,
            y);
    }

    void org_kde_kwin_fake_input::handle_touch_motion(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id,
        wl_fixed_t x,
        wl_fixed_t y)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_touch_motion(
            qtResource,
            id,
            x,
            y);
    }

    void org_kde_kwin_fake_input::handle_touch_up(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t id)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_touch_up(
            qtResource,
            id);
    }

    void org_kde_kwin_fake_input::handle_touch_cancel(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_touch_cancel(
            qtResource);
    }

    void org_kde_kwin_fake_input::handle_touch_frame(
        ::wl_client *client,
        struct wl_resource *resource)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_touch_frame(
            qtResource);
    }

    void org_kde_kwin_fake_input::handle_pointer_motion_absolute(
        ::wl_client *client,
        struct wl_resource *resource,
        wl_fixed_t x,
        wl_fixed_t y)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_pointer_motion_absolute(
            qtResource,
            x,
            y);
    }

    void org_kde_kwin_fake_input::handle_keyboard_key(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t button,
        uint32_t state)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_keyboard_key(
            qtResource,
            button,
            state);
    }

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

    void org_kde_kwin_fake_input::handle_keyboard_keysym(
        ::wl_client *client,
        struct wl_resource *resource,
        uint32_t keysym,
        uint32_t state)
    {
        Q_UNUSED(client);
        Resource *qtResource = Resource::fromResource(resource);
        if (Q_UNLIKELY(!qtResource->org_kde_kwin_fake_input_object)) {
            return;
        }
        static_cast<org_kde_kwin_fake_input *>(qtResource->org_kde_kwin_fake_input_object)->org_kde_kwin_fake_input_keyboard_keysym(
            qtResource,
            keysym,
            state);
    }
}

QT_WARNING_POP
QT_END_NAMESPACE
