summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor.cpp16
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor_p.h2
-rw-r--r--src/compositor/wayland_wrapper/qwlkeyboard.cpp3
-rw-r--r--src/compositor/wayland_wrapper/qwloutput.cpp4
-rw-r--r--src/compositor/wayland_wrapper/qwlpointer.cpp7
-rw-r--r--src/compositor/wayland_wrapper/qwlqtkey.cpp6
-rw-r--r--src/compositor/wayland_wrapper/qwltouch.cpp3
-rw-r--r--src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp16
-rw-r--r--src/qtwaylandscanner/qtwaylandscanner.cpp31
-rw-r--r--tests/auto/client/mockinput.cpp22
10 files changed, 28 insertions, 82 deletions
diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp
index ceded93bf..4f0e6ced9 100644
--- a/src/compositor/wayland_wrapper/qwlcompositor.cpp
+++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp
@@ -468,22 +468,6 @@ QList<QtWayland::Surface *> Compositor::surfacesForClient(wl_client *client)
return ret;
}
-wl_resource *Compositor::resourceForSurface(wl_list *resourceList, Surface *surface)
-{
- if (!surface)
- return 0;
-
- wl_resource *r;
- wl_client *surfaceClient = surface->resource()->client();
-
- wl_list_for_each(r, resourceList, link) {
- if (r->client == surfaceClient)
- return r;
- }
-
- return 0;
-}
-
void Compositor::configureTouchExtension(int flags)
{
if (m_touchExtension)
diff --git a/src/compositor/wayland_wrapper/qwlcompositor_p.h b/src/compositor/wayland_wrapper/qwlcompositor_p.h
index 3d0db994d..5e3c7be4e 100644
--- a/src/compositor/wayland_wrapper/qwlcompositor_p.h
+++ b/src/compositor/wayland_wrapper/qwlcompositor_p.h
@@ -148,8 +148,6 @@ public:
void scheduleReleaseBuffer(SurfaceBuffer *screenBuffer);
- static wl_resource *resourceForSurface(wl_list *resourceList, Surface *surface);
-
private slots:
void releaseBuffer(QPlatformScreenBuffer *screenBuffer);
diff --git a/src/compositor/wayland_wrapper/qwlkeyboard.cpp b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
index db0478b55..54349e300 100644
--- a/src/compositor/wayland_wrapper/qwlkeyboard.cpp
+++ b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
@@ -90,8 +90,7 @@ void Keyboard::setFocus(Surface *surface)
send_leave(m_focusResource->handle, serial, m_focus->resource()->handle);
}
- struct ::wl_resource *r = Compositor::resourceForSurface(resourceList(), surface);
- Resource *resource = r ? Resource::fromResource(r) : 0;
+ Resource *resource = surface ? resourceMap().value(surface->resource()->client()) : 0;
if (resource && (m_focus != surface || m_focusResource != resource)) {
uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
diff --git a/src/compositor/wayland_wrapper/qwloutput.cpp b/src/compositor/wayland_wrapper/qwloutput.cpp
index bb516f8c4..cfde82900 100644
--- a/src/compositor/wayland_wrapper/qwloutput.cpp
+++ b/src/compositor/wayland_wrapper/qwloutput.cpp
@@ -44,8 +44,6 @@
#include <QtGui/QScreen>
#include <QRect>
-#include "qwaylandresourcecollection.h"
-
QT_BEGIN_NAMESPACE
namespace QtWayland {
@@ -85,7 +83,7 @@ void OutputGlobal::setRefreshRate(int rate)
Output *OutputGlobal::outputForClient(wl_client *client) const
{
- return static_cast<Output *>(resourceForClient(resourceList(), client)->data);
+ return static_cast<Output *>(resourceMap().value(client));
}
} // namespace Wayland
diff --git a/src/compositor/wayland_wrapper/qwlpointer.cpp b/src/compositor/wayland_wrapper/qwlpointer.cpp
index c4f122a19..e1e1305e1 100644
--- a/src/compositor/wayland_wrapper/qwlpointer.cpp
+++ b/src/compositor/wayland_wrapper/qwlpointer.cpp
@@ -102,16 +102,15 @@ void Pointer::setFocus(Surface *surface, const QPointF &position)
send_leave(m_focusResource->handle, serial, m_focus->resource()->handle);
}
- struct ::wl_resource *r = Compositor::resourceForSurface(resourceList(), surface);
- Resource *resource = r ? Resource::fromResource(r) : 0;
+ Resource *resource = surface ? resourceMap().value(surface->resource()->client()) : 0;
if (resource && (m_focus != surface || resource != m_focusResource)) {
uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
Keyboard *keyboard = m_seat->keyboardDevice();
if (keyboard) {
- struct ::wl_resource *kr = Compositor::resourceForSurface(keyboard->resourceList(), surface);
+ wl_keyboard::Resource *kr = keyboard->resourceMap().value(surface->resource()->client());
if (kr)
- keyboard->sendKeyModifiers(wl_keyboard::Resource::fromResource(kr), serial);
+ keyboard->sendKeyModifiers(kr, serial);
}
send_enter(resource->handle, serial, surface->resource()->handle,
wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y()));
diff --git a/src/compositor/wayland_wrapper/qwlqtkey.cpp b/src/compositor/wayland_wrapper/qwlqtkey.cpp
index 6ced27881..a2b99ebc1 100644
--- a/src/compositor/wayland_wrapper/qwlqtkey.cpp
+++ b/src/compositor/wayland_wrapper/qwlqtkey.cpp
@@ -57,14 +57,12 @@ QtKeyExtensionGlobal::QtKeyExtensionGlobal(Compositor *compositor)
bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface)
{
- wl_client *surfaceClient = surface->resource()->client();
-
uint32_t time = m_compositor->currentTimeMsecs();
- struct wl_resource *target = resourceForClient(resourceList(), surfaceClient);
+ Resource *target = surface ? resourceMap().value(surface->resource()->client()) : 0;
if (target) {
- send_qtkey(target,
+ send_qtkey(target->handle,
time, event->type(), event->key(), event->modifiers(),
event->nativeScanCode(),
event->nativeVirtualKey(),
diff --git a/src/compositor/wayland_wrapper/qwltouch.cpp b/src/compositor/wayland_wrapper/qwltouch.cpp
index 54290136e..e595440d7 100644
--- a/src/compositor/wayland_wrapper/qwltouch.cpp
+++ b/src/compositor/wayland_wrapper/qwltouch.cpp
@@ -57,8 +57,7 @@ Touch::Touch(Compositor *compositor)
void Touch::setFocus(Surface *surface)
{
m_focus = surface;
- struct ::wl_resource *r = Compositor::resourceForSurface(resourceList(), surface);
- m_focusResource = r ? Resource::fromResource(r) : 0;
+ m_focusResource = surface ? resourceMap().value(surface->resource()->client()) : 0;
}
void Touch::sendCancel()
diff --git a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
index 414260305..f2fa21407 100644
--- a/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
+++ b/src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
@@ -71,21 +71,17 @@ void WindowManagerServerIntegration::initialize(QtWayland::Display *waylandDispl
void WindowManagerServerIntegration::setShowIsFullScreen(bool value)
{
m_showIsFullScreen = value;
- struct wl_resource *resource;
- wl_list_for_each(resource, resourceList(), link) {
- send_hints(resource, static_cast<int32_t>(m_showIsFullScreen));
+ Q_FOREACH (Resource *resource, resourceMap().values()) {
+ send_hints(resource->handle, static_cast<int32_t>(m_showIsFullScreen));
}
}
void WindowManagerServerIntegration::sendQuitMessage(wl_client *client)
{
- struct wl_resource *resource;
- wl_list_for_each(resource, resourceList(), link) {
- if (resource->client == client) {
- send_quit(resource);
- return;
- }
- }
+ Resource *resource = resourceMap().value(client);
+
+ if (resource)
+ send_quit(resource->handle);
}
void WindowManagerServerIntegration::windowmanager_bind_resource(Resource *resource)
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp
index 0df2d0c37..5de7cb11d 100644
--- a/src/qtwaylandscanner/qtwaylandscanner.cpp
+++ b/src/qtwaylandscanner/qtwaylandscanner.cpp
@@ -366,6 +366,7 @@ void process(QXmlStreamReader &xml)
printf("#include \"wayland-server.h\"\n");
printf("#include \"wayland-%s-server-protocol.h\"\n", QByteArray(protocolName).replace('_', '-').constData());
printf("#include <QByteArray>\n");
+ printf("#include <QMultiMap>\n");
printf("#include <QString>\n");
printf("\n");
@@ -423,8 +424,8 @@ void process(QXmlStreamReader &xml)
printf(" Resource *resource() { return m_resource; }\n");
printf(" const Resource *resource() const { return m_resource; }\n");
printf("\n");
- printf(" struct ::wl_list *resourceList() { return &m_resource_list; }\n");
- printf(" const struct ::wl_list *resourceList() const { return &m_resource_list; }\n");
+ printf(" QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; }\n");
+ printf(" const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; }\n");
printf("\n");
printf(" bool isGlobal() const { return m_global != 0; }\n");
printf(" bool isResource() const { return m_resource != 0; }\n");
@@ -485,8 +486,8 @@ void process(QXmlStreamReader &xml)
}
printf("\n");
+ printf(" QMultiMap<struct ::wl_client*, Resource*> m_resource_map;\n");
printf(" Resource *m_resource;\n");
- printf(" struct ::wl_list m_resource_list;\n");
printf(" struct ::wl_global *m_global;\n");
printf(" };\n");
@@ -526,28 +527,28 @@ void process(QXmlStreamReader &xml)
const char *interfaceNameStripped = stripped.constData();
printf(" %s::%s(struct ::wl_client *client, int id)\n", interfaceName, interfaceName);
- printf(" : m_resource(0)\n");
+ printf(" : m_resource_map()\n");
+ printf(" , m_resource(0)\n");
printf(" , m_global(0)\n");
printf(" {\n");
- printf(" wl_list_init(&m_resource_list);\n");
printf(" init(client, id);\n");
printf(" }\n");
printf("\n");
printf(" %s::%s(struct ::wl_display *display)\n", interfaceName, interfaceName);
- printf(" : m_resource(0)\n");
+ printf(" : m_resource_map()\n");
+ printf(" , m_resource(0)\n");
printf(" , m_global(0)\n");
printf(" {\n");
- printf(" wl_list_init(&m_resource_list);\n");
printf(" init(display);\n");
printf(" }\n");
printf("\n");
printf(" %s::%s()\n", interfaceName, interfaceName);
- printf(" : m_resource(0)\n");
+ printf(" : m_resource_map()\n");
+ printf(" , m_resource(0)\n");
printf(" , m_global(0)\n");
printf(" {\n");
- printf(" wl_list_init(&m_resource_list);\n");
printf(" }\n");
printf("\n");
@@ -564,14 +565,8 @@ void process(QXmlStreamReader &xml)
printf(" %s::Resource *%s::add(struct ::wl_client *client, int id)\n", interfaceName, interfaceName);
printf(" {\n");
- printf(" return add(&m_resource_list, client, id);\n");
- printf(" }\n");
- printf("\n");
-
- printf(" %s::Resource *%s::add(struct wl_list *resource_list, struct ::wl_client *client, int id)\n", interfaceName, interfaceName);
- printf(" {\n");
printf(" Resource *resource = bind(client, id);\n");
- printf(" wl_list_insert(resource_list, &resource->handle->link);\n");
+ printf(" m_resource_map.insert(client, resource);\n");
printf(" return resource;\n");
printf(" }\n");
printf("\n");
@@ -609,9 +604,8 @@ void process(QXmlStreamReader &xml)
printf(" {\n");
printf(" Resource *resource = Resource::fromResource(client_resource);\n");
printf(" %s *that = resource->%s;\n", interfaceName, interfaceNameStripped);
+ printf(" that->m_resource_map.remove(resource->client(), resource);\n");
printf(" that->%s_destroy_resource(resource);\n", interfaceNameStripped);
- printf(" if (client_resource->link.next)\n");
- printf(" wl_list_remove(&client_resource->link);\n");
printf(" delete resource;\n");
printf("#if !WAYLAND_VERSION_CHECK(1, 2, 0)\n");
printf(" free(client_resource);\n");
@@ -633,7 +627,6 @@ void process(QXmlStreamReader &xml)
printf(" handle->destroy = destroy_func;\n");
printf(" resource->handle = handle;\n");
printf(" %s_bind_resource(resource);\n", interfaceNameStripped);
- printf(" wl_list_init(&resource->handle->link);\n");
printf(" return resource;\n");
printf(" }\n");
diff --git a/tests/auto/client/mockinput.cpp b/tests/auto/client/mockinput.cpp
index ac2b666b4..40b01317f 100644
--- a/tests/auto/client/mockinput.cpp
+++ b/tests/auto/client/mockinput.cpp
@@ -137,22 +137,6 @@ Keyboard::~Keyboard()
{
}
-static wl_resource *resourceForSurface(wl_list *resourceList, Surface *surface)
-{
- if (!surface)
- return 0;
-
- wl_resource *r;
- wl_client *surfaceClient = surface->resource()->client();
-
- wl_list_for_each(r, resourceList, link) {
- if (r->client == surfaceClient)
- return r;
- }
-
- return 0;
-}
-
void Keyboard::setFocus(Surface *surface)
{
if (m_focusResource && m_focus != surface) {
@@ -160,8 +144,7 @@ void Keyboard::setFocus(Surface *surface)
send_leave(m_focusResource->handle, serial, m_focus->resource()->handle);
}
- struct ::wl_resource *r = resourceForSurface(resourceList(), surface);
- Resource *resource = r ? Resource::fromResource(r) : 0;
+ Resource *resource = surface ? resourceMap().value(surface->resource()->client()) : 0;
if (resource && (m_focus != surface || m_focusResource != resource)) {
uint32_t serial = m_compositor->nextSerial();
@@ -199,8 +182,7 @@ void Pointer::setFocus(Surface *surface, const QPoint &pos)
send_leave(m_focusResource->handle, serial, m_focus->resource()->handle);
}
- struct ::wl_resource *r = resourceForSurface(resourceList(), surface);
- Resource *resource = r ? Resource::fromResource(r) : 0;
+ Resource *resource = surface ? resourceMap().value(surface->resource()->client()) : 0;
if (resource && (m_focus != surface || resource != m_focusResource)) {
uint32_t serial = m_compositor->nextSerial();