Commit a9e5343e authored by Martin Flöser's avatar Martin Flöser

[wayland] Use an event thread for the internal Wayland connection

parent 6294961b
......@@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Client
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/event_queue.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/surface.h>
// Server
......@@ -43,6 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Server/shell_interface.h>
// Qt
#include <QThread>
#include <QWindow>
// system
......@@ -61,7 +63,14 @@ WaylandServer::WaylandServer(QObject *parent)
{
}
WaylandServer::~WaylandServer() = default;
WaylandServer::~WaylandServer()
{
if (m_internalConnection.client) {
m_internalConnection.client->deleteLater();
m_internalConnection.clientThread->quit();
m_internalConnection.clientThread->wait();
}
}
void WaylandServer::init(const QByteArray &socketName)
{
......@@ -268,16 +277,23 @@ void WaylandServer::createInternalConnection()
}
m_internalConnection.server = m_display->createClient(sx[0]);
using namespace KWayland::Client;
m_internalConnection.client = new ConnectionThread(this);
m_internalConnection.client = new ConnectionThread();
m_internalConnection.client->setSocketFd(sx[1]);
m_internalConnection.clientThread = new QThread;
m_internalConnection.client->moveToThread(m_internalConnection.clientThread);
m_internalConnection.clientThread->start();
connect(m_internalConnection.client, &ConnectionThread::connected, this,
[this] {
Registry *registry = new Registry(m_internalConnection.client);
Registry *registry = new Registry(this);
EventQueue *eventQueue = new EventQueue(this);
eventQueue->setup(m_internalConnection.client);
registry->setEventQueue(eventQueue);
registry->create(m_internalConnection.client);
m_internalConnection.registry = registry;
connect(registry, &Registry::shmAnnounced, this,
[this] (quint32 name, quint32 version) {
m_internalConnection.shm = m_internalConnection.registry->createShmPool(name, version, m_internalConnection.client);
m_internalConnection.shm = m_internalConnection.registry->createShmPool(name, version, this);
}
);
registry->setup();
......
......@@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QObject>
class QThread;
class QWindow;
namespace KWayland
......@@ -159,6 +160,7 @@ private:
struct {
KWayland::Server::ClientConnection *server = nullptr;
KWayland::Client::ConnectionThread *client = nullptr;
QThread *clientThread = nullptr;
KWayland::Client::Registry *registry = nullptr;
KWayland::Client::ShmPool *shm = nullptr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment