[libinput] Expose all input devices through DBus

Summary:
The Connection exposes a new service called org.kde.KWin.InputDevice
and every Device registers an own object exposing all properties.

This allows an external configuration tool to change the behavior of
the devices at runtime. E.g. to test configuration settings.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2407
This commit is contained in:
Martin Gräßlin 2016-05-13 10:04:28 +02:00
parent 8bbd53a774
commit ab5d31426a
4 changed files with 19 additions and 6 deletions

View file

@ -5,7 +5,7 @@ include_directories(${UDEV_INCLUDE_DIR})
########################################################
set( testLibinputDevice_SRCS device_test.cpp mock_libinput.cpp ../../libinput/device.cpp )
add_executable(testLibinputDevice ${testLibinputDevice_SRCS})
target_link_libraries( testLibinputDevice Qt5::Test)
target_link_libraries( testLibinputDevice Qt5::Test Qt5::DBus)
add_test(kwin-testLibinputDevice testLibinputDevice)
ecm_mark_as_test(testLibinputDevice)
@ -19,7 +19,7 @@ set( testLibinputKeyEvent_SRCS
../../libinput/events.cpp
)
add_executable(testLibinputKeyEvent ${testLibinputKeyEvent_SRCS})
target_link_libraries( testLibinputKeyEvent Qt5::Test Qt5::Widgets KF5::ConfigCore)
target_link_libraries( testLibinputKeyEvent Qt5::Test Qt5::DBus Qt5::Widgets KF5::ConfigCore)
add_test(kwin-testLibinputKeyEvent testLibinputKeyEvent)
ecm_mark_as_test(testLibinputKeyEvent)
@ -33,7 +33,7 @@ set( testLibinputPointerEvent_SRCS
../../libinput/events.cpp
)
add_executable(testLibinputPointerEvent ${testLibinputPointerEvent_SRCS})
target_link_libraries( testLibinputPointerEvent Qt5::Test Qt5::Widgets KF5::ConfigCore)
target_link_libraries( testLibinputPointerEvent Qt5::Test Qt5::DBus Qt5::Widgets KF5::ConfigCore)
add_test(kwin-testLibinputPointerEvent testLibinputPointerEvent)
ecm_mark_as_test(testLibinputPointerEvent)
@ -47,7 +47,7 @@ set( testLibinputTouchEvent_SRCS
../../libinput/events.cpp
)
add_executable(testLibinputTouchEvent ${testLibinputTouchEvent_SRCS})
target_link_libraries( testLibinputTouchEvent Qt5::Test Qt5::Widgets KF5::ConfigCore)
target_link_libraries( testLibinputTouchEvent Qt5::Test Qt5::DBus Qt5::Widgets KF5::ConfigCore)
add_test(kwin-testLibinputTouchEvent testLibinputTouchEvent)
ecm_mark_as_test(testLibinputTouchEvent)
@ -61,7 +61,7 @@ set( testLibinputGestureEvent_SRCS
../../libinput/events.cpp
)
add_executable(testLibinputGestureEvent ${testLibinputGestureEvent_SRCS})
target_link_libraries( testLibinputGestureEvent Qt5::Test Qt5::Widgets KF5::ConfigCore)
target_link_libraries( testLibinputGestureEvent Qt5::Test Qt5::DBus Qt5::Widgets KF5::ConfigCore)
add_test(kwin-testLibinputGestureEvent testLibinputGestureEvent)
ecm_mark_as_test(testLibinputGestureEvent)
@ -94,6 +94,6 @@ ecm_mark_as_test(testLibinputContext)
########################################################
set( testInputEvents_SRCS input_event_test.cpp mock_libinput.cpp ../../libinput/device.cpp ../../input_event.cpp )
add_executable(testInputEvents ${testInputEvents_SRCS})
target_link_libraries( testInputEvents Qt5::Test Qt5::Gui)
target_link_libraries( testInputEvents Qt5::Test Qt5::DBus Qt5::Gui)
add_test(kwin-testInputEvents testInputEvents)
ecm_mark_as_test(testInputEvents)

View file

@ -88,6 +88,7 @@ Connection *Connection::create(QObject *parent)
}
static const QString s_touchpadComponent = QStringLiteral("kcm_touchpad");
static const QString s_serviceName = QStringLiteral("org.kde.KWin.InputDevice");
Connection::Connection(Context *input, QObject *parent)
: QObject(parent)
@ -140,10 +141,13 @@ Connection::Connection(Context *input, QObject *parent)
// need to connect to KGlobalSettings as the mouse KCM does not emit a dedicated signal
QDBusConnection::sessionBus().connect(QString(), QStringLiteral("/KGlobalSettings"), QStringLiteral("org.kde.KGlobalSettings"),
QStringLiteral("notifyChange"), this, SLOT(slotKGlobalSettingsNotifyChange(int,int)));
QDBusConnection::sessionBus().registerService(s_serviceName);
}
Connection::~Connection()
{
QDBusConnection::sessionBus().unregisterService(s_serviceName);
s_self = nullptr;
delete s_context;
s_context = nullptr;

View file

@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "device.h"
#include <libinput.h>
#include <QDBusConnection>
#include <linux/input.h>
#include <config-kwin.h>
@ -143,11 +145,17 @@ Device::Device(libinput_device *device, QObject *parent)
}
s_devices << this;
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin/InputDevice/") + m_sysName,
QStringLiteral("org.kde.KWin.InputDevice"),
this,
QDBusConnection::ExportAllProperties
);
}
Device::~Device()
{
s_devices.removeOne(this);
QDBusConnection::sessionBus().unregisterObject(QStringLiteral("/org/kde/KWin/InputDevice/") + m_sysName);
libinput_device_unref(m_device);
}

View file

@ -34,6 +34,7 @@ namespace LibInput
class Device : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.InputDevice")
Q_PROPERTY(bool keyboard READ isKeyboard CONSTANT)
Q_PROPERTY(bool alphaNumericKeyboard READ isAlphaNumericKeyboard CONSTANT)
Q_PROPERTY(bool pointer READ isPointer CONSTANT)