struct ::wl_resource *LibHybrisEglServerBuffer::resourceForClient(struct ::wl_client *client)
{
    QMultiMap<struct ::wl_client *, Resource *>::iterator it = resourceMap().find(client);
    if (it == resourceMap().end()) {
        QMultiMap<struct ::wl_client *, QtWaylandServer::qt_libhybris_egl_server_buffer::Resource *>::iterator egl_it = m_integration->resourceMap().find(client);
        if (egl_it == m_integration->resourceMap().end()) {
            qWarning("LibHybrisEglServerBuffer::resourceForClient: Trying to get resource for ServerBuffer. But client is not bound to the libhybris_egl interface");
            return 0;
        }
        struct ::wl_resource *egl_resource = (*egl_it)->handle;
        Resource *resource = add(client, 1, 1);
        wl_resource *bufRes = wl_client_new_object(client, &qt_libhybris_buffer_interface, 0, 0);

        m_integration->send_server_buffer_created(egl_resource, resource->handle, bufRes, m_fds.size(), QByteArray((char *)m_ints.data(), m_ints.size() * sizeof(int32_t)),
                                    m_name, m_size.width(), m_size.height(), m_stride, m_format);

        m_qtbuffers.insert(resource, bufRes);

        for (int i = 0; i < m_fds.size(); ++i) {
            send_add_fd(resource->handle, m_fds.at(i));
        }

        return bufRes;
    }
    return m_qtbuffers.value(*it);
}
Exemplo n.º 2
0
struct wl_resource *DataOffer::addDataDeviceResource(struct wl_resource *data_device_resource)
{
    if (resourceForClient(data_device_resource->client)) {
        qDebug() << "This should not happen, the client tries to add twice to a data offer";
        return 0;
    }
    struct wl_resource *new_object =
        wl_client_new_object(data_device_resource->client,&wl_data_offer_interface,&data_interface,this);
    wl_data_device_send_data_offer(data_device_resource, new_object);

    registerResource(new_object);
    QList<QByteArray> offer_list = m_data_source->offerList();
    for (int i = 0; i < offer_list.size(); i++) {
        wl_data_offer_send_offer(new_object, offer_list.at(i).constData());
    }
    return new_object;
}
Exemplo n.º 3
0
bool DataDeviceManager::offerFromCompositorToClient(wl_resource *clientDataDeviceResource)
{
    if (!m_compositorOwnsSelection)
        return false;

    wl_client *client = clientDataDeviceResource->client;
    //qDebug("compositor offers %d types to %p", m_retainedData.formats().count(), client);

    struct wl_resource *selectionOffer =
             wl_client_new_object(client, &wl_data_offer_interface, &compositor_offer_interface, this);
    wl_data_device_send_data_offer(clientDataDeviceResource, selectionOffer);
    foreach (const QString &format, m_retainedData.formats()) {
        QByteArray ba = format.toLatin1();
        wl_data_offer_send_offer(selectionOffer, ba.constData());
    }
    wl_data_device_send_selection(clientDataDeviceResource, selectionOffer);

    return true;
}