コード例 #1
0
ファイル: data-device.c プロジェクト: CSRedRat/wayland
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;
}
コード例 #2
0
ファイル: data-device.c プロジェクト: antognolli/weston
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;
}
コード例 #3
0
ファイル: qwldataoffer.cpp プロジェクト: soreau/qtwayland
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;
}
コード例 #4
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;
}
コード例 #5
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;
}