Esempio n. 1
0
static struct wl_resource *
wl_data_source_send_offer(struct wl_data_source *source,
			  struct wl_resource *target)
{
	struct wl_data_offer *offer;
	char **p;

	offer = malloc(sizeof *offer);
	if (offer == NULL)
		return NULL;

	offer->resource.destroy = destroy_data_offer;
	offer->resource.object.id = 0;
	offer->resource.object.interface = &wl_data_offer_interface;
	offer->resource.object.implementation =
		(void (**)(void)) &data_offer_interface;
	offer->resource.data = offer;
	wl_signal_init(&offer->resource.destroy_signal);

	offer->source = source;
	offer->source_destroy_listener.notify = destroy_offer_data_source;
	wl_signal_add(&source->resource.destroy_signal,
		      &offer->source_destroy_listener);

	wl_client_add_resource(target->client, &offer->resource);

	wl_data_device_send_data_offer(target, &offer->resource);

	wl_array_for_each(p, &source->mime_types)
		wl_data_offer_send_offer(&offer->resource, *p);

	return &offer->resource;
}
Esempio n. 2
0
static struct wl_resource *
weston_data_source_send_offer(struct weston_data_source *source,
			      struct wl_resource *target)
{
	struct weston_data_offer *offer;
	char **p;

	offer = malloc(sizeof *offer);
	if (offer == NULL)
		return NULL;

	offer->resource =
		wl_resource_create(wl_resource_get_client(target),
				   &wl_data_offer_interface, 1, 0);
	if (offer->resource == NULL) {
		free(offer);
		return NULL;
	}

	wl_resource_set_implementation(offer->resource, &data_offer_interface,
				       offer, destroy_data_offer);

	offer->source = source;
	offer->source_destroy_listener.notify = destroy_offer_data_source;
	wl_signal_add(&source->destroy_signal,
		      &offer->source_destroy_listener);

	wl_data_device_send_data_offer(target, offer->resource);

	wl_array_for_each(p, &source->mime_types)
		wl_data_offer_send_offer(offer->resource, *p);

	return offer->resource;
}
Esempio n. 3
0
static struct wl_resource * new_offer(struct wl_resource * resource,
                                      struct wl_client * client,
                                      struct wl_resource * source)
{
    struct wl_resource * offer;

    offer = data_offer_new(client, source);
    wl_data_device_send_data_offer(resource, offer);
    data_send_mime_types(source, offer);

    return offer;
}
Esempio n. 4
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;
}
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;
}
Esempio n. 6
0
static struct wl_resource *
meta_wayland_data_source_send_offer (MetaWaylandDataSource *source,
                                     struct wl_resource *target)
{
  MetaWaylandDataOffer *offer = g_slice_new0 (MetaWaylandDataOffer);
  char **p;

  offer->source = source;
  offer->source_destroy_listener.notify = destroy_offer_data_source;

  offer->resource = wl_resource_create (wl_resource_get_client (target), &wl_data_offer_interface, wl_resource_get_version (target), 0);
  wl_resource_set_implementation (offer->resource, &data_offer_interface, offer, destroy_data_offer);
  wl_resource_add_destroy_listener (source->resource, &offer->source_destroy_listener);

  wl_data_device_send_data_offer (target, offer->resource);

  wl_array_for_each (p, &source->mime_types)
    wl_data_offer_send_offer (offer->resource, *p);

  return offer->resource;
}