diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,7 +137,11 @@ 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) diff --git a/config-X11.h.cmake b/config-X11.h.cmake --- a/config-X11.h.cmake +++ b/config-X11.h.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 diff --git a/kcms/touchpad/src/backends/libinputcommon.h b/kcms/touchpad/src/backends/libinputcommon.h --- a/kcms/touchpad/src/backends/libinputcommon.h +++ b/kcms/touchpad/src/backends/libinputcommon.h @@ -25,25 +25,25 @@ namespace { template -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(reply.toInt()); } +inline Qt::MouseButtons valueLoaderPart(QVariant const &reply) { return static_cast(reply.toInt()); } } class LibinputCommon : public QObject diff --git a/kcms/touchpad/src/backends/x11.cmake b/kcms/touchpad/src/backends/x11.cmake --- a/kcms/touchpad/src/backends/x11.cmake +++ b/kcms/touchpad/src/backends/x11.cmake @@ -16,17 +16,23 @@ 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 diff --git a/kcms/touchpad/src/backends/x11/libinputtouchpad.cpp b/kcms/touchpad/src/backends/x11/libinputtouchpad.cpp --- a/kcms/touchpad/src/backends/x11/libinputtouchpad.cpp +++ b/kcms/touchpad/src/backends/x11/libinputtouchpad.cpp @@ -16,19 +16,18 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include -#include - #include "libinputtouchpad.h" +#include "logging.h" #include #include -#include #include -#include "logging.h" +#include + +#include -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 @@ {"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) diff --git a/kcms/touchpad/src/backends/x11/xlibbackend.cpp b/kcms/touchpad/src/backends/x11/xlibbackend.cpp --- a/kcms/touchpad/src/backends/x11/xlibbackend.cpp +++ b/kcms/touchpad/src/backends/x11/xlibbackend.cpp @@ -25,11 +25,15 @@ #include #include +#include + //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 @@ 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 touchpads; +#if HAVE_XORGLIBINPUT LibinputTouchpad* libinputtouchpad = dynamic_cast (m_device.data()); - SynapticsTouchpad* synaptics = dynamic_cast (m_device.data()); - if ( libinputtouchpad) { touchpads.push_back(libinputtouchpad); } +#endif + + SynapticsTouchpad* synaptics = dynamic_cast (m_device.data()); if (synaptics) { touchpads.push_back(synaptics); }