From 3c6fd0190bfa8a37eb0ec029b78f1597474562c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 23 Mar 2015 09:54:37 +0100 Subject: [PATCH] [tests] Only use KWayland in the waylandclienttest No need for Wayland::Client any more - KWayland encapsulates the usage. --- tests/CMakeLists.txt | 4 ++-- tests/waylandclienttest.cpp | 45 +++++++++++-------------------------- tests/waylandclienttest.h | 4 ++-- 3 files changed, 17 insertions(+), 36 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d1d0036017..bacddc70b8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,13 +9,13 @@ set(screenedgeshowtest_SRCS screenedgeshowtest.cpp) add_executable(screenedgeshowtest ${screenedgeshowtest_SRCS}) target_link_libraries(screenedgeshowtest Qt5::Widgets Qt5::X11Extras KF5::WindowSystem ${XCB_XCB_LIBRARY}) -if (Wayland_Client_FOUND AND XKB_FOUND AND KF5Wayland_FOUND) +if (KF5Wayland_FOUND) add_definitions(-DSOURCE_DIR="${KWIN_SOURCE_DIR}") set(waylandclienttest_SRCS waylandclienttest.cpp ) add_executable(waylandclienttest ${waylandclienttest_SRCS}) - target_link_libraries(waylandclienttest Qt5::Core Qt5::Gui Wayland::Client KF5::WaylandClient) + target_link_libraries(waylandclienttest Qt5::Core Qt5::Gui KF5::WaylandClient) endif() if (HAVE_INPUT) diff --git a/tests/waylandclienttest.cpp b/tests/waylandclienttest.cpp index ce4ee479a5..28d9d61f11 100644 --- a/tests/waylandclienttest.cpp +++ b/tests/waylandclienttest.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -37,8 +38,6 @@ #include #include #include -// Wayland -#include #include @@ -58,10 +57,10 @@ WaylandClientTest::WaylandClientTest(QObject *parent) , m_connectionThread(new QThread(this)) , m_connectionThreadObject(new ConnectionThread(nullptr)) , m_eventQueue(nullptr) - , m_compositor(new Compositor(this)) - , m_output(new Output(this)) + , m_compositor(nullptr) + , m_output(nullptr) , m_surface(nullptr) - , m_shm(new ShmPool(this)) + , m_shm(nullptr) , m_timer(new QTimer(this)) { init(); @@ -79,27 +78,11 @@ void WaylandClientTest::init() connect(m_connectionThreadObject, &ConnectionThread::connected, this, [this]() { // create the event queue for the main gui thread - wl_display *display = m_connectionThreadObject->display(); - m_eventQueue = wl_display_create_queue(display); + m_eventQueue = new EventQueue(this); + m_eventQueue->setup(m_connectionThreadObject); // setup registry Registry *registry = new Registry(this); setupRegistry(registry); - - QAbstractEventDispatcher *dispatcher = QCoreApplication::instance()->eventDispatcher(); - connect(dispatcher, &QAbstractEventDispatcher::aboutToBlock, this, - [this]() { - wl_display_flush(m_connectionThreadObject->display()); - } - ); - }, - Qt::QueuedConnection); - connect(m_connectionThreadObject, &ConnectionThread::eventsRead, this, - [this]() { - if (!m_eventQueue) { - return; - } - wl_display_dispatch_queue_pending(m_connectionThreadObject->display(), m_eventQueue); - wl_display_flush(m_connectionThreadObject->display()); }, Qt::QueuedConnection); @@ -122,14 +105,13 @@ void WaylandClientTest::setupRegistry(Registry *registry) { connect(registry, &Registry::compositorAnnounced, this, [this, registry](quint32 name) { - m_compositor->setup(registry->bindCompositor(name, 1)); + m_compositor = registry->createCompositor(name, 1, this); m_surface = m_compositor->createSurface(this); } ); connect(registry, &Registry::shellAnnounced, this, [this, registry](quint32 name) { - Shell *shell = new Shell(this); - shell->setup(registry->bindShell(name, 1)); + Shell *shell = registry->createShell(name, 1, this); ShellSurface *shellSurface = shell->createSurface(m_surface, m_surface); shellSurface->setFullscreen(m_output); connect(shellSurface, &ShellSurface::sizeChanged, this, static_cast(&WaylandClientTest::render)); @@ -137,20 +119,20 @@ void WaylandClientTest::setupRegistry(Registry *registry) ); connect(registry, &Registry::outputAnnounced, this, [this, registry](quint32 name) { - if (m_output->isValid()) { + if (m_output) { return; } - m_output->setup(registry->bindOutput(name, 2)); + m_output = registry->createOutput(name, 2, this); } ); connect(registry, &Registry::shmAnnounced, this, [this, registry](quint32 name) { - m_shm->setup(registry->bindShm(name, 1)); + m_shm = registry->createShmPool(name, 1, this); } ); connect(registry, &Registry::seatAnnounced, this, [this, registry](quint32 name) { - Seat *s = new Seat(this); + Seat *s = registry->createSeat(name, 2, this); connect(s, &Seat::hasKeyboardChanged, this, [this, s](bool has) { if (!has) { @@ -192,11 +174,10 @@ void WaylandClientTest::setupRegistry(Registry *registry) ); } ); - s->setup(registry->bindSeat(name, 2)); } ); registry->create(m_connectionThreadObject->display()); - wl_proxy_set_queue((wl_proxy*)registry->registry(), m_eventQueue); + registry->setEventQueue(m_eventQueue); registry->setup(); } diff --git a/tests/waylandclienttest.h b/tests/waylandclienttest.h index 936312aeab..b1ae7d8575 100644 --- a/tests/waylandclienttest.h +++ b/tests/waylandclienttest.h @@ -29,6 +29,7 @@ namespace Client { class Compositor; class ConnectionThread; +class EventQueue; class Output; class Registry; class ShmPool; @@ -38,7 +39,6 @@ class Surface; class QThread; class QTimer; -struct wl_event_queue; class WaylandClientTest : public QObject { @@ -55,7 +55,7 @@ private: void toggleTimer(); QThread *m_connectionThread; KWayland::Client::ConnectionThread *m_connectionThreadObject; - wl_event_queue *m_eventQueue; + KWayland::Client::EventQueue *m_eventQueue; KWayland::Client::Compositor *m_compositor; KWayland::Client::Output *m_output; KWayland::Client::Surface *m_surface;