diff --git a/autotests/libinput/device_test.cpp b/autotests/libinput/device_test.cpp --- a/autotests/libinput/device_test.cpp +++ b/autotests/libinput/device_test.cpp @@ -1222,33 +1222,37 @@ void TestLibinputDevice::testScrollTwoFinger_data() { QTest::addColumn("initValue"); + QTest::addColumn("otherValue"); QTest::addColumn("setValue"); QTest::addColumn("setShouldFail"); QTest::addColumn("expectedValue"); QTest::addColumn("supportsScrollTwoFinger"); - 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("true -> false") << true << false << false << false << false << true; + QTest::newRow("other -> false") << false << true << false << false << false << true; + QTest::newRow("false -> true") << false << false << true << false << true << true; + QTest::newRow("set fails") << true << false << false << true << true << true; + QTest::newRow("true -> true") << true << false << true << false << true << true; + QTest::newRow("false -> false") << false << false << false << false << false << true; - QTest::newRow("false -> true, unsupported") << false << true << true << false << false; + QTest::newRow("false -> true, unsupported") << false << false << true << true << false << false; } void TestLibinputDevice::testScrollTwoFinger() { libinput_device device; QFETCH(bool, initValue); + QFETCH(bool, otherValue); QFETCH(bool, setShouldFail); QFETCH(bool, supportsScrollTwoFinger); - device.supportedScrollMethods = supportsScrollTwoFinger ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; - device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + device.supportedScrollMethods = (supportsScrollTwoFinger ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_EDGE; + device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_2FG : otherValue ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; device.setScrollMethodReturnValue = setShouldFail; Device d(&device); QCOMPARE(d.isScrollTwoFinger(), initValue); QCOMPARE(d.property("scrollTwoFinger").toBool(), initValue); + QCOMPARE(d.property("scrollEdge").toBool(), otherValue); QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged); QVERIFY(scrollMethodChangedSpy.isValid()); @@ -1263,33 +1267,37 @@ void TestLibinputDevice::testScrollEdge_data() { QTest::addColumn("initValue"); + QTest::addColumn("otherValue"); QTest::addColumn("setValue"); QTest::addColumn("setShouldFail"); QTest::addColumn("expectedValue"); QTest::addColumn("supportsScrollEdge"); - 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("true -> false") << true << false << false << false << false << true; + QTest::newRow("other -> false") << false << true << false << false << false << true; + QTest::newRow("false -> true") << false << false << true << false << true << true; + QTest::newRow("set fails") << true << false << false << true << true << true; + QTest::newRow("true -> true") << true << false << true << false << true << true; + QTest::newRow("false -> false") << false << false << false << false << false << true; - QTest::newRow("false -> true, unsupported") << false << true << true << false << false; + QTest::newRow("false -> true, unsupported") << false << false << true << true << false << false; } void TestLibinputDevice::testScrollEdge() { libinput_device device; QFETCH(bool, initValue); + QFETCH(bool, otherValue); QFETCH(bool, setShouldFail); QFETCH(bool, supportsScrollEdge); - device.supportedScrollMethods = supportsScrollEdge ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; - device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + device.supportedScrollMethods = (supportsScrollEdge ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG; + device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_EDGE : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; device.setScrollMethodReturnValue = setShouldFail; Device d(&device); QCOMPARE(d.isScrollEdge(), initValue); QCOMPARE(d.property("scrollEdge").toBool(), initValue); + QCOMPARE(d.property("scrollTwoFinger").toBool(), otherValue); QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged); QVERIFY(scrollMethodChangedSpy.isValid()); @@ -1304,33 +1312,37 @@ void TestLibinputDevice::testScrollButtonDown_data() { QTest::addColumn("initValue"); + QTest::addColumn("otherValue"); QTest::addColumn("setValue"); QTest::addColumn("setShouldFail"); QTest::addColumn("expectedValue"); QTest::addColumn("supportsScrollButtonDown"); - 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("true -> false") << true << false << false << false << false << true; + QTest::newRow("other -> false") << false << true << false << false << false << true; + QTest::newRow("false -> true") << false << false << true << false << true << true; + QTest::newRow("set fails") << true << false << false << true << true << true; + QTest::newRow("true -> true") << true << false << true << false << true << true; + QTest::newRow("false -> false") << false << false << false << false << false << true; - QTest::newRow("false -> true, unsupported") << false << true << true << false << false; + QTest::newRow("false -> true, unsupported") << false << false << true << true << false << false; } void TestLibinputDevice::testScrollButtonDown() { libinput_device device; QFETCH(bool, initValue); + QFETCH(bool, otherValue); QFETCH(bool, setShouldFail); QFETCH(bool, supportsScrollButtonDown); - device.supportedScrollMethods = supportsScrollButtonDown ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; - device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + device.supportedScrollMethods = (supportsScrollButtonDown ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG; + device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; device.setScrollMethodReturnValue = setShouldFail; Device d(&device); QCOMPARE(d.isScrollOnButtonDown(), initValue); QCOMPARE(d.property("scrollOnButtonDown").toBool(), initValue); + QCOMPARE(d.property("scrollTwoFinger").toBool(), otherValue); QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged); QVERIFY(scrollMethodChangedSpy.isValid()); diff --git a/libinput/device.h b/libinput/device.h --- a/libinput/device.h +++ b/libinput/device.h @@ -369,7 +369,7 @@ void setPointerAccelerationProfileAdaptive(bool set) { setPointerAccelerationProfile(set, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); } - void activatePointerAccelerationProfileFromInt(quint32 profile) { + void setPointerAccelerationProfileFromInt(quint32 profile) { setPointerAccelerationProfile(true, (libinput_config_accel_profile) profile); } quint32 defaultPointerAccelerationProfileToInt() const { diff --git a/libinput/device.cpp b/libinput/device.cpp --- a/libinput/device.cpp +++ b/libinput/device.cpp @@ -121,7 +121,7 @@ {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::PointerAccelerationProfile, ConfigData(QByteArrayLiteral("PointerAccelerationProfile"), &Device::setPointerAccelerationProfileFromInt, &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)}, @@ -315,13 +315,14 @@ } void Device::setPointerAccelerationProfile(bool set, enum libinput_config_accel_profile profile) { - if (!(m_supportedPointerAccelerationProfiles & profile)) { return; } - if (!set) { - profile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; + profile = (profile == LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT) ? LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE : LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT; + if (!(m_supportedPointerAccelerationProfiles & profile)) { + return; + } } if (libinput_device_config_accel_set_profile(m_device, profile) == LIBINPUT_CONFIG_STATUS_SUCCESS) { @@ -339,12 +340,18 @@ return; } + bool isCurrent = m_scrollMethod == method; if (!set) { - method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + if (isCurrent) { + method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + isCurrent = false; + } else { + return; + } } if (libinput_device_config_scroll_set_method(m_device, method) == LIBINPUT_CONFIG_STATUS_SUCCESS) { - if (m_scrollMethod != method) { + if (!isCurrent) { m_scrollMethod = method; emit scrollMethodChanged(); writeEntry(ConfigKey::ScrollMethod, (quint32) method);