[libinput] Add optional device detection for cap tablet tool

The capability tablet tool is new in Libinput 1.2. As build.kde.org
does not yet support this version, it's only an optional check.

So far the code only detects whether the capability exists and reports
this accordingly.
icc-effect-5.14.5
Martin Gräßlin 2016-08-03 09:31:47 +02:00
parent 17abac9db3
commit 6a6af0e8b5
6 changed files with 39 additions and 10 deletions

View File

@ -182,6 +182,13 @@ if (UDEV_FOUND)
set(HAVE_UDEV TRUE)
endif()
set(HAVE_LIBINPUT_1_2 FALSE)
if (Libinput_FOUND)
if (NOT (Libinput_VERSION VERSION_LESS "1.2"))
set(HAVE_LIBINPUT_1_2 TRUE)
endif()
endif()
find_package(Libdrm)
set_package_properties(Libdrm PROPERTIES TYPE OPTIONAL PURPOSE "Required for drm output on Wayland.")
set(HAVE_DRM FALSE)

View File

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "mock_libinput.h"
#include "../../libinput/device.h"
#include <config-kwin.h>
#include <QtTest/QtTest>
@ -115,14 +116,16 @@ void TestLibinputDevice::testDeviceType_data()
QTest::addColumn<bool>("keyboard");
QTest::addColumn<bool>("pointer");
QTest::addColumn<bool>("touch");
QTest::addColumn<bool>("tabletTool");
QTest::newRow("keyboard") << true << false << false;
QTest::newRow("pointer") << false << true << false;
QTest::newRow("touch") << false << false << true;
QTest::newRow("keyboard/pointer") << true << true << false;
QTest::newRow("keyboard/touch") << true << false << true;
QTest::newRow("pointer/touch") << false << true << true;
QTest::newRow("keyboard/pointer/touch") << true << true << true;
QTest::newRow("keyboard") << true << false << false << false;
QTest::newRow("pointer") << false << true << false << false;
QTest::newRow("touch") << false << false << true << false;
QTest::newRow("keyboard/pointer") << true << true << false << false;
QTest::newRow("keyboard/touch") << true << false << true << false;
QTest::newRow("pointer/touch") << false << true << true << false;
QTest::newRow("keyboard/pointer/touch") << true << true << true << false;
QTest::newRow("tabletTool") << false << false << false << true;
}
void TestLibinputDevice::testDeviceType()
@ -131,11 +134,13 @@ void TestLibinputDevice::testDeviceType()
QFETCH(bool, keyboard);
QFETCH(bool, pointer);
QFETCH(bool, touch);
QFETCH(bool, tabletTool);
libinput_device device;
device.keyboard = keyboard;
device.pointer = pointer;
device.touch = touch;
device.tabletTool = tabletTool;
Device d(&device);
QCOMPARE(d.isKeyboard(), keyboard);
@ -146,8 +151,13 @@ void TestLibinputDevice::testDeviceType()
QCOMPARE(d.property("touch").toBool(), touch);
QCOMPARE(d.isTabletPad(), false);
QCOMPARE(d.property("tabletPad").toBool(), false);
#if HAVE_LIBINPUT_1_2
QCOMPARE(d.isTabletTool(), tabletTool);
QCOMPARE(d.property("tabletTool").toBool(), tabletTool);
#else
QCOMPARE(d.isTabletTool(), false);
QCOMPARE(d.property("tabletTool").toBool(), false);
#endif
QCOMPARE(d.device(), &device);
}

View File

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include <libinput.h>
#include "mock_libinput.h"
#include <config-kwin.h>
#include <linux/input.h>
@ -38,6 +39,10 @@ int libinput_device_has_capability(struct libinput_device *device, enum libinput
return device->touch;
case LIBINPUT_DEVICE_CAP_GESTURE:
return device->gestureSupported;
#if HAVE_LIBINPUT_1_2
case LIBINPUT_DEVICE_CAP_TABLET_TOOL:
return device->tabletTool;
#endif
default:
return 0;
}

View File

@ -30,6 +30,7 @@ struct libinput_device {
bool keyboard = false;
bool pointer = false;
bool touch = false;
bool tabletTool = false;
bool gestureSupported = false;
QByteArray name;
QByteArray sysName;

View File

@ -10,6 +10,7 @@
#define KWIN_RULES_DIALOG_BIN "${CMAKE_INSTALL_FULL_LIBEXECDIR}/kwin_rules_dialog"
#define KWIN_XCLIPBOARD_SYNC_BIN "${CMAKE_INSTALL_FULL_LIBEXECDIR}/org_kde_kwin_xclipboard_syncer"
#cmakedefine01 HAVE_INPUT
#cmakedefine01 HAVE_LIBINPUT_1_2
#cmakedefine01 HAVE_X11_XCB
#cmakedefine01 HAVE_X11_XINPUT
#cmakedefine01 HAVE_DRM

View File

@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <linux/input.h>
#include <config-kwin.h>
namespace KWin
{
namespace LibInput
@ -73,12 +75,15 @@ Device::Device(libinput_device *device, QObject *parent)
, m_keyboard(libinput_device_has_capability(m_device, LIBINPUT_DEVICE_CAP_KEYBOARD))
, m_pointer(libinput_device_has_capability(m_device, LIBINPUT_DEVICE_CAP_POINTER))
, m_touch(libinput_device_has_capability(m_device, LIBINPUT_DEVICE_CAP_TOUCH))
#if 0
// next libinput version
#if HAVE_LIBINPUT_1_2
, m_tabletTool(libinput_device_has_capability(m_device, LIBINPUT_DEVICE_CAP_TABLET_TOOL))
, m_tabletPad(libinput_device_has_capability(m_device, LIBINPUT_DEVICE_CAP_TABLET_PAD))
#else
, m_tabletTool(false)
#endif
#if 0
// next libinput version
, m_tabletPad(libinput_device_has_capability(m_device, LIBINPUT_DEVICE_CAP_TABLET_PAD))
#else
, m_tabletPad(false)
#endif
, m_supportsGesture(libinput_device_has_capability(m_device, LIBINPUT_DEVICE_CAP_GESTURE))