KWin
Loading...
Searching...
No Matches
libinputbackend.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "libinputbackend.h"
8#include "connection.h"
9#include "device.h"
10
11namespace KWin
12{
13
14LibinputBackend::LibinputBackend(Session *session, QObject *parent)
15 : InputBackend(parent)
16{
17 m_thread.setObjectName(QStringLiteral("libinput-connection"));
18 m_thread.start();
19
20 m_connection = LibInput::Connection::create(session);
21 m_connection->moveToThread(&m_thread);
22
23 connect(
24 m_connection.get(), &LibInput::Connection::eventsRead, this, [this]() {
25 m_connection->processEvents();
26 },
27 Qt::QueuedConnection);
28
29 // Direct connection because the deviceAdded() and the deviceRemoved() signals are emitted
30 // from the main thread.
31 connect(m_connection.get(), &LibInput::Connection::deviceAdded,
32 this, &InputBackend::deviceAdded, Qt::DirectConnection);
33 connect(m_connection.get(), &LibInput::Connection::deviceRemoved,
34 this, &InputBackend::deviceRemoved, Qt::DirectConnection);
35}
36
38{
39 m_thread.quit();
40 m_thread.wait();
41}
42
44{
45 m_connection->setInputConfig(config());
46 m_connection->setup();
47}
48
50{
51 m_connection->updateScreens();
52}
53
54} // namespace KWin
55
56#include "moc_libinputbackend.cpp"
void deviceAdded(InputDevice *device)
KSharedConfigPtr config() const
void deviceRemoved(InputDevice *device)
void deviceAdded(KWin::LibInput::Device *)
void deviceRemoved(KWin::LibInput::Device *)
static std::unique_ptr< Connection > create(Session *session)
LibinputBackend(Session *session, QObject *parent=nullptr)
void updateScreens() override
void initialize() override