From 1cfd72f49fff8dca953616ef6467f564df13afb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 2 Sep 2015 10:12:18 +0200 Subject: [PATCH] [libinput] Use a dedicated thread for libinput When the Connection is created we move it into a dedicated thread so that even processing happens in the thread. Currently all events are still queued directly. --- libinput/connection.cpp | 10 +++++++++- libinput/connection.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) 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; }; }