summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2011-12-14 10:32:13 +0100
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-12-14 16:51:13 +0100
commit8abec2446d38e8963468f60e2436ba34595b644d (patch)
treeb8e75bb61e9663cd944a6c386d8a9f059b81b0e8
parentd0d4b2056d49049da29713ed4d54e9e323fddffa (diff)
Added a resourcecollection class
This class will typically be the super class of globals which creates wl_resources in the bind functions. If for some reason some other class needs to get a resource for a given client of the global, it can look it up Change-Id: I939cc7aaeb15586f2c760c600c188a8cbf19f358 Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
-rw-r--r--src/compositor/global/global.pri7
-rw-r--r--src/compositor/global/waylandobject.h (renamed from src/compositor/util/waylandobject.h)6
-rw-r--r--src/compositor/global/waylandresourcecollection.cpp92
-rw-r--r--src/compositor/global/waylandresourcecollection.h67
-rw-r--r--src/compositor/util/util.pri5
-rw-r--r--src/compositor/wayland_wrapper/wlcompositor.cpp9
-rw-r--r--src/compositor/wayland_wrapper/wldatadevicemanager.cpp2
-rw-r--r--src/compositor/wayland_wrapper/wldatadevicemanager.h4
-rw-r--r--src/compositor/wayland_wrapper/wldataoffer.cpp26
-rw-r--r--src/compositor/wayland_wrapper/wldataoffer.h7
-rw-r--r--src/compositor/wayland_wrapper/wlinputdevice.cpp5
-rw-r--r--src/compositor/wayland_wrapper/wlinputdevice.h4
-rw-r--r--src/compositor/wayland_wrapper/wloutput.cpp1
-rw-r--r--src/compositor/wayland_wrapper/wloutput.h4
-rw-r--r--src/compositor/wayland_wrapper/wlshell.h4
-rw-r--r--src/compositor/wayland_wrapper/wlsurface.h3
-rw-r--r--src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp30
-rw-r--r--src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h12
-rw-r--r--wayland_sha1.txt2
19 files changed, 209 insertions, 81 deletions
diff --git a/src/compositor/global/global.pri b/src/compositor/global/global.pri
index bdabcbfcf..4dcbe340e 100644
--- a/src/compositor/global/global.pri
+++ b/src/compositor/global/global.pri
@@ -1,5 +1,10 @@
INCLUDEPATH += $$PWD
-HEADERS += $$PWD/waylandexport.h
+HEADERS += \
+ $$PWD/waylandexport.h \
+ $$PWD/waylandobject.h \
+ $$PWD/waylandresourcecollection.h \
+SOURCES += \
+ $$PWD/waylandresourcecollection.cpp \
diff --git a/src/compositor/util/waylandobject.h b/src/compositor/global/waylandobject.h
index a64cfd0c7..131cd0993 100644
--- a/src/compositor/util/waylandobject.h
+++ b/src/compositor/global/waylandobject.h
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#ifndef WL_OBJECT_H
-#define WL_OBJECT_H
+#ifndef WAYLAND_OBJECT_H
+#define WAYLAND_OBJECT_H
#include <wayland-server.h>
@@ -84,4 +84,4 @@ void addClientResource(struct wl_client *client,
}
-#endif //WL_OBJECT_H
+#endif //WAYLAND_OBJECT_H
diff --git a/src/compositor/global/waylandresourcecollection.cpp b/src/compositor/global/waylandresourcecollection.cpp
new file mode 100644
index 000000000..9601f6f49
--- /dev/null
+++ b/src/compositor/global/waylandresourcecollection.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** This file is part of QtCompositor**
+**
+** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+**
+** Contact: Nokia Corporation qt-info@nokia.com
+**
+** You may use this file under the terms of the BSD license as follows:
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+**
+** Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in the
+** documentation and/or other materials provided with the distribution.
+**
+** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the
+** names of its contributors may be used to endorse or promote products
+** derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+****************************************************************************/
+
+#include "waylandresourcecollection.h"
+
+#include <QtCore/qglobal.h>
+
+namespace Wayland {
+
+ResourceCollection::ResourceCollection()
+{
+ wl_list_init(&client_resources);
+}
+
+ResourceCollection::~ResourceCollection()
+{
+
+}
+
+void ResourceCollection::registerResource(struct wl_resource *resource)
+{
+ wl_list_insert(&client_resources,&resource->link);
+ struct wl_listener *listener = new struct wl_listener;
+ listener->func = ResourceCollection::destroy_listener_func;
+ wl_list_insert(&resource->destroy_listener_list,&listener->link);
+}
+
+struct wl_resource *ResourceCollection::resourceForClient(wl_client *client) const
+{
+ struct wl_resource *resource;
+ wl_list_for_each(resource,&client_resources, link) {
+ if (resource->client == client) {
+ return resource;
+ }
+ }
+ return 0;
+
+}
+
+bool ResourceCollection::resourceListIsEmpty() const
+{
+ return wl_list_empty(const_cast<struct wl_list *>(&client_resources));
+}
+
+void ResourceCollection::destroy_listener_func(struct wl_listener *listener,
+ wl_resource *resource,
+ uint32_t time)
+{
+ Q_UNUSED(time);
+ wl_list_remove(&resource->link);
+ delete listener;
+}
+
+
+}
diff --git a/src/compositor/global/waylandresourcecollection.h b/src/compositor/global/waylandresourcecollection.h
new file mode 100644
index 000000000..104ec97d0
--- /dev/null
+++ b/src/compositor/global/waylandresourcecollection.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** This file is part of QtCompositor**
+**
+** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+**
+** Contact: Nokia Corporation qt-info@nokia.com
+**
+** You may use this file under the terms of the BSD license as follows:
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+**
+** Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in the
+** documentation and/or other materials provided with the distribution.
+**
+** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the
+** names of its contributors may be used to endorse or promote products
+** derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+****************************************************************************/
+
+#ifndef WAYLAND_RESOURCE_OBJECT_H
+#define WAYLAND_RESOURCE_OBJECT_H
+
+#include <wayland-server.h>
+
+namespace Wayland {
+
+class ResourceCollection
+{
+public:
+ ResourceCollection();
+ virtual ~ResourceCollection();
+ void registerResource(struct wl_resource *resource);
+ struct wl_resource *resourceForClient(struct wl_client *client) const;
+ bool resourceListIsEmpty() const;
+
+protected:
+ struct wl_list client_resources;
+private:
+ static void destroy_listener_func(struct wl_listener *listener,
+ struct wl_resource *resource, uint32_t time);
+
+};
+
+}
+
+#endif //WAYLAND_RESOURCE_OBJECT_H
diff --git a/src/compositor/util/util.pri b/src/compositor/util/util.pri
deleted file mode 100644
index fe5e9e606..000000000
--- a/src/compositor/util/util.pri
+++ /dev/null
@@ -1,5 +0,0 @@
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/waylandobject.h
-
diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp
index 1dc2a8700..f2c69fd73 100644
--- a/src/compositor/wayland_wrapper/wlcompositor.cpp
+++ b/src/compositor/wayland_wrapper/wlcompositor.cpp
@@ -40,7 +40,6 @@
#include "wlcompositor.h"
-#include "waylandobject.h"
#include "wldisplay.h"
#include "wlshmbuffer.h"
#include "wlsurface.h"
@@ -144,9 +143,9 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
m_input = new InputDevice(this);
m_data_device_manager = new DataDeviceManager(this);
- wl_display_add_global(m_display->handle(),&wl_output_interface,m_output.base(),Output::output_bind_func);
+ wl_display_add_global(m_display->handle(),&wl_output_interface, &m_output,Output::output_bind_func);
- wl_display_add_global(m_display->handle(), &wl_shell_interface, m_shell.base(), Shell::bind_func);
+ wl_display_add_global(m_display->handle(), &wl_shell_interface, &m_shell, Shell::bind_func);
if (wl_display_add_socket(m_display->handle(), qt_compositor->socketName())) {
@@ -195,7 +194,7 @@ void Compositor::createSurface(struct wl_client *client, int id)
QList<struct wl_client *> prevClientList = clients();
m_surfaces << surface;
if (!prevClientList.contains(client)) {
- m_windowManagerIntegration->setScreenOrientation(client, m_output.base(), m_orientation);
+ m_windowManagerIntegration->setScreenOrientation(client, m_output.resourceForClient(client), m_orientation);
emit clientAdded(client);
}
@@ -383,7 +382,7 @@ void Compositor::setScreenOrientation(Qt::ScreenOrientation orientation)
QList<struct wl_client*> clientList = clients();
for (int i = 0; i < clientList.length(); ++i) {
struct wl_client *client = clientList.at(i);
- m_windowManagerIntegration->setScreenOrientation(client, m_output.base(), orientation);
+ m_windowManagerIntegration->setScreenOrientation(client, m_output.resourceForClient(client), orientation);
}
}
diff --git a/src/compositor/wayland_wrapper/wldatadevicemanager.cpp b/src/compositor/wayland_wrapper/wldatadevicemanager.cpp
index b4f15a686..e1cf7c5bb 100644
--- a/src/compositor/wayland_wrapper/wldatadevicemanager.cpp
+++ b/src/compositor/wayland_wrapper/wldatadevicemanager.cpp
@@ -54,7 +54,7 @@ DataDeviceManager::DataDeviceManager(Compositor *compositor)
: m_compositor(compositor)
, m_current_selection_source(0)
{
- wl_display_add_global(compositor->wl_display(), &wl_data_device_manager_interface, base(), DataDeviceManager::bind_func_drag);
+ wl_display_add_global(compositor->wl_display(), &wl_data_device_manager_interface, this, DataDeviceManager::bind_func_drag);
}
void DataDeviceManager::setCurrentSelectionSource(DataSource *source)
diff --git a/src/compositor/wayland_wrapper/wldatadevicemanager.h b/src/compositor/wayland_wrapper/wldatadevicemanager.h
index 87398c4cf..a217ec7a6 100644
--- a/src/compositor/wayland_wrapper/wldatadevicemanager.h
+++ b/src/compositor/wayland_wrapper/wldatadevicemanager.h
@@ -41,8 +41,6 @@
#ifndef WLDATADEVICEMANAGER_H
#define WLDATADEVICEMANAGER_H
-#include "waylandobject.h"
-
#include "wlcompositor.h"
#include <QtCore/QList>
@@ -57,7 +55,7 @@ class Compositor;
class DataDevice;
class DataSource;
-class DataDeviceManager : public Object<struct wl_object>
+class DataDeviceManager
{
public:
DataDeviceManager(Compositor *compositor);
diff --git a/src/compositor/wayland_wrapper/wldataoffer.cpp b/src/compositor/wayland_wrapper/wldataoffer.cpp
index 882337352..d95be2b14 100644
--- a/src/compositor/wayland_wrapper/wldataoffer.cpp
+++ b/src/compositor/wayland_wrapper/wldataoffer.cpp
@@ -63,17 +63,15 @@ DataOffer::~DataOffer()
struct wl_resource *DataOffer::addDataDeviceResource(struct wl_resource *data_device_resource)
{
- for (int i = 0; i < m_clients_data_resource.size(); i++) {
- if (m_clients_data_resource.at(i)->client == data_device_resource->client) {
- qDebug() << "This should not happen, the client tries to add twice to a data offer";
- return 0;
- }
+ 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_resource_post_event(data_device_resource,WL_DATA_DEVICE_DATA_OFFER,new_object);
- m_clients_data_resource.append(new_object);
+ registerResource(new_object);
QList<QByteArray> offer_list = m_data_source->offerList();
for (int i = 0; i < offer_list.size(); i++) {
wl_resource_post_event(new_object, WL_DATA_OFFER_OFFER, offer_list.at(i).constData());
@@ -81,18 +79,6 @@ struct wl_resource *DataOffer::addDataDeviceResource(struct wl_resource *data_de
return new_object;
}
-void DataOffer::removeClient(struct wl_client *client)
-{
- for (int i = 0; i < m_clients_data_resource.size(); i++) {
- struct wl_resource *resource = m_clients_data_resource.at(i);
- if (resource->client == client) {
- wl_resource_destroy(resource,Compositor::currentTimeMsecs());
- m_clients_data_resource.removeAt(i);
- break;
- }
- }
-}
-
const struct wl_data_offer_interface DataOffer::data_interface = {
DataOffer::accept,
DataOffer::receive,
@@ -115,11 +101,11 @@ void DataOffer::receive(wl_client *client, wl_resource *resource, const char *mi
void DataOffer::destroy(wl_client *client, wl_resource *resource)
{
+ Q_UNUSED(client);
qDebug() << "dataOFFER DESTROY!";
DataOffer *data_offer = static_cast<DataOffer *>(resource->data);
- data_offer->removeClient(client);
- if (data_offer->m_clients_data_resource.size() == 0) {
+ if (data_offer->resourceListIsEmpty()) {
delete data_offer;
}
}
diff --git a/src/compositor/wayland_wrapper/wldataoffer.h b/src/compositor/wayland_wrapper/wldataoffer.h
index 5db80f62b..7b0d470ee 100644
--- a/src/compositor/wayland_wrapper/wldataoffer.h
+++ b/src/compositor/wayland_wrapper/wldataoffer.h
@@ -43,22 +43,21 @@
#include "wldatasource.h"
+#include "waylandresourcecollection.h"
+
namespace Wayland
{
-class DataOffer
+class DataOffer : public ResourceCollection
{
public:
DataOffer(DataSource *data_source);
~DataOffer();
struct wl_resource *addDataDeviceResource(struct wl_resource *client_resource);
- void removeClient(struct wl_client *client);
private:
DataSource *m_data_source;
- QList<struct wl_resource *> m_clients_data_resource;
-
static void accept(struct wl_client *client,
struct wl_resource *resource,
uint32_t time,
diff --git a/src/compositor/wayland_wrapper/wlinputdevice.cpp b/src/compositor/wayland_wrapper/wlinputdevice.cpp
index a7ce0d43a..60ccabe16 100644
--- a/src/compositor/wayland_wrapper/wlinputdevice.cpp
+++ b/src/compositor/wayland_wrapper/wlinputdevice.cpp
@@ -54,6 +54,7 @@ namespace Wayland {
static ShmBuffer *currentCursor;
InputDevice::InputDevice(Compositor *compositor)
+ : m_compositor(compositor)
{
wl_input_device_init(base());
wl_display_add_global(compositor->wl_display(),&wl_input_device_interface,this,InputDevice::bind_func);
@@ -119,10 +120,10 @@ void InputDevice::input_device_attach(struct wl_client *client,
struct wl_buffer *buffer = reinterpret_cast<struct wl_buffer *>(buffer_resource);
qDebug() << "Client input device attach" << client << buffer << x << y;
-// Compositor *compositor = wayland_cast<Compositor *>(device_base->compositor);
+ InputDevice *inputDevice = wayland_cast<InputDevice *>(device_base);
ShmBuffer *shmBuffer = static_cast<ShmBuffer *>(buffer->user_data);
if (shmBuffer) {
-// compositor->qtCompositor()->changeCursor(shmBuffer->image(), x, y);
+ inputDevice->m_compositor->qtCompositor()->changeCursor(shmBuffer->image(), x, y);
currentCursor = shmBuffer;
}
}
diff --git a/src/compositor/wayland_wrapper/wlinputdevice.h b/src/compositor/wayland_wrapper/wlinputdevice.h
index 7ea56a918..c70e835e7 100644
--- a/src/compositor/wayland_wrapper/wlinputdevice.h
+++ b/src/compositor/wayland_wrapper/wlinputdevice.h
@@ -42,6 +42,9 @@
#define WLINPUTDEVICE_H
#include "waylandobject.h"
+
+#include <stdint.h>
+
#include <QtCore/QList>
namespace Wayland {
@@ -71,6 +74,7 @@ public:
static void destroy_resource(struct wl_resource *resource);
private:
+ Compositor *m_compositor;
QList<DataDevice *>m_data_devices;
};
diff --git a/src/compositor/wayland_wrapper/wloutput.cpp b/src/compositor/wayland_wrapper/wloutput.cpp
index 0f61bc051..0221107f0 100644
--- a/src/compositor/wayland_wrapper/wloutput.cpp
+++ b/src/compositor/wayland_wrapper/wloutput.cpp
@@ -52,6 +52,7 @@ void Output::output_bind_func(struct wl_client *client, void *data,
Output *output = static_cast<Output *>(data);
struct wl_resource *resource = wl_client_add_object(client,&wl_output_interface,0,id,data);
+ output->registerResource(resource);
wl_resource_post_event(resource, WL_OUTPUT_GEOMETRY, 0, 0,
output->size().width(), output->size().height(),0,"","");
diff --git a/src/compositor/wayland_wrapper/wloutput.h b/src/compositor/wayland_wrapper/wloutput.h
index 84c91a2f5..30ce64b2a 100644
--- a/src/compositor/wayland_wrapper/wloutput.h
+++ b/src/compositor/wayland_wrapper/wloutput.h
@@ -41,13 +41,13 @@
#ifndef WL_OUTPUT_H
#define WL_OUTPUT_H
-#include "waylandobject.h"
+#include "waylandresourcecollection.h"
#include <QtCore/QRect>
namespace Wayland {
-class Output : public Object<struct wl_object>
+class Output : public ResourceCollection
{
public:
Output();
diff --git a/src/compositor/wayland_wrapper/wlshell.h b/src/compositor/wayland_wrapper/wlshell.h
index 25262e9cc..981c31f02 100644
--- a/src/compositor/wayland_wrapper/wlshell.h
+++ b/src/compositor/wayland_wrapper/wlshell.h
@@ -41,13 +41,13 @@
#ifndef WLSHELL_H
#define WLSHELL_H
-#include "waylandobject.h"
+#include "waylandresourcecollection.h"
namespace Wayland {
class Compositor;
-class Shell : public Object<struct wl_object>
+class Shell
{
public:
Shell(Compositor *compositor);
diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h
index 96c9bc415..11262cf37 100644
--- a/src/compositor/wayland_wrapper/wlsurface.h
+++ b/src/compositor/wayland_wrapper/wlsurface.h
@@ -43,10 +43,11 @@
#include "waylandexport.h"
-#include "waylandobject.h"
#include "wlshmbuffer.h"
#include "waylandsurface.h"
+#include "waylandobject.h"
+
#include <QtCore/QRect>
#include <QtGui/QImage>
diff --git a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
index 90375e19e..b4e27b07e 100644
--- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
+++ b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
@@ -41,7 +41,6 @@
#include "waylandwindowmanagerintegration.h"
-#include "waylandobject.h"
#include "wayland_wrapper/wldisplay.h"
#include "wayland_wrapper/wlcompositor.h"
@@ -71,14 +70,14 @@ WaylandManagedClient *WindowManagerServerIntegration::managedClient(wl_client *c
void WindowManagerServerIntegration::setVisibilityOnScreen(wl_client *client, bool visible)
{
- struct wl_resource *win_mgr_resource = getWindowManagerResourceForClient(client);
+ struct wl_resource *win_mgr_resource = resourceForClient(client);
wl_resource_post_event(win_mgr_resource,WL_WINDOWMANAGER_CLIENT_ONSCREEN_VISIBILITY,visible);
}
-void WindowManagerServerIntegration::setScreenOrientation(wl_client *client, wl_object *output, Qt::ScreenOrientation orientation)
+void WindowManagerServerIntegration::setScreenOrientation(wl_client *client, wl_resource *output_resource, Qt::ScreenOrientation orientation)
{
- struct wl_resource *win_mgr_resource = getWindowManagerResourceForClient(client);
- wl_resource_post_event(win_mgr_resource,WL_WINDOWMANAGER_SET_SCREEN_ROTATION,output, qint32(orientation));
+ struct wl_resource *win_mgr_resource = resourceForClient(client);
+ wl_resource_post_event(win_mgr_resource,WL_WINDOWMANAGER_SET_SCREEN_ROTATION,output_resource, qint32(orientation));
}
// client -> server
@@ -103,7 +102,7 @@ void WindowManagerServerIntegration::setWindowProperty(wl_client *client, wl_sur
data.data = (void*) byteValue.constData();
data.alloc = 0;
- struct wl_resource *win_mgr_resource = getWindowManagerResourceForClient(client);
+ struct wl_resource *win_mgr_resource = resourceForClient(client);
wl_resource_post_event(win_mgr_resource,WL_WINDOWMANAGER_SET_GENERIC_PROPERTY,surface, name.toLatin1().constData(),&data);
}
@@ -126,32 +125,15 @@ void WindowManagerServerIntegration::authenticateWithToken(wl_client *client, co
emit clientAuthenticated(client);
}
-struct wl_resource *WindowManagerServerIntegration::getWindowManagerResourceForClient(wl_client *client) const
-{
- for (int i = 0; i < m_client_resources.size(); i++) {
- if (m_client_resources.at(i)->client == client) {
- return m_client_resources.at(i);
- }
- }
- return 0;
-}
-
void WindowManagerServerIntegration::bind_func(struct wl_client *client, void *data,
uint32_t version, uint32_t id)
{
Q_UNUSED(version);
WindowManagerServerIntegration *win_mgr = static_cast<WindowManagerServerIntegration *>(data);
struct wl_resource *resource = wl_client_add_object(client,&wl_windowmanager_interface,&windowmanager_interface,id,data);
- resource->destroy = destroy_resource;
- win_mgr->m_client_resources.append(resource);
+ win_mgr->registerResource(resource);
}
-void WindowManagerServerIntegration::destroy_resource(wl_resource *win_mgr_integration_resource)
-{
- WindowManagerServerIntegration *win_mgr = static_cast<WindowManagerServerIntegration *>(win_mgr_integration_resource->data);
- win_mgr->m_client_resources.removeOne(win_mgr_integration_resource);
- free(win_mgr_integration_resource);
-}
void WindowManagerServerIntegration::map_client_to_process(struct wl_client *client,
struct wl_resource *window_mgr_resource,
diff --git a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h
index 1ac449629..fdf9b8d45 100644
--- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h
+++ b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h
@@ -42,11 +42,12 @@
#ifndef WAYLANDWINDOWMANAGERINTEGRATION_H
#define WAYLANDWINDOWMANAGERINTEGRATION_H
+#include "waylandexport.h"
+#include "waylandresourcecollection.h"
+
#include <qwindowdefs.h>
#include <stdint.h>
-#include "waylandexport.h"
-
#include <QObject>
#include <QMap>
#include <QVariant>
@@ -61,7 +62,7 @@ namespace Wayland {
class WindowManagerObject;
class WaylandManagedClient;
-class Q_COMPOSITOR_EXPORT WindowManagerServerIntegration : public QObject
+class Q_COMPOSITOR_EXPORT WindowManagerServerIntegration : public QObject, private Wayland::ResourceCollection
{
Q_OBJECT
public:
@@ -72,7 +73,7 @@ public:
WaylandManagedClient *managedClient(wl_client *client) const;
void setVisibilityOnScreen(wl_client *client, bool visible);
- void setScreenOrientation(wl_client *client, wl_object *output, Qt::ScreenOrientation orientationInDegrees);
+ void setScreenOrientation(wl_client *client, struct wl_resource *output_resource, Qt::ScreenOrientation orientationInDegrees);
void updateWindowProperty(wl_client *client, struct wl_surface *surface, const char *name, struct wl_array *value);
void setWindowProperty(wl_client *client, struct wl_surface *surface, const QString &name, const QVariant &value);
@@ -88,9 +89,6 @@ private:
private:
QMap<wl_client*, WaylandManagedClient*> m_managedClients;
- QList<struct wl_resource *>m_client_resources;
- struct wl_resource *getWindowManagerResourceForClient(struct wl_client *client) const;
-
static void bind_func(struct wl_client *client, void *data,
uint32_t version, uint32_t id);
diff --git a/wayland_sha1.txt b/wayland_sha1.txt
index 5650e8ab8..8dec1782b 100644
--- a/wayland_sha1.txt
+++ b/wayland_sha1.txt
@@ -1,3 +1,3 @@
This version of Qt-Compositor is checked against the following sha1 from the
Wayland repository:
-58bb064afa3bfc706e3b30dd170804235aa272ea
+187eace6139754eae58a21303c808a270f70dc3f