[libinput] Add more support for pointer devices, in particular touchpads

This patch is made in preparation for the Touchpad KCM for Wayland.

Summary:
* KWin has a Libinput version requirement bump to 1.5
* new isTouchpad property to distinguish touchpads from mice
* new lmrTapButtonMap property
* new disableWhileTyping property
* new pointerAccelerationProfile property
* new defaultPointerAcceleration property
* save to config mechanism added for new propertys and pointerAcceleration
* new D-Bus interface org.kde.KWin.InputDeviceManager and method devicesSysNames
* removed unnecessary additional D-Bus service name org.kde.KWin.InputDevice
* changing acceleration in the Mouse KCM doesn't influence touchpads anymore

Reviewers: #kwin, #plasma, davidedmundson

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3479
This commit is contained in:
Roman Gilg 2016-12-02 14:58:56 +01:00
parent c1e88d0af8
commit 7f16d83e04
8 changed files with 742 additions and 63 deletions

View file

@ -173,7 +173,7 @@ set_package_properties(XKB PROPERTIES
PURPOSE "Required for building KWin with Wayland support"
)
find_package(Libinput 1.2)
find_package(Libinput 1.5)
set_package_properties(Libinput PROPERTIES TYPE OPTIONAL PURPOSE "Required for input handling on Wayland.")
find_package(UDev)

View file

@ -45,6 +45,12 @@ private Q_SLOTS:
void testTapFingerCount();
void testSize_data();
void testSize();
void testDefaultPointerAcceleration_data();
void testDefaultPointerAcceleration();
void testDefaultPointerAccelerationProfileFlat_data();
void testDefaultPointerAccelerationProfileFlat();
void testDefaultPointerAccelerationProfileAdaptive_data();
void testDefaultPointerAccelerationProfileAdaptive();
void testLeftHandedEnabledByDefault_data();
void testLeftHandedEnabledByDefault();
void testTapEnabledByDefault_data();
@ -59,6 +65,10 @@ private Q_SLOTS:
void testScrollEdgeEnabledByDefault();
void testScrollOnButtonDownEnabledByDefault_data();
void testScrollOnButtonDownEnabledByDefault();
void testDisableWhileTypingEnabledByDefault_data();
void testDisableWhileTypingEnabledByDefault();
void testLmrTapButtonMapEnabledByDefault_data();
void testLmrTapButtonMapEnabledByDefault();
void testSupportsDisableWhileTyping_data();
void testSupportsDisableWhileTyping();
void testSupportsPointerAcceleration_data();
@ -115,8 +125,16 @@ private Q_SLOTS:
void testScrollButtonDown();
void testScrollButton_data();
void testScrollButton();
void testDisableWhileTyping_data();
void testDisableWhileTyping();
void testLmrTapButtonMap_data();
void testLmrTapButtonMap();
void testLoadEnabled_data();
void testLoadEnabled();
void testLoadPointerAcceleration_data();
void testLoadPointerAcceleration();
void testLoadPointerAccelerationProfile_data();
void testLoadPointerAccelerationProfile();
void testLoadTapToClick_data();
void testLoadTapToClick();
void testLoadTapAndDrag_data();
@ -131,6 +149,10 @@ private Q_SLOTS:
void testLoadScrollMethod();
void testLoadScrollButton_data();
void testLoadScrollButton();
void testLoadDisableWhileTyping_data();
void testLoadDisableWhileTyping();
void testLoadLmrTapButtonMap_data();
void testLoadLmrTapButtonMap();
void testLoadLeftHanded_data();
void testLoadLeftHanded();
};
@ -441,6 +463,44 @@ void TestLibinputDevice::testScrollEdgeEnabledByDefault()
QCOMPARE(d.property("scrollEdgeEnabledByDefault").toBool(), enabled);
}
void TestLibinputDevice::testDefaultPointerAccelerationProfileFlat_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testDefaultPointerAccelerationProfileFlat()
{
QFETCH(bool, enabled);
libinput_device device;
device.defaultPointerAccelerationProfile = enabled ? LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT : LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
Device d(&device);
QCOMPARE(d.defaultPointerAccelerationProfileFlat(), enabled);
QCOMPARE(d.property("defaultPointerAccelerationProfileFlat").toBool(), enabled);
}
void TestLibinputDevice::testDefaultPointerAccelerationProfileAdaptive_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testDefaultPointerAccelerationProfileAdaptive()
{
QFETCH(bool, enabled);
libinput_device device;
device.defaultPointerAccelerationProfile = enabled ? LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE : LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
Device d(&device);
QCOMPARE(d.defaultPointerAccelerationProfileAdaptive(), enabled);
QCOMPARE(d.property("defaultPointerAccelerationProfileAdaptive").toBool(), enabled);
}
void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault_data()
{
QTest::addColumn<bool>("enabled");
@ -695,6 +755,28 @@ void TestLibinputDevice::testSupportsScrollOnButtonDown()
QCOMPARE(d.property("supportsScrollOnButtonDown").toBool(), enabled);
}
void TestLibinputDevice::testDefaultPointerAcceleration_data()
{
QTest::addColumn<qreal>("accel");
QTest::newRow("-1.0") << -1.0;
QTest::newRow("-0.5") << -0.5;
QTest::newRow("0.0") << 0.0;
QTest::newRow("0.3") << 0.3;
QTest::newRow("1.0") << 1.0;
}
void TestLibinputDevice::testDefaultPointerAcceleration()
{
QFETCH(qreal, accel);
libinput_device device;
device.defaultPointerAcceleration = accel;
Device d(&device);
QCOMPARE(d.defaultPointerAcceleration(), accel);
QCOMPARE(d.property("defaultPointerAcceleration").toReal(), accel);
}
void TestLibinputDevice::testPointerAcceleration_data()
{
QTest::addColumn<bool>("supported");
@ -1298,6 +1380,135 @@ void TestLibinputDevice::testScrollButton()
QCOMPARE(scrollButtonChangedSpy.isEmpty(), initValue == expectedValue);
}
void TestLibinputDevice::testDisableWhileTypingEnabledByDefault_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testDisableWhileTypingEnabledByDefault()
{
QFETCH(bool, enabled);
libinput_device device;
device.disableWhileTypingEnabledByDefault = enabled ? LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED;
Device d(&device);
QCOMPARE(d.disableWhileTypingEnabledByDefault(), enabled);
QCOMPARE(d.property("disableWhileTypingEnabledByDefault").toBool(), enabled);
}
void TestLibinputDevice::testLmrTapButtonMapEnabledByDefault_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testLmrTapButtonMapEnabledByDefault()
{
QFETCH(bool, enabled);
libinput_device device;
device.defaultTapButtonMap = enabled ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM;
Device d(&device);
QCOMPARE(d.lmrTapButtonMapEnabledByDefault(), enabled);
QCOMPARE(d.property("lmrTapButtonMapEnabledByDefault").toBool(), enabled);
}
void TestLibinputDevice::testLmrTapButtonMap_data()
{
QTest::addColumn<bool>("initValue");
QTest::addColumn<bool>("setValue");
QTest::addColumn<bool>("setShouldFail");
QTest::addColumn<bool>("expectedValue");
QTest::addColumn<int>("fingerCount");
QTest::newRow("true -> false") << true << false << false << false << 3;
QTest::newRow("false -> true") << false << true << false << true << 3;
QTest::newRow("true -> false") << true << false << false << false << 2;
QTest::newRow("false -> true") << false << true << false << true << 2;
QTest::newRow("set fails") << true << false << true << true << 3;
QTest::newRow("true -> true") << true << true << false << true << 3;
QTest::newRow("false -> false") << false << false << false << false << 3;
QTest::newRow("true -> true") << true << true << false << true << 2;
QTest::newRow("false -> false") << false << false << false << false << 2;
QTest::newRow("false -> true, fingerCount 0") << false << true << true << false << 0;
// TODO: is this a fail in libinput?
//QTest::newRow("false -> true, fingerCount 1") << false << true << true << false << 1;
}
void TestLibinputDevice::testLmrTapButtonMap()
{
libinput_device device;
QFETCH(bool, initValue);
QFETCH(bool, setShouldFail);
QFETCH(int, fingerCount);
device.tapFingerCount = fingerCount;
device.tapButtonMap = initValue ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM;
device.setTapButtonMapReturnValue = setShouldFail;
Device d(&device);
QCOMPARE(d.lmrTapButtonMap(), initValue);
QCOMPARE(d.property("lmrTapButtonMap").toBool(), initValue);
QSignalSpy tapButtonMapChangedSpy(&d, &Device::tapButtonMapChanged);
QVERIFY(tapButtonMapChangedSpy.isValid());
QFETCH(bool, setValue);
d.setLmrTapButtonMap(setValue);
QFETCH(bool, expectedValue);
QCOMPARE(d.lmrTapButtonMap(), expectedValue);
QCOMPARE(d.property("lmrTapButtonMap").toBool(), expectedValue);
QCOMPARE(tapButtonMapChangedSpy.isEmpty(), initValue == expectedValue);
}
void TestLibinputDevice::testDisableWhileTyping_data()
{
QTest::addColumn<bool>("initValue");
QTest::addColumn<bool>("setValue");
QTest::addColumn<bool>("setShouldFail");
QTest::addColumn<bool>("expectedValue");
QTest::addColumn<bool>("supportsDisableWhileTyping");
QTest::newRow("true -> false") << true << false << false << false << true;
QTest::newRow("false -> true") << false << true << false << true << true;
QTest::newRow("set fails") << true << false << true << true << true;
QTest::newRow("true -> true") << true << true << false << true << true;
QTest::newRow("false -> false") << false << false << false << false << true;
QTest::newRow("false -> true, unsupported") << false << true << true << false << false;
}
void TestLibinputDevice::testDisableWhileTyping()
{
libinput_device device;
QFETCH(bool, initValue);
QFETCH(bool, setShouldFail);
QFETCH(bool, supportsDisableWhileTyping);
device.supportsDisableWhileTyping = supportsDisableWhileTyping;
device.disableWhileTyping = initValue ? LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED;
device.setDisableWhileTypingReturnValue = setShouldFail;
Device d(&device);
QCOMPARE(d.isDisableWhileTyping(), initValue);
QCOMPARE(d.property("disableWhileTyping").toBool(), initValue);
QSignalSpy disableWhileTypingChangedSpy(&d, &Device::disableWhileTypingChanged);
QVERIFY(disableWhileTypingChangedSpy.isValid());
QFETCH(bool, setValue);
d.setDisableWhileTyping(setValue);
QFETCH(bool, expectedValue);
QCOMPARE(d.isDisableWhileTyping(), expectedValue);
QCOMPARE(d.property("disableWhileTyping").toBool(), expectedValue);
QCOMPARE(disableWhileTypingChangedSpy.isEmpty(), initValue == expectedValue);
}
void TestLibinputDevice::testLoadEnabled_data()
{
QTest::addColumn<bool>("initValue");
@ -1340,6 +1551,108 @@ void TestLibinputDevice::testLoadEnabled()
}
}
void TestLibinputDevice::testLoadPointerAcceleration_data()
{
QTest::addColumn<qreal>("initValue");
QTest::addColumn<qreal>("configValue");
QTest::newRow("-0.2 -> 0.9") << -0.2 << 0.9;
QTest::newRow("0.0 -> -1.0") << 0.0 << -1.0;
QTest::newRow("0.123 -> -0.456") << 0.123 << -0.456;
QTest::newRow("0.7 -> 0.7") << 0.7 << 0.7;
}
void TestLibinputDevice::testLoadPointerAcceleration()
{
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup inputConfig(config, QStringLiteral("Test"));
QFETCH(qreal, configValue);
QFETCH(qreal, initValue);
inputConfig.writeEntry("PointerAcceleration", configValue);
libinput_device device;
device.supportsPointerAcceleration = true;
device.pointerAcceleration = initValue;
device.setPointerAccelerationReturnValue = false;
Device d(&device);
QCOMPARE(d.pointerAcceleration(), initValue);
QCOMPARE(d.property("pointerAcceleration").toReal(), initValue);
// no config group set, should not change
d.loadConfiguration();
QCOMPARE(d.pointerAcceleration(), initValue);
QCOMPARE(d.property("pointerAcceleration").toReal(), initValue);
// set the group
d.setConfig(inputConfig);
d.loadConfiguration();
QCOMPARE(d.pointerAcceleration(), configValue);
QCOMPARE(d.property("pointerAcceleration").toReal(), configValue);
// and try to store
if (configValue != initValue) {
d.setPointerAcceleration(initValue);
QCOMPARE(inputConfig.readEntry("PointerAcceleration", configValue), initValue);
}
}
void TestLibinputDevice::testLoadPointerAccelerationProfile_data()
{
QTest::addColumn<quint32>("initValue");
QTest::addColumn<QString>("initValuePropNameString");
QTest::addColumn<quint32>("configValue");
QTest::addColumn<QString>("configValuePropNameString");
QTest::newRow("pointerAccelerationProfileFlat -> pointerAccelerationProfileAdaptive")
<< (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT << "pointerAccelerationProfileFlat"
<< (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive";
QTest::newRow("pointerAccelerationProfileAdaptive -> pointerAccelerationProfileFlat")
<< (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive"
<< (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT << "pointerAccelerationProfileFlat";
QTest::newRow("pointerAccelerationProfileAdaptive -> pointerAccelerationProfileAdaptive")
<< (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive" << (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive";
}
void TestLibinputDevice::testLoadPointerAccelerationProfile()
{
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup inputConfig(config, QStringLiteral("Test"));
QFETCH(quint32, initValue);
QFETCH(quint32, configValue);
QFETCH(QString, initValuePropNameString);
QFETCH(QString, configValuePropNameString);
QByteArray initValuePropName = initValuePropNameString.toLatin1();
QByteArray configValuePropName = configValuePropNameString.toLatin1();
inputConfig.writeEntry("PointerAccelerationProfile", configValue);
libinput_device device;
device.supportedPointerAccelerationProfiles = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT | LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
device.pointerAccelerationProfile = (libinput_config_accel_profile) initValue;
device.setPointerAccelerationProfileReturnValue = false;
Device d(&device);
QCOMPARE(d.property(initValuePropName).toBool(), true);
QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue);
// no config group set, should not change
d.loadConfiguration();
QCOMPARE(d.property(initValuePropName).toBool(), true);
QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue);
// set the group
d.setConfig(inputConfig);
d.loadConfiguration();
QCOMPARE(d.property(initValuePropName).toBool(), initValue == configValue);
QCOMPARE(d.property(configValuePropName).toBool(), true);
// and try to store
if (configValue != initValue) {
d.setProperty(initValuePropName, true);
QCOMPARE(inputConfig.readEntry("PointerAccelerationProfile", configValue), initValue);
}
}
void TestLibinputDevice::testLoadTapToClick_data()
{
QTest::addColumn<bool>("initValue");
@ -1686,5 +1999,89 @@ void TestLibinputDevice::testLoadLeftHanded()
}
}
void TestLibinputDevice::testLoadDisableWhileTyping_data()
{
QTest::addColumn<bool>("initValue");
QTest::addColumn<bool>("configValue");
QTest::newRow("false -> true") << false << true;
QTest::newRow("true -> false") << true << false;
QTest::newRow("true -> true") << true << true;
QTest::newRow("false -> false") << false << false;
}
void TestLibinputDevice::testLoadDisableWhileTyping()
{
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup inputConfig(config, QStringLiteral("Test"));
QFETCH(bool, configValue);
QFETCH(bool, initValue);
inputConfig.writeEntry("DisableWhileTyping", configValue);
libinput_device device;
device.supportsDisableWhileTyping = true;
device.disableWhileTyping = initValue ? LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED;
device.setDisableWhileTypingReturnValue = false;
Device d(&device);
QCOMPARE(d.isDisableWhileTyping(), initValue);
// no config group set, should not change
d.loadConfiguration();
QCOMPARE(d.isDisableWhileTyping(), initValue);
// set the group
d.setConfig(inputConfig);
d.loadConfiguration();
QCOMPARE(d.isDisableWhileTyping(), configValue);
// and try to store
if (configValue != initValue) {
d.setDisableWhileTyping(initValue);
QCOMPARE(inputConfig.readEntry("DisableWhileTyping", configValue), initValue);
}
}
void TestLibinputDevice::testLoadLmrTapButtonMap_data()
{
QTest::addColumn<bool>("initValue");
QTest::addColumn<bool>("configValue");
QTest::newRow("false -> true") << false << true;
QTest::newRow("true -> false") << true << false;
QTest::newRow("true -> true") << true << true;
QTest::newRow("false -> false") << false << false;
}
void TestLibinputDevice::testLoadLmrTapButtonMap()
{
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup inputConfig(config, QStringLiteral("Test"));
QFETCH(bool, configValue);
QFETCH(bool, initValue);
inputConfig.writeEntry("LmrTapButtonMap", configValue);
libinput_device device;
device.tapFingerCount = 3;
device.tapButtonMap = initValue ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM;
device.setTapButtonMapReturnValue = false;
Device d(&device);
QCOMPARE(d.lmrTapButtonMap(), initValue);
// no config group set, should not change
d.loadConfiguration();
QCOMPARE(d.lmrTapButtonMap(), initValue);
// set the group
d.setConfig(inputConfig);
d.loadConfiguration();
QCOMPARE(d.lmrTapButtonMap(), configValue);
// and try to store
if (configValue != initValue) {
d.setLmrTapButtonMap(initValue);
QCOMPARE(inputConfig.readEntry("LmrTapButtonMap", configValue), initValue);
}
}
QTEST_GUILESS_MAIN(TestLibinputDevice)
#include "device_test.moc"

View file

@ -162,6 +162,28 @@ int libinput_device_config_dwt_is_available(struct libinput_device *device)
return device->supportsDisableWhileTyping;
}
enum libinput_config_status libinput_device_config_dwt_set_enabled(struct libinput_device *device, enum libinput_config_dwt_state state)
{
if (device->setDisableWhileTypingReturnValue == 0) {
if (!device->supportsDisableWhileTyping) {
return LIBINPUT_CONFIG_STATUS_INVALID;
}
device->disableWhileTyping = state;
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
return LIBINPUT_CONFIG_STATUS_INVALID;
}
enum libinput_config_dwt_state libinput_device_config_dwt_get_enabled(struct libinput_device *device)
{
return device->disableWhileTyping;
}
enum libinput_config_dwt_state libinput_device_config_dwt_get_default_enabled(struct libinput_device *device)
{
return device->disableWhileTypingEnabledByDefault;
}
int libinput_device_config_accel_is_available(struct libinput_device *device)
{
return device->supportsPointerAcceleration;
@ -194,6 +216,11 @@ int libinput_device_config_left_handed_get(struct libinput_device *device)
return device->leftHanded;
}
double libinput_device_config_accel_get_default_speed(struct libinput_device *device)
{
return device->defaultPointerAcceleration;
}
int libinput_device_config_left_handed_get_default(struct libinput_device *device)
{
return device->leftHandedEnabledByDefault;
@ -204,6 +231,33 @@ double libinput_device_config_accel_get_speed(struct libinput_device *device)
return device->pointerAcceleration;
}
uint32_t libinput_device_config_accel_get_profiles(struct libinput_device *device)
{
return device->supportedPointerAccelerationProfiles;
}
enum libinput_config_accel_profile libinput_device_config_accel_get_default_profile(struct libinput_device *device)
{
return device->defaultPointerAccelerationProfile;
}
enum libinput_config_status libinput_device_config_accel_set_profile(struct libinput_device *device, enum libinput_config_accel_profile profile)
{
if (device->setPointerAccelerationProfileReturnValue == 0) {
if (!(device->supportedPointerAccelerationProfiles & profile) && profile!= LIBINPUT_CONFIG_ACCEL_PROFILE_NONE) {
return LIBINPUT_CONFIG_STATUS_INVALID;
}
device->pointerAccelerationProfile = profile;
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
return LIBINPUT_CONFIG_STATUS_INVALID;
}
enum libinput_config_accel_profile libinput_device_config_accel_get_profile(struct libinput_device *device)
{
return device->pointerAccelerationProfile;
}
uint32_t libinput_device_config_send_events_get_mode(struct libinput_device *device)
{
if (device->enabled) {
@ -670,6 +724,28 @@ int libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libi
return device->naturalScrollEnabledByDefault;
}
enum libinput_config_tap_button_map libinput_device_config_tap_get_default_button_map(struct libinput_device *device)
{
return device->defaultTapButtonMap;
}
enum libinput_config_status libinput_device_config_tap_set_button_map(struct libinput_device *device, enum libinput_config_tap_button_map map)
{
if (device->setTapButtonMapReturnValue == 0) {
if (device->tapFingerCount == 0) {
return LIBINPUT_CONFIG_STATUS_INVALID;
}
device->tapButtonMap = map;
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
return LIBINPUT_CONFIG_STATUS_INVALID;
}
enum libinput_config_tap_button_map libinput_device_config_tap_get_button_map(struct libinput_device *device)
{
return device->tapButtonMap;
}
uint32_t libinput_device_config_scroll_get_methods(struct libinput_device *device)
{
return device->supportedScrollMethods;

View file

@ -57,6 +57,13 @@ struct libinput_device {
quint32 supportedScrollMethods = 0;
bool middleEmulationEnabledByDefault = false;
bool middleEmulation = false;
enum libinput_config_tap_button_map defaultTapButtonMap = LIBINPUT_CONFIG_TAP_MAP_LRM;
enum libinput_config_tap_button_map tapButtonMap = LIBINPUT_CONFIG_TAP_MAP_LRM;
int setTapButtonMapReturnValue = 0;
enum libinput_config_dwt_state disableWhileTypingEnabledByDefault = LIBINPUT_CONFIG_DWT_DISABLED;
enum libinput_config_dwt_state disableWhileTyping = LIBINPUT_CONFIG_DWT_DISABLED;
int setDisableWhileTypingReturnValue = 0;
qreal defaultPointerAcceleration = 0.0;
qreal pointerAcceleration = 0.0;
int setPointerAccelerationReturnValue = 0;
bool leftHandedEnabledByDefault = false;
@ -79,6 +86,10 @@ struct libinput_device {
int setTapAndDragReturnValue = 0;
int setTapDragLockReturnValue = 0;
int setMiddleEmulationReturnValue = 0;
quint32 supportedPointerAccelerationProfiles = 0;
enum libinput_config_accel_profile defaultPointerAccelerationProfile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
enum libinput_config_accel_profile pointerAccelerationProfile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
bool setPointerAccelerationProfileReturnValue = 0;
};
struct libinput_event {

View file

@ -99,11 +99,17 @@ Connection *Connection::create(QObject *parent)
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);
connect(s_self, &Connection::deviceAdded, s_self, [s_self](Device* device) {
emit s_self->deviceAddedSysName(device->sysName());
});
connect(s_self, &Connection::deviceRemoved, s_self, [s_self](Device* device) {
emit s_self->deviceRemovedSysName(device->sysName());
});
return s_self;
}
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)
@ -158,12 +164,15 @@ Connection::Connection(Context *input, QObject *parent)
QDBusConnection::sessionBus().connect(QString(), QStringLiteral("/KGlobalSettings"), QStringLiteral("org.kde.KGlobalSettings"),
QStringLiteral("notifyChange"), this, SLOT(slotKGlobalSettingsNotifyChange(int,int)));
QDBusConnection::sessionBus().registerService(s_serviceName);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin/InputDevice"),
QStringLiteral("org.kde.KWin.InputDeviceManager"),
this,
QDBusConnection::ExportAllProperties | QDBusConnection::ExportScriptableSignals
);
}
Connection::~Connection()
{
QDBusConnection::sessionBus().unregisterService(s_serviceName);
s_self = nullptr;
delete s_context;
s_context = nullptr;
@ -475,7 +484,7 @@ void Connection::applyDeviceConfig(Device *device)
device->setConfig(m_config->group("Libinput").group(QString::number(device->vendor())).group(QString::number(device->product())).group(device->name()));
device->loadConfiguration();
if (device->isPointer()) {
if (device->isPointer() && !device->isTouchpad()) {
const KConfigGroup group = m_config->group("Mouse");
device->setLeftHanded(group.readEntry("MouseButtonMapping", "RightHanded") == QLatin1String("LeftHanded"));
qreal accel = group.readEntry("Acceleration", -1.0);
@ -511,21 +520,13 @@ void Connection::toggleTouchpads()
m_touchpadsEnabled = !m_touchpadsEnabled;
for (auto it = m_devices.constBegin(); it != m_devices.constEnd(); ++it) {
auto device = *it;
if (!device->isPointer()) {
if (!device->isTouchpad()) {
continue;
}
if (device->isKeyboard() || device->isTouch() || device->isTabletPad() || device->isTabletTool()) {
// ignore all combined devices. E.g. a touchpad on a keyboard we don't want to toggle
// as that would result in the keyboard going off as well
continue;
}
// is this a touch pad? We don't really know, let's do some assumptions
if (device->tapFingerCount() > 0 || device->supportsDisableWhileTyping() || device->supportsDisableEventsOnExternalMouse()) {
const bool old = device->isEnabled();
device->setEnabled(m_touchpadsEnabled);
if (old != device->isEnabled()) {
changed = true;
}
const bool old = device->isEnabled();
device->setEnabled(m_touchpadsEnabled);
if (old != device->isEnabled()) {
changed = true;
}
}
if (changed) {
@ -554,5 +555,13 @@ void Connection::updateLEDs(Xkb::LEDs leds)
}
}
QStringList Connection::devicesSysNames() const {
QStringList sl;
foreach (Device *d, m_devices) {
sl.append(d->sysName());
}
return sl;
}
}
}

View file

@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QSize>
#include <QMutex>
#include <QVector>
#include <QStringList>
class QSocketNotifier;
class QThread;
@ -44,6 +45,8 @@ class Context;
class Connection : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.InputDeviceManager")
Q_PROPERTY(QStringList devicesSysNames READ devicesSysNames CONSTANT)
public:
~Connection();
@ -83,6 +86,8 @@ public:
return m_devices;
}
QStringList devicesSysNames() const;
void updateLEDs(KWin::Xkb::LEDs leds);
Q_SIGNALS:
@ -102,6 +107,8 @@ Q_SIGNALS:
void hasTouchChanged(bool);
void deviceAdded(KWin::LibInput::Device *);
void deviceRemoved(KWin::LibInput::Device *);
Q_SCRIPTABLE void deviceAddedSysName(QString);
Q_SCRIPTABLE void deviceRemovedSysName(QString);
void swipeGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device);
void swipeGestureUpdate(const QSizeF &delta, quint32 time, KWin::LibInput::Device *device);
void swipeGestureEnd(quint32 time, KWin::LibInput::Device *device);

View file

@ -73,7 +73,11 @@ Device *Device::getDevice(libinput_device *native)
enum class ConfigKey {
Enabled,
LeftHanded,
DisableWhileTyping,
PointerAcceleration,
PointerAccelerationProfile,
TapToClick,
LmrTapButtonMap,
TapAndDrag,
TapDragLock,
MiddleButtonEmulation,
@ -91,6 +95,10 @@ struct ConfigData {
: key(_key)
{ quint32Setter.setter = _setter; quint32Setter.defaultValue = _defaultValue; }
explicit ConfigData(QByteArray _key, void (Device::*_setter)(QString), QString (Device::*_defaultValue)() const = nullptr)
: key(_key)
{ stringSetter.setter = _setter; stringSetter.defaultValue = _defaultValue; }
QByteArray key;
struct {
@ -102,15 +110,23 @@ struct ConfigData {
void (Device::*setter)(quint32) = nullptr;
quint32 (Device::*defaultValue)() const;
} quint32Setter;
struct {
void (Device::*setter)(QString) = nullptr;
QString (Device::*defaultValue)() const;
} stringSetter;
};
static const QMap<ConfigKey, ConfigData> s_configData {
{ConfigKey::Enabled, ConfigData(QByteArrayLiteral("Enabled"), &Device::setEnabled)},
{ConfigKey::LeftHanded, ConfigData(QByteArrayLiteral("LeftHanded"), &Device::setLeftHanded, &Device::leftHandedEnabledByDefault)},
{ConfigKey::DisableWhileTyping, ConfigData(QByteArrayLiteral("DisableWhileTyping"), &Device::setDisableWhileTyping, &Device::disableWhileTypingEnabledByDefault)},
{ConfigKey::PointerAcceleration, ConfigData(QByteArrayLiteral("PointerAcceleration"), &Device::setPointerAccelerationFromString, &Device::defaultPointerAccelerationToString)},
{ConfigKey::PointerAccelerationProfile, ConfigData(QByteArrayLiteral("PointerAccelerationProfile"), &Device::activatePointerAccelerationProfileFromInt, &Device::defaultPointerAccelerationProfileToInt)},
{ConfigKey::TapToClick, ConfigData(QByteArrayLiteral("TapToClick"), &Device::setTapToClick, &Device::tapToClickEnabledByDefault)},
{ConfigKey::TapAndDrag, ConfigData(QByteArrayLiteral("TapAndDrag"), &Device::setTapAndDrag, &Device::tapAndDragEnabledByDefault)},
{ConfigKey::TapDragLock, ConfigData(QByteArrayLiteral("TapDragLock"), &Device::setTapDragLock, &Device::tapDragLockEnabledByDefault)},
{ConfigKey::MiddleButtonEmulation, ConfigData(QByteArrayLiteral("MiddleButtonEmulation"), &Device::setMiddleEmulation, &Device::middleEmulationEnabledByDefault)},
{ConfigKey::LmrTapButtonMap, ConfigData(QByteArrayLiteral("LmrTapButtonMap"), &Device::setLmrTapButtonMap, &Device::lmrTapButtonMapEnabledByDefault)},
{ConfigKey::NaturalScroll, ConfigData(QByteArrayLiteral("NaturalScroll"), &Device::setNaturalScroll, &Device::naturalScrollEnabledByDefault)},
{ConfigKey::ScrollMethod, ConfigData(QByteArrayLiteral("ScrollMethod"), &Device::activateScrollMethodFromInt, &Device::defaultScrollMethodToInt)},
{ConfigKey::ScrollButton, ConfigData(QByteArrayLiteral("ScrollButton"), &Device::setScrollButton, &Device::defaultScrollButton)}
@ -138,6 +154,8 @@ Device::Device(libinput_device *device, QObject *parent)
, m_tapFingerCount(libinput_device_config_tap_get_finger_count(m_device))
, m_tapToClickEnabledByDefault(libinput_device_config_tap_get_default_enabled(m_device) == LIBINPUT_CONFIG_TAP_ENABLED)
, m_tapToClick(libinput_device_config_tap_get_enabled(m_device))
, m_defaultTapButtonMap(libinput_device_config_tap_get_default_button_map(m_device))
, m_tapButtonMap(libinput_device_config_tap_get_button_map(m_device))
, m_tapAndDragEnabledByDefault(libinput_device_config_tap_get_default_drag_enabled(m_device))
, m_tapAndDrag(libinput_device_config_tap_get_drag_enabled(m_device))
, m_tapDragLockEnabledByDefault(libinput_device_config_tap_get_default_drag_lock_enabled(m_device))
@ -156,12 +174,18 @@ Device::Device(libinput_device *device, QObject *parent)
, m_naturalScrollEnabledByDefault(libinput_device_config_scroll_get_default_natural_scroll_enabled(m_device))
, m_defaultScrollMethod(libinput_device_config_scroll_get_default_method(m_device))
, m_defaultScrollButton(libinput_device_config_scroll_get_default_button(m_device))
, m_disableWhileTypingEnabledByDefault(libinput_device_config_dwt_get_default_enabled(m_device))
, m_disableWhileTyping(m_supportsDisableWhileTyping ? libinput_device_config_dwt_get_enabled(m_device) : false)
, m_middleEmulation(libinput_device_config_middle_emulation_get_enabled(m_device) == LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED)
, m_leftHanded(m_supportsLeftHanded ? libinput_device_config_left_handed_get(m_device) : false)
, m_naturalScroll(m_supportsNaturalScroll ? libinput_device_config_scroll_get_natural_scroll_enabled(m_device) : false)
, m_scrollMethod(libinput_device_config_scroll_get_method(m_device))
, m_scrollButton(libinput_device_config_scroll_get_button(m_device))
, m_defaultPointerAcceleration(libinput_device_config_accel_get_default_speed(m_device))
, m_pointerAcceleration(libinput_device_config_accel_get_speed(m_device))
, m_supportedPointerAccelerationProfiles(libinput_device_config_accel_get_profiles(m_device))
, m_defaultPointerAccelerationProfile(libinput_device_config_accel_get_default_profile(m_device))
, m_pointerAccelerationProfile(libinput_device_config_accel_get_profile(m_device))
, m_enabled(m_supportsDisableEvents ? libinput_device_config_send_events_get_mode(m_device) == LIBINPUT_CONFIG_SEND_EVENTS_ENABLED : true)
, m_config()
{
@ -255,6 +279,7 @@ void Device::loadConfiguration()
}
readEntry(key, it.value().booleanSetter, true);
readEntry(key, it.value().quint32Setter, 0);
readEntry(key, it.value().stringSetter, "");
};
m_loading = false;
@ -270,28 +295,11 @@ void Device::setPointerAcceleration(qreal acceleration)
if (m_pointerAcceleration != acceleration) {
m_pointerAcceleration = acceleration;
emit pointerAccelerationChanged();
writeEntry(ConfigKey::PointerAcceleration, QString::number(acceleration, 'f', 3));
}
}
}
void Device::setScrollMethod(bool set, enum libinput_config_scroll_method method)
{
bool stays_the_same = (m_scrollMethod == method) == set;
if (!(m_supportedScrollMethods & method) || stays_the_same) {
return;
}
if (!set) {
method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
}
if (libinput_device_config_scroll_set_method(m_device, method) == LIBINPUT_CONFIG_STATUS_SUCCESS) {
m_scrollMethod = method;
emit scrollMethodChanged();
writeEntry(ConfigKey::ScrollMethod, (quint32) method);
}
}
void Device::setScrollButton(quint32 button)
{
if (!(m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)) {
@ -306,6 +314,63 @@ void Device::setScrollButton(quint32 button)
}
}
void Device::setPointerAccelerationProfile(bool set, enum libinput_config_accel_profile profile) {
if (!(m_supportedPointerAccelerationProfiles & profile)) {
return;
}
if (!set) {
profile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
}
if (libinput_device_config_accel_set_profile(m_device, profile) == LIBINPUT_CONFIG_STATUS_SUCCESS) {
if (m_pointerAccelerationProfile != profile) {
m_pointerAccelerationProfile = profile;
emit pointerAccelerationProfileChanged();
writeEntry(ConfigKey::PointerAccelerationProfile, (quint32) profile);
}
}
}
void Device::setScrollMethod(bool set, enum libinput_config_scroll_method method)
{
if (!(m_supportedScrollMethods & method)) {
return;
}
if (!set) {
method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
}
if (libinput_device_config_scroll_set_method(m_device, method) == LIBINPUT_CONFIG_STATUS_SUCCESS) {
if (m_scrollMethod != method) {
m_scrollMethod = method;
emit scrollMethodChanged();
writeEntry(ConfigKey::ScrollMethod, (quint32) method);
}
}
}
void Device::setLmrTapButtonMap(bool set) {
enum libinput_config_tap_button_map map = set ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM;
if (m_tapFingerCount < 2) {
return;
}
if (!set) {
map = LIBINPUT_CONFIG_TAP_MAP_LRM;
}
if (libinput_device_config_tap_set_button_map(m_device, map) == LIBINPUT_CONFIG_STATUS_SUCCESS) {
if (m_tapButtonMap != map) {
m_tapButtonMap = map;
writeEntry(ConfigKey::LmrTapButtonMap, set);
emit tapButtonMapChanged();
}
}
}
#define CONFIG(method, condition, function, variable, key) \
void Device::method(bool set) \
{ \
@ -342,6 +407,7 @@ void Device::method(bool set) \
}
CONFIG(setEnabled, !m_supportsDisableEvents, send_events_set_mode, SEND_EVENTS, enabled, Enabled)
CONFIG(setDisableWhileTyping, !m_supportsDisableWhileTyping, dwt_set_enabled, DWT, disableWhileTyping, DisableWhileTyping)
CONFIG(setTapToClick, m_tapFingerCount == 0, tap_set_enabled, TAP, tapToClick, TapToClick)
CONFIG(setTapAndDrag, false, tap_set_drag_enabled, DRAG, tapAndDrag, TapAndDrag)
CONFIG(setTapDragLock, false, tap_set_drag_lock_enabled, DRAG_LOCK, tapDragLock, TapDragLock)

View file

@ -40,9 +40,12 @@ class Device : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.InputDevice")
//
// general
Q_PROPERTY(bool keyboard READ isKeyboard CONSTANT)
Q_PROPERTY(bool alphaNumericKeyboard READ isAlphaNumericKeyboard CONSTANT)
Q_PROPERTY(bool pointer READ isPointer CONSTANT)
Q_PROPERTY(bool touchpad READ isTouchpad CONSTANT)
Q_PROPERTY(bool touch READ isTouch CONSTANT)
Q_PROPERTY(bool tabletTool READ isTabletTool CONSTANT)
Q_PROPERTY(bool tabletPad READ isTabletPad CONSTANT)
@ -53,41 +56,74 @@ class Device : public QObject
Q_PROPERTY(QSizeF size READ size CONSTANT)
Q_PROPERTY(quint32 product READ product CONSTANT)
Q_PROPERTY(quint32 vendor READ vendor CONSTANT)
Q_PROPERTY(Qt::MouseButtons supportedButtons READ supportedButtons CONSTANT)
Q_PROPERTY(int tapFingerCount READ tapFingerCount CONSTANT)
Q_PROPERTY(bool tapToClickEnabledByDefault READ tapToClickEnabledByDefault CONSTANT)
Q_PROPERTY(bool supportsDisableWhileTyping READ supportsDisableWhileTyping CONSTANT)
Q_PROPERTY(bool supportsPointerAcceleration READ supportsPointerAcceleration CONSTANT)
Q_PROPERTY(bool supportsLeftHanded READ supportsLeftHanded CONSTANT)
Q_PROPERTY(bool supportsCalibrationMatrix READ supportsCalibrationMatrix CONSTANT)
Q_PROPERTY(bool supportsDisableEvents READ supportsDisableEvents CONSTANT)
Q_PROPERTY(bool supportsDisableEventsOnExternalMouse READ supportsDisableEventsOnExternalMouse CONSTANT)
Q_PROPERTY(bool supportsMiddleEmulation READ supportsMiddleEmulation CONSTANT)
Q_PROPERTY(bool supportsNaturalScroll READ supportsNaturalScroll CONSTANT)
Q_PROPERTY(bool supportsScrollTwoFinger READ supportsScrollTwoFinger CONSTANT)
Q_PROPERTY(bool supportsScrollEdge READ supportsScrollEdge CONSTANT)
Q_PROPERTY(bool supportsScrollOnButtonDown READ supportsScrollOnButtonDown CONSTANT)
Q_PROPERTY(bool middleEmulationEnabledByDefault READ middleEmulationEnabledByDefault CONSTANT)
Q_PROPERTY(bool naturalScrollEnabledByDefault READ naturalScrollEnabledByDefault CONSTANT)
Q_PROPERTY(bool scrollTwoFingerEnabledByDefault READ scrollTwoFingerEnabledByDefault CONSTANT)
Q_PROPERTY(bool scrollEdgeEnabledByDefault READ scrollEdgeEnabledByDefault CONSTANT)
Q_PROPERTY(bool scrollOnButtonDownEnabledByDefault READ scrollOnButtonDownEnabledByDefault CONSTANT)
Q_PROPERTY(quint32 defaultScrollButton READ defaultScrollButton CONSTANT)
Q_PROPERTY(bool middleEmulation READ isMiddleEmulation WRITE setMiddleEmulation NOTIFY middleEmulationChanged)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
//
// advanced
Q_PROPERTY(Qt::MouseButtons supportedButtons READ supportedButtons CONSTANT)
Q_PROPERTY(bool supportsCalibrationMatrix READ supportsCalibrationMatrix CONSTANT)
Q_PROPERTY(bool supportsLeftHanded READ supportsLeftHanded CONSTANT)
Q_PROPERTY(bool leftHandedEnabledByDefault READ leftHandedEnabledByDefault CONSTANT)
Q_PROPERTY(bool leftHanded READ isLeftHanded WRITE setLeftHanded NOTIFY leftHandedChanged)
Q_PROPERTY(bool naturalScroll READ isNaturalScroll WRITE setNaturalScroll NOTIFY naturalScrollChanged)
Q_PROPERTY(bool scrollTwoFinger READ isScrollTwoFinger WRITE setScrollTwoFinger NOTIFY scrollMethodChanged)
Q_PROPERTY(bool scrollEdge READ isScrollEdge WRITE setScrollEdge NOTIFY scrollMethodChanged)
Q_PROPERTY(bool scrollOnButtonDown READ isScrollOnButtonDown WRITE setScrollOnButtonDown NOTIFY scrollMethodChanged)
Q_PROPERTY(quint32 scrollButton READ scrollButton WRITE setScrollButton NOTIFY scrollButtonChanged)
Q_PROPERTY(bool supportsDisableEventsOnExternalMouse READ supportsDisableEventsOnExternalMouse CONSTANT)
Q_PROPERTY(bool supportsDisableWhileTyping READ supportsDisableWhileTyping CONSTANT)
Q_PROPERTY(bool disableWhileTypingEnabledByDefault READ disableWhileTypingEnabledByDefault CONSTANT)
Q_PROPERTY(bool disableWhileTyping READ isDisableWhileTyping WRITE setDisableWhileTyping NOTIFY disableWhileTypingChanged)
//
// acceleration speed and profile
Q_PROPERTY(bool supportsPointerAcceleration READ supportsPointerAcceleration CONSTANT)
Q_PROPERTY(qreal defaultPointerAcceleration READ defaultPointerAcceleration CONSTANT)
Q_PROPERTY(qreal pointerAcceleration READ pointerAcceleration WRITE setPointerAcceleration NOTIFY pointerAccelerationChanged)
Q_PROPERTY(bool supportsPointerAccelerationProfileFlat READ supportsPointerAccelerationProfileFlat CONSTANT)
Q_PROPERTY(bool defaultPointerAccelerationProfileFlat READ defaultPointerAccelerationProfileFlat CONSTANT)
Q_PROPERTY(bool pointerAccelerationProfileFlat READ pointerAccelerationProfileFlat WRITE setPointerAccelerationProfileFlat NOTIFY pointerAccelerationProfileChanged)
Q_PROPERTY(bool supportsPointerAccelerationProfileAdaptive READ supportsPointerAccelerationProfileAdaptive CONSTANT)
Q_PROPERTY(bool defaultPointerAccelerationProfileAdaptive READ defaultPointerAccelerationProfileAdaptive CONSTANT)
Q_PROPERTY(bool pointerAccelerationProfileAdaptive READ pointerAccelerationProfileAdaptive WRITE setPointerAccelerationProfileAdaptive NOTIFY pointerAccelerationProfileChanged)
//
// tapping
Q_PROPERTY(int tapFingerCount READ tapFingerCount CONSTANT)
Q_PROPERTY(bool tapToClickEnabledByDefault READ tapToClickEnabledByDefault CONSTANT)
Q_PROPERTY(bool tapToClick READ isTapToClick WRITE setTapToClick NOTIFY tapToClickChanged)
Q_PROPERTY(bool supportsLmrTapButtonMap READ supportsLmrTapButtonMap CONSTANT)
Q_PROPERTY(bool lmrTapButtonMapEnabledByDefault READ lmrTapButtonMapEnabledByDefault CONSTANT)
Q_PROPERTY(bool lmrTapButtonMap READ lmrTapButtonMap WRITE setLmrTapButtonMap NOTIFY tapButtonMapChanged)
Q_PROPERTY(bool tapAndDragEnabledByDefault READ tapAndDragEnabledByDefault CONSTANT)
Q_PROPERTY(bool tapAndDrag READ isTapAndDrag WRITE setTapAndDrag NOTIFY tapAndDragChanged)
Q_PROPERTY(bool tapDragLockEnabledByDefault READ tapDragLockEnabledByDefault CONSTANT)
Q_PROPERTY(bool tapDragLock READ isTapDragLock WRITE setTapDragLock NOTIFY tapDragLockChanged)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool supportsMiddleEmulation READ supportsMiddleEmulation CONSTANT)
Q_PROPERTY(bool middleEmulationEnabledByDefault READ middleEmulationEnabledByDefault CONSTANT)
Q_PROPERTY(bool middleEmulation READ isMiddleEmulation WRITE setMiddleEmulation NOTIFY middleEmulationChanged)
//
// scrolling
Q_PROPERTY(bool supportsNaturalScroll READ supportsNaturalScroll CONSTANT)
Q_PROPERTY(bool naturalScrollEnabledByDefault READ naturalScrollEnabledByDefault CONSTANT)
Q_PROPERTY(bool naturalScroll READ isNaturalScroll WRITE setNaturalScroll NOTIFY naturalScrollChanged)
Q_PROPERTY(bool supportsScrollTwoFinger READ supportsScrollTwoFinger CONSTANT)
Q_PROPERTY(bool scrollTwoFingerEnabledByDefault READ scrollTwoFingerEnabledByDefault CONSTANT)
Q_PROPERTY(bool scrollTwoFinger READ isScrollTwoFinger WRITE setScrollTwoFinger NOTIFY scrollMethodChanged)
Q_PROPERTY(bool supportsScrollEdge READ supportsScrollEdge CONSTANT)
Q_PROPERTY(bool scrollEdgeEnabledByDefault READ scrollEdgeEnabledByDefault CONSTANT)
Q_PROPERTY(bool scrollEdge READ isScrollEdge WRITE setScrollEdge NOTIFY scrollMethodChanged)
Q_PROPERTY(bool supportsScrollOnButtonDown READ supportsScrollOnButtonDown CONSTANT)
Q_PROPERTY(bool scrollOnButtonDownEnabledByDefault READ scrollOnButtonDownEnabledByDefault CONSTANT)
Q_PROPERTY(quint32 defaultScrollButton READ defaultScrollButton CONSTANT)
Q_PROPERTY(bool scrollOnButtonDown READ isScrollOnButtonDown WRITE setScrollOnButtonDown NOTIFY scrollMethodChanged)
Q_PROPERTY(quint32 scrollButton READ scrollButton WRITE setScrollButton NOTIFY scrollButtonChanged)
public:
explicit Device(libinput_device *device, QObject *parent = nullptr);
virtual ~Device();
@ -101,6 +137,14 @@ public:
bool isPointer() const {
return m_pointer;
}
bool isTouchpad() const{
return m_pointer &&
// ignore all combined devices. E.g. a touchpad on a keyboard we don't want to toggle
// as that would result in the keyboard going off as well
!(m_keyboard || m_touch || m_tabletPad || m_tabletTool) &&
// is this a touch pad? We don't really know, let's do some assumptions
(m_tapFingerCount > 0 || m_supportsDisableWhileTyping || m_supportsDisableEventsOnExternalMouse);
}
bool isTouch() const {
return m_touch;
}
@ -164,6 +208,9 @@ public:
bool supportsDisableWhileTyping() const {
return m_supportsDisableWhileTyping;
}
bool disableWhileTypingEnabledByDefault() const {
return m_disableWhileTypingEnabledByDefault;
}
bool supportsPointerAcceleration() const {
return m_supportsPointerAcceleration;
}
@ -218,6 +265,18 @@ public:
bool scrollOnButtonDownEnabledByDefault() const {
return m_defaultScrollMethod == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
}
bool supportsLmrTapButtonMap() const {
return m_tapFingerCount > 1;
}
bool lmrTapButtonMapEnabledByDefault() const {
return m_defaultTapButtonMap == LIBINPUT_CONFIG_TAP_MAP_LMR;
}
void setLmrTapButtonMap(bool set);
bool lmrTapButtonMap() const {
return m_tapButtonMap & LIBINPUT_CONFIG_TAP_MAP_LMR;
}
quint32 defaultScrollButton() const {
return m_defaultScrollButton;
}
@ -256,6 +315,10 @@ public:
}
void setScrollButton(quint32 button);
void setDisableWhileTyping(bool set);
bool isDisableWhileTyping() const {
return m_disableWhileTyping;
}
bool isLeftHanded() const {
return m_leftHanded;
}
@ -265,6 +328,9 @@ public:
**/
void setLeftHanded(bool set);
qreal defaultPointerAcceleration() const {
return m_defaultPointerAcceleration;
}
qreal pointerAcceleration() const {
return m_pointerAcceleration;
}
@ -272,7 +338,43 @@ public:
* @param acceleration mapped to range [-1,1] with -1 being the slowest, 1 being the fastest supported acceleration.
**/
void setPointerAcceleration(qreal acceleration);
void setPointerAccelerationFromString(QString acceleration) {
setPointerAcceleration(acceleration.toDouble());
}
QString defaultPointerAccelerationToString() const {
return QString::number(m_pointerAcceleration, 'f', 3);
}
bool supportsPointerAccelerationProfileFlat() const {
return (m_supportedPointerAccelerationProfiles & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
}
bool supportsPointerAccelerationProfileAdaptive() const {
return (m_supportedPointerAccelerationProfiles & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
}
bool defaultPointerAccelerationProfileFlat() const {
return (m_defaultPointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
}
bool defaultPointerAccelerationProfileAdaptive() const {
return (m_defaultPointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
}
bool pointerAccelerationProfileFlat() const {
return (m_pointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
}
bool pointerAccelerationProfileAdaptive() const {
return (m_pointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
}
void setPointerAccelerationProfile(bool set, enum libinput_config_accel_profile profile);
void setPointerAccelerationProfileFlat(bool set) {
setPointerAccelerationProfile(set, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
}
void setPointerAccelerationProfileAdaptive(bool set) {
setPointerAccelerationProfile(set, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
}
void activatePointerAccelerationProfileFromInt(quint32 profile) {
setPointerAccelerationProfile(true, (libinput_config_accel_profile) profile);
}
quint32 defaultPointerAccelerationProfileToInt() const {
return (quint32) m_defaultPointerAccelerationProfile;
}
bool isEnabled() const {
return m_enabled;
}
@ -307,8 +409,11 @@ public:
static Device *getDevice(libinput_device *native);
Q_SIGNALS:
void tapButtonMapChanged();
void leftHandedChanged();
void disableWhileTypingChanged();
void pointerAccelerationChanged();
void pointerAccelerationProfileChanged();
void enabledChanged();
void tapToClickChanged();
void tapAndDragChanged();
@ -339,6 +444,8 @@ private:
quint32 m_vendor;
Qt::MouseButtons m_supportedButtons = Qt::NoButton;
int m_tapFingerCount;
enum libinput_config_tap_button_map m_defaultTapButtonMap;
enum libinput_config_tap_button_map m_tapButtonMap;
bool m_tapToClickEnabledByDefault;
bool m_tapToClick;
bool m_tapAndDragEnabledByDefault;
@ -361,12 +468,18 @@ private:
bool m_naturalScrollEnabledByDefault;
enum libinput_config_scroll_method m_defaultScrollMethod;
quint32 m_defaultScrollButton;
bool m_disableWhileTypingEnabledByDefault;
bool m_disableWhileTyping;
bool m_middleEmulation;
bool m_leftHanded;
bool m_naturalScroll;
enum libinput_config_scroll_method m_scrollMethod;
quint32 m_scrollButton;
qreal m_defaultPointerAcceleration;
qreal m_pointerAcceleration;
quint32 m_supportedPointerAccelerationProfiles;
enum libinput_config_accel_profile m_defaultPointerAccelerationProfile;
enum libinput_config_accel_profile m_pointerAccelerationProfile;
bool m_enabled;
KConfigGroup m_config;