Merge branch 'Plasma/5.8'

icc-effect-5.14.5
Martin Gräßlin 2016-11-04 10:03:10 +01:00
commit f17d06ee7d
8 changed files with 791 additions and 3 deletions

View File

@ -521,6 +521,7 @@ void DebugConsoleTest::testClosingDebugConsole()
QVERIFY(c->isInternal());
QCOMPARE(c->internalWindow(), console->windowHandle());
QVERIFY(c->isDecorated());
QCOMPARE(c->isMinimizable(), false);
c->closeWindow();
QVERIFY(destroyedSpy.wait());
}

View File

@ -45,6 +45,16 @@ private Q_SLOTS:
void testSize();
void testTapEnabledByDefault_data();
void testTapEnabledByDefault();
void testMiddleEmulationEnabledByDefault_data();
void testMiddleEmulationEnabledByDefault();
void testNaturalScrollEnabledByDefault_data();
void testNaturalScrollEnabledByDefault();
void testScrollTwoFingerEnabledByDefault_data();
void testScrollTwoFingerEnabledByDefault();
void testScrollEdgeEnabledByDefault_data();
void testScrollEdgeEnabledByDefault();
void testScrollOnButtonDownEnabledByDefault_data();
void testScrollOnButtonDownEnabledByDefault();
void testSupportsDisableWhileTyping_data();
void testSupportsDisableWhileTyping();
void testSupportsPointerAcceleration_data();
@ -57,6 +67,18 @@ private Q_SLOTS:
void testSupportsDisableEvents();
void testSupportsDisableEventsOnExternalMouse_data();
void testSupportsDisableEventsOnExternalMouse();
void testSupportsMiddleEmulation_data();
void testSupportsMiddleEmulation();
void testSupportsNaturalScroll_data();
void testSupportsNaturalScroll();
void testSupportsScrollTwoFinger_data();
void testSupportsScrollTwoFinger();
void testSupportsScrollEdge_data();
void testSupportsScrollEdge();
void testSupportsScrollOnButtonDown_data();
void testSupportsScrollOnButtonDown();
void testDefaultScrollButton_data();
void testDefaultScrollButton();
void testPointerAcceleration_data();
void testPointerAcceleration();
void testLeftHanded_data();
@ -77,6 +99,18 @@ private Q_SLOTS:
void testTapDragLockEnabledByDefault();
void testTapDragLock_data();
void testTapDragLock();
void testMiddleEmulation_data();
void testMiddleEmulation();
void testNaturalScroll_data();
void testNaturalScroll();
void testScrollTwoFinger_data();
void testScrollTwoFinger();
void testScrollEdge_data();
void testScrollEdge();
void testScrollButtonDown_data();
void testScrollButtonDown();
void testScrollButton_data();
void testScrollButton();
};
void TestLibinputDevice::testStaticGetter()
@ -290,6 +324,127 @@ void TestLibinputDevice::testTapEnabledByDefault()
QCOMPARE(d.property("tapToClickEnabledByDefault").toBool(), enabled);
}
void TestLibinputDevice::testMiddleEmulationEnabledByDefault_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testMiddleEmulationEnabledByDefault()
{
QFETCH(bool, enabled);
libinput_device device;
device.middleEmulationEnabledByDefault = enabled;
Device d(&device);
QCOMPARE(d.middleEmulationEnabledByDefault(), enabled);
QCOMPARE(d.property("middleEmulationEnabledByDefault").toBool(), enabled);
}
void TestLibinputDevice::testNaturalScrollEnabledByDefault_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testNaturalScrollEnabledByDefault()
{
QFETCH(bool, enabled);
libinput_device device;
device.naturalScrollEnabledByDefault = enabled;
Device d(&device);
QCOMPARE(d.naturalScrollEnabledByDefault(), enabled);
QCOMPARE(d.property("naturalScrollEnabledByDefault").toBool(), enabled);
}
void TestLibinputDevice::testScrollTwoFingerEnabledByDefault_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testScrollTwoFingerEnabledByDefault()
{
QFETCH(bool, enabled);
libinput_device device;
device.defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
Device d(&device);
QCOMPARE(d.scrollTwoFingerEnabledByDefault(), enabled);
QCOMPARE(d.property("scrollTwoFingerEnabledByDefault").toBool(), enabled);
}
void TestLibinputDevice::testScrollEdgeEnabledByDefault_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testScrollEdgeEnabledByDefault()
{
QFETCH(bool, enabled);
libinput_device device;
device.defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
Device d(&device);
QCOMPARE(d.scrollEdgeEnabledByDefault(), enabled);
QCOMPARE(d.property("scrollEdgeEnabledByDefault").toBool(), enabled);
}
void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault()
{
QFETCH(bool, enabled);
libinput_device device;
device.defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
Device d(&device);
QCOMPARE(d.scrollOnButtonDownEnabledByDefault(), enabled);
QCOMPARE(d.property("scrollOnButtonDownEnabledByDefault").toBool(), enabled);
}
void TestLibinputDevice::testDefaultScrollButton_data()
{
QTest::addColumn<quint32>("button");
QTest::newRow("0") << 0u;
QTest::newRow("BTN_LEFT") << quint32(BTN_LEFT);
QTest::newRow("BTN_RIGHT") << quint32(BTN_RIGHT);
QTest::newRow("BTN_MIDDLE") << quint32(BTN_MIDDLE);
QTest::newRow("BTN_SIDE") << quint32(BTN_SIDE);
QTest::newRow("BTN_EXTRA") << quint32(BTN_EXTRA);
QTest::newRow("BTN_FORWARD") << quint32(BTN_FORWARD);
QTest::newRow("BTN_BACK") << quint32(BTN_BACK);
QTest::newRow("BTN_TASK") << quint32(BTN_TASK);
}
void TestLibinputDevice::testDefaultScrollButton()
{
libinput_device device;
QFETCH(quint32, button);
device.defaultScrollButton = button;
Device d(&device);
QCOMPARE(d.defaultScrollButton(), button);
QCOMPARE(d.property("defaultScrollButton").value<quint32>(), button);
}
void TestLibinputDevice::testSupportsDisableWhileTyping_data()
{
QTest::addColumn<bool>("enabled");
@ -404,6 +559,101 @@ void TestLibinputDevice::testSupportsDisableEventsOnExternalMouse()
QCOMPARE(d.property("supportsDisableEventsOnExternalMouse").toBool(), enabled);
}
void TestLibinputDevice::testSupportsMiddleEmulation_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testSupportsMiddleEmulation()
{
QFETCH(bool, enabled);
libinput_device device;
device.supportsMiddleEmulation = enabled;
Device d(&device);
QCOMPARE(d.supportsMiddleEmulation(), enabled);
QCOMPARE(d.property("supportsMiddleEmulation").toBool(), enabled);
}
void TestLibinputDevice::testSupportsNaturalScroll_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testSupportsNaturalScroll()
{
QFETCH(bool, enabled);
libinput_device device;
device.supportsNaturalScroll = enabled;
Device d(&device);
QCOMPARE(d.supportsNaturalScroll(), enabled);
QCOMPARE(d.property("supportsNaturalScroll").toBool(), enabled);
}
void TestLibinputDevice::testSupportsScrollTwoFinger_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testSupportsScrollTwoFinger()
{
QFETCH(bool, enabled);
libinput_device device;
device.supportedScrollMethods = enabled ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
Device d(&device);
QCOMPARE(d.supportsScrollTwoFinger(), enabled);
QCOMPARE(d.property("supportsScrollTwoFinger").toBool(), enabled);
}
void TestLibinputDevice::testSupportsScrollEdge_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testSupportsScrollEdge()
{
QFETCH(bool, enabled);
libinput_device device;
device.supportedScrollMethods = enabled ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
Device d(&device);
QCOMPARE(d.supportsScrollEdge(), enabled);
QCOMPARE(d.property("supportsScrollEdge").toBool(), enabled);
}
void TestLibinputDevice::testSupportsScrollOnButtonDown_data()
{
QTest::addColumn<bool>("enabled");
QTest::newRow("enabled") << true;
QTest::newRow("disabled") << false;
}
void TestLibinputDevice::testSupportsScrollOnButtonDown()
{
QFETCH(bool, enabled);
libinput_device device;
device.supportedScrollMethods = enabled ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
Device d(&device);
QCOMPARE(d.supportsScrollOnButtonDown(), enabled);
QCOMPARE(d.property("supportsScrollOnButtonDown").toBool(), enabled);
}
void TestLibinputDevice::testPointerAcceleration_data()
{
QTest::addColumn<bool>("supported");
@ -764,5 +1014,248 @@ void TestLibinputDevice::testTapDragLock()
QCOMPARE(tapDragLockChangedSpy.isEmpty(), initValue == expectedValue);
}
void TestLibinputDevice::testMiddleEmulation_data()
{
QTest::addColumn<bool>("initValue");
QTest::addColumn<bool>("setValue");
QTest::addColumn<bool>("setShouldFail");
QTest::addColumn<bool>("expectedValue");
QTest::addColumn<bool>("supportsMiddleButton");
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::testMiddleEmulation()
{
libinput_device device;
QFETCH(bool, initValue);
QFETCH(bool, setShouldFail);
QFETCH(bool, supportsMiddleButton);
device.supportsMiddleEmulation = supportsMiddleButton;
device.middleEmulation = initValue;
device.setMiddleEmulationReturnValue = setShouldFail;
Device d(&device);
QCOMPARE(d.isMiddleEmulation(), initValue);
QCOMPARE(d.property("middleEmulation").toBool(), initValue);
QSignalSpy middleEmulationChangedSpy(&d, &Device::middleEmulationChanged);
QVERIFY(middleEmulationChangedSpy.isValid());
QFETCH(bool, setValue);
d.setMiddleEmulation(setValue);
QFETCH(bool, expectedValue);
QCOMPARE(d.isMiddleEmulation(), expectedValue);
QCOMPARE(d.property("middleEmulation").toBool(), expectedValue);
QCOMPARE(middleEmulationChangedSpy.isEmpty(), initValue == expectedValue);
}
void TestLibinputDevice::testNaturalScroll_data()
{
QTest::addColumn<bool>("initValue");
QTest::addColumn<bool>("setValue");
QTest::addColumn<bool>("setShouldFail");
QTest::addColumn<bool>("expectedValue");
QTest::addColumn<bool>("supportsNaturalScroll");
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::testNaturalScroll()
{
libinput_device device;
QFETCH(bool, initValue);
QFETCH(bool, setShouldFail);
QFETCH(bool, supportsNaturalScroll);
device.supportsNaturalScroll = supportsNaturalScroll;
device.naturalScroll = initValue;
device.setNaturalScrollReturnValue = setShouldFail;
Device d(&device);
QCOMPARE(d.isNaturalScroll(), initValue);
QCOMPARE(d.property("naturalScroll").toBool(), initValue);
QSignalSpy naturalScrollChangedSpy(&d, &Device::naturalScrollChanged);
QVERIFY(naturalScrollChangedSpy.isValid());
QFETCH(bool, setValue);
d.setNaturalScroll(setValue);
QFETCH(bool, expectedValue);
QCOMPARE(d.isNaturalScroll(), expectedValue);
QCOMPARE(d.property("naturalScroll").toBool(), expectedValue);
QCOMPARE(naturalScrollChangedSpy.isEmpty(), initValue == expectedValue);
}
void TestLibinputDevice::testScrollTwoFinger_data()
{
QTest::addColumn<bool>("initValue");
QTest::addColumn<bool>("setValue");
QTest::addColumn<bool>("setShouldFail");
QTest::addColumn<bool>("expectedValue");
QTest::addColumn<bool>("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("false -> true, unsupported") << false << true << true << false << false;
}
void TestLibinputDevice::testScrollTwoFinger()
{
libinput_device device;
QFETCH(bool, initValue);
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.setScrollMethodReturnValue = setShouldFail;
Device d(&device);
QCOMPARE(d.isScrollTwoFinger(), initValue);
QCOMPARE(d.property("scrollTwoFinger").toBool(), initValue);
QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged);
QVERIFY(scrollMethodChangedSpy.isValid());
QFETCH(bool, setValue);
d.setScrollTwoFinger(setValue);
QFETCH(bool, expectedValue);
QCOMPARE(d.isScrollTwoFinger(), expectedValue);
QCOMPARE(d.property("scrollTwoFinger").toBool(), expectedValue);
QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue);
}
void TestLibinputDevice::testScrollEdge_data()
{
QTest::addColumn<bool>("initValue");
QTest::addColumn<bool>("setValue");
QTest::addColumn<bool>("setShouldFail");
QTest::addColumn<bool>("expectedValue");
QTest::addColumn<bool>("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("false -> true, unsupported") << false << true << true << false << false;
}
void TestLibinputDevice::testScrollEdge()
{
libinput_device device;
QFETCH(bool, initValue);
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.setScrollMethodReturnValue = setShouldFail;
Device d(&device);
QCOMPARE(d.isScrollEdge(), initValue);
QCOMPARE(d.property("scrollEdge").toBool(), initValue);
QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged);
QVERIFY(scrollMethodChangedSpy.isValid());
QFETCH(bool, setValue);
d.setScrollEdge(setValue);
QFETCH(bool, expectedValue);
QCOMPARE(d.isScrollEdge(), expectedValue);
QCOMPARE(d.property("scrollEdge").toBool(), expectedValue);
QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue);
}
void TestLibinputDevice::testScrollButtonDown_data()
{
QTest::addColumn<bool>("initValue");
QTest::addColumn<bool>("setValue");
QTest::addColumn<bool>("setShouldFail");
QTest::addColumn<bool>("expectedValue");
QTest::addColumn<bool>("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("false -> true, unsupported") << false << true << true << false << false;
}
void TestLibinputDevice::testScrollButtonDown()
{
libinput_device device;
QFETCH(bool, initValue);
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.setScrollMethodReturnValue = setShouldFail;
Device d(&device);
QCOMPARE(d.isScrollOnButtonDown(), initValue);
QCOMPARE(d.property("scrollOnButtonDown").toBool(), initValue);
QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged);
QVERIFY(scrollMethodChangedSpy.isValid());
QFETCH(bool, setValue);
d.setScrollOnButtonDown(setValue);
QFETCH(bool, expectedValue);
QCOMPARE(d.isScrollOnButtonDown(), expectedValue);
QCOMPARE(d.property("scrollOnButtonDown").toBool(), expectedValue);
QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue);
}
void TestLibinputDevice::testScrollButton_data()
{
QTest::addColumn<quint32>("initValue");
QTest::addColumn<quint32>("setValue");
QTest::addColumn<quint32>("expectedValue");
QTest::addColumn<bool>("setShouldFail");
QTest::addColumn<bool>("scrollOnButton");
QTest::newRow("BTN_LEFT -> BTN_RIGHT") << quint32(BTN_LEFT) << quint32(BTN_RIGHT) << quint32(BTN_RIGHT) << false << true;
QTest::newRow("BTN_LEFT -> BTN_LEFT") << quint32(BTN_LEFT) << quint32(BTN_LEFT) << quint32(BTN_LEFT) << false << true;
QTest::newRow("set should fail") << quint32(BTN_LEFT) << quint32(BTN_RIGHT) << quint32(BTN_LEFT) << true << true;
QTest::newRow("not scroll on button") << quint32(BTN_LEFT) << quint32(BTN_RIGHT) << quint32(BTN_LEFT) << false << false;
}
void TestLibinputDevice::testScrollButton()
{
libinput_device device;
QFETCH(quint32, initValue);
QFETCH(bool, setShouldFail);
QFETCH(bool, scrollOnButton);
device.scrollButton = initValue;
device.supportedScrollMethods = scrollOnButton ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
device.setScrollButtonReturnValue = setShouldFail;
Device d(&device);
QCOMPARE(d.scrollButton(), initValue);
QCOMPARE(d.property("scrollButton").value<quint32>(), initValue);
QSignalSpy scrollButtonChangedSpy(&d, &Device::scrollButtonChanged);
QVERIFY(scrollButtonChangedSpy.isValid());
QFETCH(quint32, setValue);
d.setScrollButton(setValue);
QFETCH(quint32, expectedValue);
QCOMPARE(d.scrollButton(), expectedValue);
QCOMPARE(d.property("scrollButton").value<quint32>(), expectedValue);
QCOMPARE(scrollButtonChangedSpy.isEmpty(), initValue == expectedValue);
}
QTEST_GUILESS_MAIN(TestLibinputDevice)
#include "device_test.moc"

View File

@ -602,3 +602,114 @@ int libinput_resume(struct libinput *libinput)
Q_UNUSED(libinput)
return 0;
}
int libinput_device_config_middle_emulation_is_available(struct libinput_device *device)
{
return device->supportsMiddleEmulation;
}
enum libinput_config_status libinput_device_config_middle_emulation_set_enabled(struct libinput_device *device, enum libinput_config_middle_emulation_state enable)
{
if (device->setMiddleEmulationReturnValue == 0) {
if (!device->supportsMiddleEmulation) {
return LIBINPUT_CONFIG_STATUS_INVALID;
}
device->middleEmulation = (enable == LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
return LIBINPUT_CONFIG_STATUS_INVALID;
}
enum libinput_config_middle_emulation_state libinput_device_config_middle_emulation_get_enabled(struct libinput_device *device)
{
if (device->middleEmulation) {
return LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED;
} else {
return LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
}
}
enum libinput_config_middle_emulation_state libinput_device_config_middle_emulation_get_default_enabled(struct libinput_device *device)
{
if (device->middleEmulationEnabledByDefault) {
return LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED;
} else {
return LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
}
}
int libinput_device_config_scroll_has_natural_scroll(struct libinput_device *device)
{
return device->supportsNaturalScroll;
}
enum libinput_config_status libinput_device_config_scroll_set_natural_scroll_enabled(struct libinput_device *device, int enable)
{
if (device->setNaturalScrollReturnValue == 0) {
if (!device->supportsNaturalScroll) {
return LIBINPUT_CONFIG_STATUS_INVALID;
}
device->naturalScroll = enable;
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
return LIBINPUT_CONFIG_STATUS_INVALID;
}
int libinput_device_config_scroll_get_natural_scroll_enabled(struct libinput_device *device)
{
return device->naturalScroll;
}
int libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput_device *device)
{
return device->naturalScrollEnabledByDefault;
}
uint32_t libinput_device_config_scroll_get_methods(struct libinput_device *device)
{
return device->supportedScrollMethods;
}
enum libinput_config_scroll_method libinput_device_config_scroll_get_default_method(struct libinput_device *device)
{
return device->defaultScrollMethod;
}
enum libinput_config_status libinput_device_config_scroll_set_method(struct libinput_device *device, enum libinput_config_scroll_method method)
{
if (device->setScrollMethodReturnValue == 0) {
if (!(device->supportedScrollMethods & method) && method != LIBINPUT_CONFIG_SCROLL_NO_SCROLL) {
return LIBINPUT_CONFIG_STATUS_INVALID;
}
device->scrollMethod = method;
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
return LIBINPUT_CONFIG_STATUS_INVALID;
}
enum libinput_config_scroll_method libinput_device_config_scroll_get_method(struct libinput_device *device)
{
return device->scrollMethod;
}
enum libinput_config_status libinput_device_config_scroll_set_button(struct libinput_device *device, uint32_t button)
{
if (device->setScrollButtonReturnValue == 0) {
if (!(device->supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)) {
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
}
device->scrollButton = button;
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
return LIBINPUT_CONFIG_STATUS_INVALID;
}
uint32_t libinput_device_config_scroll_get_button(struct libinput_device *device)
{
return device->scrollButton;
}
uint32_t libinput_device_config_scroll_get_default_button(struct libinput_device *device)
{
return device->defaultScrollButton;
}

View File

@ -52,10 +52,24 @@ struct libinput_device {
bool supportsCalibrationMatrix = false;
bool supportsDisableEvents = false;
bool supportsDisableEventsOnExternalMouse = false;
bool supportsMiddleEmulation = false;
bool supportsNaturalScroll = false;
quint32 supportedScrollMethods = 0;
bool middleEmulationEnabledByDefault = false;
bool middleEmulation = false;
qreal pointerAcceleration = 0.0;
int setPointerAccelerationReturnValue = 0;
bool leftHanded = false;
int setLeftHandedReturnValue = 0;
bool naturalScrollEnabledByDefault = false;
bool naturalScroll = false;
int setNaturalScrollReturnValue = 0;
enum libinput_config_scroll_method defaultScrollMethod = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
enum libinput_config_scroll_method scrollMethod = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
int setScrollMethodReturnValue = 0;
quint32 defaultScrollButton = 0;
quint32 scrollButton = 0;
int setScrollButtonReturnValue = 0;
Qt::MouseButtons supportedButtons;
QVector<quint32> keys;
bool enabled = true;
@ -63,6 +77,7 @@ struct libinput_device {
int setTapToClickReturnValue = 0;
int setTapAndDragReturnValue = 0;
int setTapDragLockReturnValue = 0;
int setMiddleEmulationReturnValue = 0;
};
struct libinput_event {

View File

@ -494,8 +494,8 @@ class InternalWindowEventFilter : public InputEventFilter {
const Qt::Orientation orientation = (event->angleDelta().x() != 0) ? Qt::Horizontal : Qt::Vertical;
const int delta = event->angleDelta().x() != 0 ? event->angleDelta().x() : event->angleDelta().y();
QWheelEvent e(localPos, event->globalPosF(), QPoint(),
event->angleDelta(),
delta,
event->angleDelta() * -1,
delta * -1,
orientation,
event->buttons(),
event->modifiers());

View File

@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "device.h"
#include <libinput.h>
#include <QDBusConnection>
@ -103,7 +102,18 @@ Device::Device(libinput_device *device, QObject *parent)
, m_supportsCalibrationMatrix(libinput_device_config_calibration_has_matrix(m_device))
, m_supportsDisableEvents(libinput_device_config_send_events_get_modes(m_device) & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED)
, m_supportsDisableEventsOnExternalMouse(libinput_device_config_send_events_get_modes(m_device) & LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE)
, m_supportsMiddleEmulation(libinput_device_config_middle_emulation_is_available(m_device))
, m_supportsNaturalScroll(libinput_device_config_scroll_has_natural_scroll(m_device))
, m_supportedScrollMethods(libinput_device_config_scroll_get_methods(m_device))
, m_middleEmulationEnabledByDefault(libinput_device_config_middle_emulation_get_default_enabled(m_device) == LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED)
, 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_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_pointerAcceleration(libinput_device_config_accel_get_speed(m_device))
, m_enabled(m_supportsDisableEvents ? libinput_device_config_send_events_get_mode(m_device) == LIBINPUT_CONFIG_SEND_EVENTS_ENABLED : true)
{
@ -186,6 +196,66 @@ void Device::setPointerAcceleration(qreal acceleration)
}
}
void Device::setNaturalScroll(bool set)
{
if (!m_supportsNaturalScroll) {
return;
}
if (libinput_device_config_scroll_set_natural_scroll_enabled(m_device, set) == LIBINPUT_CONFIG_STATUS_SUCCESS) {
if (m_naturalScroll != set) {
m_naturalScroll = set;
emit naturalScrollChanged();
}
}
}
void Device::setScrollMethod(bool set, enum libinput_config_scroll_method method)
{
if (!(m_supportedScrollMethods & method)) {
return;
}
if (set) {
if (m_scrollMethod == method) {
return;
}
} else {
if (m_scrollMethod != method) {
return;
}
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();
}
}
void Device::setScrollTwoFinger(bool set) {
setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_2FG);
}
void Device::setScrollEdge(bool set) {
setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_EDGE);
}
void Device::setScrollOnButtonDown(bool set) {
setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
}
void Device::setScrollButton(quint32 button)
{
if (!(m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)) {
return;
}
if (libinput_device_config_scroll_set_button(m_device, button) == LIBINPUT_CONFIG_STATUS_SUCCESS) {
if (m_scrollButton != button) {
m_scrollButton = button;
emit scrollButtonChanged();
}
}
}
#define CONFIG(method, condition, function, enum, variable) \
void Device::method(bool set) \
{ \
@ -204,6 +274,7 @@ CONFIG(setEnabled, !m_supportsDisableEvents, send_events_set_mode, SEND_EVENTS,
CONFIG(setTapToClick, m_tapFingerCount == 0, tap_set_enabled, TAP, tapToClick)
CONFIG(setTapAndDrag, false, tap_set_drag_enabled, DRAG, tapAndDrag)
CONFIG(setTapDragLock, false, tap_set_drag_lock_enabled, DRAG_LOCK, tapDragLock)
CONFIG(setMiddleEmulation, m_supportsMiddleEmulation == false, middle_emulation_set_enabled, MIDDLE_EMULATION, middleEmulation)
#undef CONFIG

View File

@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KWIN_LIBINPUT_DEVICE_H
#define KWIN_LIBINPUT_DEVICE_H
#include <libinput.h>
#include <QObject>
#include <QSizeF>
#include <QVector>
@ -57,7 +59,24 @@ class Device : public QObject
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 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(qreal pointerAcceleration READ pointerAcceleration WRITE setPointerAcceleration NOTIFY pointerAccelerationChanged)
Q_PROPERTY(bool tapToClick READ isTapToClick WRITE setTapToClick NOTIFY tapToClickChanged)
Q_PROPERTY(bool tapAndDragEnabledByDefault READ tapAndDragEnabledByDefault CONSTANT)
@ -156,6 +175,64 @@ public:
bool supportsDisableEventsOnExternalMouse() const {
return m_supportsDisableEventsOnExternalMouse;
}
bool supportsMiddleEmulation() const {
return m_supportsMiddleEmulation;
}
bool supportsNaturalScroll() const {
return m_supportsNaturalScroll;
}
bool supportsScrollTwoFinger() const {
return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_2FG);
}
bool supportsScrollEdge() const {
return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_EDGE);
}
bool supportsScrollOnButtonDown() const {
return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
}
bool middleEmulationEnabledByDefault() const {
return m_middleEmulationEnabledByDefault;
}
bool naturalScrollEnabledByDefault() const {
return m_naturalScrollEnabledByDefault;
}
bool scrollTwoFingerEnabledByDefault() const {
return m_defaultScrollMethod == LIBINPUT_CONFIG_SCROLL_2FG;
}
bool scrollEdgeEnabledByDefault() const {
return m_defaultScrollMethod == LIBINPUT_CONFIG_SCROLL_EDGE;
}
bool scrollOnButtonDownEnabledByDefault() const {
return m_defaultScrollMethod == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
}
quint32 defaultScrollButton() const {
return m_defaultScrollButton;
}
bool isMiddleEmulation() const {
return m_middleEmulation;
}
void setMiddleEmulation(bool set);
bool isNaturalScroll() const {
return m_naturalScroll;
}
void setNaturalScroll(bool set);
void setScrollMethod(bool set, enum libinput_config_scroll_method method);
bool isScrollTwoFinger() const {
return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_2FG;
}
void setScrollTwoFinger(bool set);
bool isScrollEdge() const {
return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_EDGE;
}
void setScrollEdge(bool set);
bool isScrollOnButtonDown() const {
return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
}
void setScrollOnButtonDown(bool set);
quint32 scrollButton() const {
return m_scrollButton;
}
void setScrollButton(quint32 button);
bool isLeftHanded() const {
return m_leftHanded;
@ -201,6 +278,10 @@ Q_SIGNALS:
void tapToClickChanged();
void tapAndDragChanged();
void tapDragLockChanged();
void middleEmulationChanged();
void naturalScrollChanged();
void scrollMethodChanged();
void scrollButtonChanged();
private:
libinput_device *m_device;
@ -231,7 +312,20 @@ private:
bool m_supportsCalibrationMatrix;
bool m_supportsDisableEvents;
bool m_supportsDisableEventsOnExternalMouse;
bool m_supportsMiddleEmulation;
bool m_supportsNaturalScroll;
quint32 m_supportedScrollMethods;
bool m_supportsScrollEdge;
bool m_supportsScrollOnButtonDown;
bool m_middleEmulationEnabledByDefault;
bool m_naturalScrollEnabledByDefault;
enum libinput_config_scroll_method m_defaultScrollMethod;
quint32 m_defaultScrollButton;
bool m_middleEmulation;
bool m_leftHanded;
bool m_naturalScroll;
enum libinput_config_scroll_method m_scrollMethod;
quint32 m_scrollButton;
qreal m_pointerAcceleration;
bool m_enabled;

View File

@ -587,6 +587,9 @@ bool ShellClient::isMaximizable() const
bool ShellClient::isMinimizable() const
{
if (m_internal) {
return false;
}
return (!m_plasmaShellSurface || m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Normal);
}