summaryrefslogtreecommitdiffstats
path: root/src/compositor/wayland_wrapper/qwldatasource.cpp
diff options
context:
space:
mode:
authorJan Arne Petersen <jan.petersen@kdab.com>2013-11-01 12:46:22 +0100
committerJørgen Lind <jorgen.lind@digia.com>2013-11-22 15:46:38 +0100
commitd06c04238238c780b6d0019b305b4ae8c99de425 (patch)
treefa5fbf0a960e63b4525168d309ccfc78de4927fc /src/compositor/wayland_wrapper/qwldatasource.cpp
parent19992cf8f509e178b0cb0e31df28ba30b8020057 (diff)
Add Drag&Drop support to compositor
Change-Id: Ic606ac4dfbb1c55ddb81ac8a912132102753455c Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/compositor/wayland_wrapper/qwldatasource.cpp')
-rw-r--r--src/compositor/wayland_wrapper/qwldatasource.cpp71
1 files changed, 27 insertions, 44 deletions
diff --git a/src/compositor/wayland_wrapper/qwldatasource.cpp b/src/compositor/wayland_wrapper/qwldatasource.cpp
index d60ec5108..a31ed8e70 100644
--- a/src/compositor/wayland_wrapper/qwldatasource.cpp
+++ b/src/compositor/wayland_wrapper/qwldatasource.cpp
@@ -40,23 +40,20 @@
#include "qwldatasource_p.h"
#include "qwldataoffer_p.h"
+#include "qwldatadevice_p.h"
#include "qwldatadevicemanager_p.h"
#include "qwlcompositor_p.h"
-#include <wayland-wayland-server-protocol.h>
-
-#include <QtCore/QDebug>
+#include <unistd.h>
QT_BEGIN_NAMESPACE
namespace QtWayland {
DataSource::DataSource(struct wl_client *client, uint32_t id, uint32_t time)
- : m_time(time)
+ : QtWaylandServer::wl_data_source(client, id)
+ , m_time(time)
{
- m_data_source_resource = wl_client_add_object(client, &wl_data_source_interface, &DataSource::data_source_interface,id,this);
- m_data_source_resource->destroy = resource_destroy;
- m_data_offer = new DataOffer(this);
m_manager = 0;
}
@@ -64,71 +61,57 @@ DataSource::~DataSource()
{
if (m_manager)
m_manager->sourceDestroyed(this);
- wl_resource_destroy(m_data_source_resource);
}
-void DataSource::resource_destroy(wl_resource *resource)
+uint32_t DataSource::time() const
{
- DataSource *source = static_cast<DataSource *>(resource->data);
- if (source && source->m_data_source_resource == resource)
- source->m_data_source_resource = 0;
- free(resource);
+ return m_time;
}
-uint32_t DataSource::time() const
+QList<QString> DataSource::mimeTypes() const
{
- return m_time;
+ return m_mimeTypes;
}
-QList<QByteArray> DataSource::offerList() const
+void DataSource::accept(const QString &mimeType)
{
- return m_offers;
+ send_target(mimeType);
}
-struct wl_data_source_interface DataSource::data_source_interface = {
- DataSource::offer,
- DataSource::destroy
-};
+void DataSource::send(const QString &mimeType, int fd)
+{
+ send_send(mimeType, fd);
+ close(fd);
+}
-void DataSource::offer(struct wl_client *client,
- struct wl_resource *resource,
- const char *type)
+void DataSource::cancel()
{
- Q_UNUSED(client);
- //qDebug() << "received offer" << type;
- static_cast<DataSource *>(resource->data)->m_offers.append(type);
+ send_cancelled();
}
-void DataSource::destroy(struct wl_client *client,
- struct wl_resource *resource)
+void DataSource::setManager(DataDeviceManager *mgr)
{
- Q_UNUSED(client);
- DataSource *self = static_cast<DataSource *>(resource->data);
- delete self;
+ m_manager = mgr;
}
-DataOffer * DataSource::dataOffer() const
+DataSource *DataSource::fromResource(struct ::wl_resource *resource)
{
- return m_data_offer;
+ return static_cast<DataSource *>(Resource::fromResource(resource)->data_source);
}
-void DataSource::postSendEvent(const QByteArray &mimeType, int fd)
+void DataSource::data_source_offer(Resource *, const QString &mime_type)
{
- if (m_data_source_resource) {
- wl_data_source_send_send(m_data_source_resource, mimeType.constData(), fd);
- }
+ m_mimeTypes.append(mime_type);
}
-struct wl_client *DataSource::client() const
+void DataSource::data_source_destroy(Resource *resource)
{
- if (m_data_source_resource)
- return m_data_source_resource->client;
- return 0;
+ wl_resource_destroy(resource->handle);
}
-void DataSource::setManager(DataDeviceManager *mgr)
+void DataSource::data_source_destroy_resource(QtWaylandServer::wl_data_source::Resource *resource)
{
- m_manager = mgr;
+ delete this;
}
}