diff --git a/libinput/connection.cpp b/libinput/connection.cpp
index 04825bb873..d708894c87 100644
--- a/libinput/connection.cpp
+++ b/libinput/connection.cpp
@@ -25,6 +25,7 @@ along with this program. If not, see .
#include "libinput_logging.h"
#include
+#include
#include
@@ -34,6 +35,7 @@ namespace LibInput
{
Connection *Connection::s_self = nullptr;
+QThread *Connection::s_thread = nullptr;
static Context *s_context = nullptr;
@@ -67,7 +69,13 @@ Connection *Connection::create(QObject *parent)
return nullptr;
}
}
- s_self = new Connection(s_context, parent);
+ s_thread = new QThread();
+ s_self = new Connection(s_context);
+ s_self->moveToThread(s_thread);
+ s_thread->start();
+ QObject::connect(s_thread, &QThread::finished, s_self, &QObject::deleteLater);
+ QObject::connect(s_thread, &QThread::finished, s_thread, &QObject::deleteLater);
+ QObject::connect(parent, &QObject::destroyed, s_thread, &QThread::quit);
return s_self;
}
diff --git a/libinput/connection.h b/libinput/connection.h
index 934d41c4ba..a34ed2131f 100644
--- a/libinput/connection.h
+++ b/libinput/connection.h
@@ -27,6 +27,7 @@ along with this program. If not, see .
#include
class QSocketNotifier;
+class QThread;
namespace KWin
{
@@ -91,6 +92,7 @@ private:
bool m_touchBeforeSuspend = false;
KWIN_SINGLETON(Connection)
+ static QThread *s_thread;
};
}