summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor/mockclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/compositor/compositor/mockclient.cpp')
-rw-r--r--tests/auto/compositor/compositor/mockclient.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/auto/compositor/compositor/mockclient.cpp b/tests/auto/compositor/compositor/mockclient.cpp
index 970890a65..85a89f04c 100644
--- a/tests/auto/compositor/compositor/mockclient.cpp
+++ b/tests/auto/compositor/compositor/mockclient.cpp
@@ -42,13 +42,12 @@
const struct wl_registry_listener MockClient::registryListener = {
MockClient::handleGlobal,
- nullptr
+ MockClient::handleGlobalRemove
};
MockClient::MockClient()
: display(wl_display_connect("wayland-qt-test-0"))
, compositor(0)
- , output(0)
, registry(0)
, wlshell(0)
, xdgShell(nullptr)
@@ -75,9 +74,9 @@ MockClient::MockClient()
timeout.start();
do {
QCoreApplication::processEvents();
- } while (!(compositor && output) && timeout.elapsed() < 1000);
+ } while (!(compositor && !m_outputs.isEmpty()) && timeout.elapsed() < 1000);
- if (!compositor || !output)
+ if (!compositor || m_outputs.empty())
qFatal("MockClient(): failed to receive globals from display");
}
@@ -166,12 +165,18 @@ void MockClient::handleGlobal(void *data, wl_registry *registry, uint32_t id, co
resolve(data)->handleGlobal(id, QByteArray(interface));
}
+void MockClient::handleGlobalRemove(void *data, wl_registry *wl_registry, uint32_t id)
+{
+ resolve(data)->handleGlobalRemove(id);
+}
+
void MockClient::handleGlobal(uint32_t id, const QByteArray &interface)
{
if (interface == "wl_compositor") {
compositor = static_cast<wl_compositor *>(wl_registry_bind(registry, id, &wl_compositor_interface, 1));
} else if (interface == "wl_output") {
- output = static_cast<wl_output *>(wl_registry_bind(registry, id, &wl_output_interface, 2));
+ auto output = static_cast<wl_output *>(wl_registry_bind(registry, id, &wl_output_interface, 2));
+ m_outputs.append(output);
wl_output_add_listener(output, &outputListener, this);
} else if (interface == "wl_shm") {
shm = static_cast<wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface, 1));
@@ -187,6 +192,15 @@ void MockClient::handleGlobal(uint32_t id, const QByteArray &interface)
}
}
+void MockClient::handleGlobalRemove(uint32_t id)
+{
+ for (auto output : m_outputs) {
+ auto outputId = wl_proxy_get_id(reinterpret_cast<wl_proxy *>(output));
+ if (outputId == id)
+ m_outputs.removeAll(output);
+ }
+}
+
wl_surface *MockClient::createSurface()
{
flushDisplay();