[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.
This commit is contained in:
Martin Gräßlin 2015-09-02 10:12:18 +02:00
parent ea77d32259
commit 1cfd72f49f
2 changed files with 11 additions and 1 deletions

View file

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "libinput_logging.h"
#include <QSocketNotifier>
#include <QThread>
#include <libinput.h>
@ -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;
}

View file

@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QSize>
class QSocketNotifier;
class QThread;
namespace KWin
{
@ -91,6 +92,7 @@ private:
bool m_touchBeforeSuspend = false;
KWIN_SINGLETON(Connection)
static QThread *s_thread;
};
}