Commit 8b1c894e authored by Roman Gilg's avatar Roman Gilg

[Touchpad KCM] Fix libinput-less build and warnings

Summary:
If the X.Org libinput dev packages are not found, do not
build the X11 libinput backend. This way the build succeeds.

Fix also some minor warnings.

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D21220
parent ce84d6ab
......@@ -137,7 +137,11 @@ add_feature_info("Synaptics" SYNAPTICS_FOUND "Synaptics libraries needed for tou
find_package(XorgLibinput)
set_package_properties(XorgLibinput PROPERTIES TYPE OPTIONAL)
add_feature_info("XorgLibinput" XORGLIBINPUT_FOUND "Libinput driver headers needed for mouse KCM")
add_feature_info("XorgLibinput" XORGLIBINPUT_FOUND "Libinput driver headers needed for mouse and touchpad KCM")
if(XORGLIBINPUT_FOUND)
set(HAVE_XORGLIBINPUT 1)
endif()
include(ConfigureChecks.cmake)
......
......@@ -40,5 +40,8 @@
/* Define if you have XRandR 1.3 */
#cmakedefine HAS_RANDR_1_3 1
/* Define if you have XorgLibinput */
#cmakedefine01 HAVE_XORGLIBINPUT
/* Define if you have X11 at all */
#cmakedefine01 HAVE_X11
......@@ -25,25 +25,25 @@
namespace {
template<typename T>
T valueLoaderPart(QVariant const &reply) { Q_UNUSED(reply); return T(); }
inline T valueLoaderPart(QVariant const &reply) { Q_UNUSED(reply); return T(); }
template<>
bool valueLoaderPart(QVariant const &reply) { return reply.toBool(); }
inline bool valueLoaderPart(QVariant const &reply) { return reply.toBool(); }
template<>
int valueLoaderPart(QVariant const &reply) { return reply.toInt(); }
inline int valueLoaderPart(QVariant const &reply) { return reply.toInt(); }
template<>
quint32 valueLoaderPart(QVariant const &reply) { return reply.toInt(); }
inline quint32 valueLoaderPart(QVariant const &reply) { return reply.toInt(); }
template<>
qreal valueLoaderPart(QVariant const &reply) { return reply.toReal(); }
inline qreal valueLoaderPart(QVariant const &reply) { return reply.toReal(); }
template<>
QString valueLoaderPart(QVariant const &reply) { return reply.toString(); }
inline QString valueLoaderPart(QVariant const &reply) { return reply.toString(); }
template<>
Qt::MouseButtons valueLoaderPart(QVariant const &reply) { return static_cast<Qt::MouseButtons>(reply.toInt()); }
inline Qt::MouseButtons valueLoaderPart(QVariant const &reply) { return static_cast<Qt::MouseButtons>(reply.toInt()); }
}
class LibinputCommon : public QObject
......
......@@ -16,17 +16,23 @@ include_directories(${X11_Xinput_INCLUDE_PATH}
SET(backend_SRCS
${backend_SRCS}
backends/libinputcommon.cpp
backends/x11/propertyinfo.cpp
backends/x11/xlibbackend.cpp
backends/x11/synapticstouchpad.cpp
backends/x11/libinputtouchpad.cpp
backends/x11/xlibtouchpad.cpp
backends/x11/xcbatom.cpp
backends/x11/xlibnotifications.cpp
backends/x11/xrecordkeyboardmonitor.cpp
)
if (HAVE_XORGLIBINPUT)
SET(backend_SRCS
${backend_SRCS}
backends/libinputcommon.cpp
backends/x11/libinputtouchpad.cpp
)
endif()
SET(backend_LIBS
${backend_LIBS}
XCB::ATOM
......
......@@ -16,19 +16,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QDebug>
#include <X11/extensions/XInput2.h>
#include "libinputtouchpad.h"
#include "logging.h"
#include <stddef.h>
#include <limits.h>
#include <xserver-properties.h>
#include <libinput-properties.h>
#include "logging.h"
#include <xserver-properties.h>
#include <X11/extensions/XInput2.h>
const struct Parameter libinputProperties[] = {
const Parameter libinputProperties[] = {
/* libinput disable supports property */
{"supportsDisableEvents", PT_INT, 0, 1, LIBINPUT_PROP_SENDEVENTS_AVAILABLE, 8, 0},
......@@ -118,7 +117,7 @@ const struct Parameter libinputProperties[] = {
{"clickMethodClickfinger", PT_INT, 0, 1, LIBINPUT_PROP_CLICK_METHOD_ENABLED, 8, 1},
/* libinput doesn't have a separate toggle for horiz scrolling */
{ NULL, PT_INT, 0, 0, 0, 0, 0 }
{ nullptr, PT_INT, 0, 0, nullptr, 0, 0 }
};
Qt::MouseButtons maskBtns(Display *display, XIButtonClassInfo *buttonInfo)
......
......@@ -25,11 +25,15 @@
#include <KLocalizedString>
#include <QDebug>
#include <config-X11.h>
//Includes are ordered this way because of #defines in Xorg's headers
#include "xrecordkeyboardmonitor.h" // krazy:exclude=includes
#include "xlibbackend.h" // krazy:exclude=includes
#include "xlibnotifications.h" // krazy:exclude=includes
#if HAVE_XORGLIBINPUT
#include "libinputtouchpad.h"
#endif
#include "synapticstouchpad.h"
#include "propertyinfo.h"
......@@ -119,10 +123,13 @@ XlibTouchpad* XlibBackend::findTouchpad()
Atom *atom = properties.data(), *atomEnd = properties.data() + nProperties;
for (; atom != atomEnd; atom++) {
#if HAVE_XORGLIBINPUT
if (*atom == m_libinputIdentifierAtom.atom()) {
setMode(TouchpadInputBackendMode::XLibinput);
return new LibinputTouchpad(m_display.data(), info->id);
} else if (*atom == m_synapticsIdentifierAtom.atom()) {
}
#endif
if (*atom == m_synapticsIdentifierAtom.atom()) {
setMode(TouchpadInputBackendMode::XSynaptics);
return new SynapticsTouchpad(m_display.data(), info->id);
}
......@@ -350,12 +357,14 @@ QVector<QObject *> XlibBackend::getDevices() const
{
QVector<QObject*> touchpads;
#if HAVE_XORGLIBINPUT
LibinputTouchpad* libinputtouchpad = dynamic_cast<LibinputTouchpad*> (m_device.data());
SynapticsTouchpad* synaptics = dynamic_cast<SynapticsTouchpad*> (m_device.data());
if ( libinputtouchpad) {
touchpads.push_back(libinputtouchpad);
}
#endif
SynapticsTouchpad* synaptics = dynamic_cast<SynapticsTouchpad*> (m_device.data());
if (synaptics) {
touchpads.push_back(synaptics);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment