diff --git a/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandbackend.cpp b/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandbackend.cpp index e9bc10a11..62810b16f 100644 --- a/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandbackend.cpp +++ b/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandbackend.cpp @@ -1,166 +1,164 @@ /* * Copyright 2017 Roman Gilg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kwinwaylandbackend.h" #include "kwinwaylandtouchpad.h" #include #include #include #include #include #include #include "logging.h" KWinWaylandBackend::KWinWaylandBackend(QObject *parent) : TouchpadBackend(parent) { m_deviceManager = new QDBusInterface (QStringLiteral("org.kde.KWin"), QStringLiteral("/org/kde/KWin/InputDevice"), QStringLiteral("org.kde.KWin.InputDeviceManager"), QDBusConnection::sessionBus(), this); setMode(TouchpadInputBackendMode::WaylandLibinput); findTouchpads(); m_deviceManager->connection().connect(QStringLiteral("org.kde.KWin"), QStringLiteral("/org/kde/KWin/InputDevice"), QStringLiteral("org.kde.KWin.InputDeviceManager"), QStringLiteral("deviceAdded"), this, SLOT(onDeviceAdded(QString))); m_deviceManager->connection().connect(QStringLiteral("org.kde.KWin"), QStringLiteral("/org/kde/KWin/InputDevice"), QStringLiteral("org.kde.KWin.InputDeviceManager"), QStringLiteral("deviceRemoved"), this, SLOT(onDeviceRemoved(QString))); } KWinWaylandBackend::~KWinWaylandBackend() { qDeleteAll(m_devices); delete m_deviceManager; } void KWinWaylandBackend::findTouchpads() { QStringList devicesSysNames; const QVariant reply = m_deviceManager->property("devicesSysNames"); if (reply.isValid()) { qCDebug(KCM_TOUCHPAD) << "Devices list received successfully from KWin."; devicesSysNames = reply.toStringList(); } else { qCCritical(KCM_TOUCHPAD) << "Error on receiving device list from KWin."; m_errorString = i18n("Querying input devices failed. Please reopen this settings module."); return; } - bool touchpadFound = false; for (QString sn : devicesSysNames) { QDBusInterface deviceIface(QStringLiteral("org.kde.KWin"), QStringLiteral("/org/kde/KWin/InputDevice/") + sn, QStringLiteral("org.kde.KWin.InputDevice"), QDBusConnection::sessionBus(), this); const QVariant reply = deviceIface.property("touchpad"); if (reply.isValid() && reply.toBool()) { KWinWaylandTouchpad* tp = new KWinWaylandTouchpad(sn); if (!tp->init()) { qCCritical(KCM_TOUCHPAD) << "Error on creating touchpad object" << sn; m_errorString = i18n("Critical error on reading fundamental device infos for touchpad %1.", sn); return; } m_devices.append(tp); - touchpadFound = true; qCDebug(KCM_TOUCHPAD).nospace() << "Touchpad found: " << tp->name() << " (" << tp->sysName() << ")"; } } } bool KWinWaylandBackend::applyConfig() { return std::all_of(m_devices.constBegin(), m_devices.constEnd(), [] (QObject *t) { return static_cast(t)->applyConfig(); }); } bool KWinWaylandBackend::getConfig() { return std::all_of(m_devices.constBegin(), m_devices.constEnd(), [] (QObject *t) { return static_cast(t)->getConfig(); }); } bool KWinWaylandBackend::getDefaultConfig() { return std::all_of(m_devices.constBegin(), m_devices.constEnd(), [] (QObject *t) { return static_cast(t)->getDefaultConfig(); }); } bool KWinWaylandBackend::isChangedConfig() const { return std::any_of(m_devices.constBegin(), m_devices.constEnd(), [] (QObject *t) { return static_cast(t)->isChangedConfig(); }); } void KWinWaylandBackend::onDeviceAdded(QString sysName) { if (std::any_of(m_devices.constBegin(), m_devices.constEnd(), [sysName] (QObject *t) { return static_cast(t)->sysName() == sysName; })) { return; } QDBusInterface deviceIface(QStringLiteral("org.kde.KWin"), QStringLiteral("/org/kde/KWin/InputDevice/") + sysName, QStringLiteral("org.kde.KWin.InputDevice"), QDBusConnection::sessionBus(), this); QVariant reply = deviceIface.property("touchpad"); if (reply.isValid() && reply.toBool()) { KWinWaylandTouchpad* tp = new KWinWaylandTouchpad(sysName); if (!tp->init() || !tp->getConfig()) { emit touchpadAdded(false); return; } m_devices.append(tp); qCDebug(KCM_TOUCHPAD).nospace() << "Touchpad connected: " << tp->name() << " (" << tp->sysName() << ")"; emit touchpadAdded(true); } } void KWinWaylandBackend::onDeviceRemoved(QString sysName) { QVector::const_iterator it = std::find_if(m_devices.constBegin(), m_devices.constEnd(), [sysName] (QObject *t) { return static_cast(t)->sysName() == sysName; }); if (it == m_devices.cend()) { return; } KWinWaylandTouchpad *tp = static_cast(*it); qCDebug(KCM_TOUCHPAD).nospace() << "Touchpad disconnected: " << tp->name() << " (" << tp->sysName() << ")"; int index = it - m_devices.cbegin(); m_devices.removeAt(index); emit touchpadRemoved(index); } diff --git a/kcms/touchpad/src/backends/x11/synapticstouchpad.cpp b/kcms/touchpad/src/backends/x11/synapticstouchpad.cpp index a3945d46a..d2f41d70b 100644 --- a/kcms/touchpad/src/backends/x11/synapticstouchpad.cpp +++ b/kcms/touchpad/src/backends/x11/synapticstouchpad.cpp @@ -1,273 +1,273 @@ /* * Copyright (C) 2013 Alexander Mezin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* //krazy:excludeall=copyright * This file incorporates work covered by the following copyright and * permission notice: * * Copyright © 2002-2005,2007 Peter Osterlund * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice * appear in supporting documentation, and that the name of Red Hat * not be used in advertising or publicity pertaining to distribution * of the software without specific, written prior permission. Red * Hat makes no representations about the suitability of this software * for any purpose. It is provided "as is" without express or implied * warranty. * * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Authors: * Peter Osterlund (petero2@telia.com) */ #include #include #include "synapticstouchpad.h" #include #include #include #define SYN_MAX_BUTTONS 12 const struct Parameter synapticsProperties[] = { {"LeftEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_EDGES, 32, 0}, {"RightEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_EDGES, 32, 1}, {"TopEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_EDGES, 32, 2}, {"BottomEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_EDGES, 32, 3}, {"FingerLow", PT_INT, 0, 255, SYNAPTICS_PROP_FINGER, 32, 0}, {"FingerHigh", PT_INT, 0, 255, SYNAPTICS_PROP_FINGER, 32, 1}, {"MaxTapTime", PT_INT, 0, 1000, SYNAPTICS_PROP_TAP_TIME, 32, 0}, {"MaxTapMove", PT_INT, 0, 2000, SYNAPTICS_PROP_TAP_MOVE, 32, 0}, {"MaxDoubleTapTime", PT_INT, 0, 1000, SYNAPTICS_PROP_TAP_DURATIONS,32, 1}, {"SingleTapTimeout", PT_INT, 0, 1000, SYNAPTICS_PROP_TAP_DURATIONS,32, 0}, {"ClickTime", PT_INT, 0, 1000, SYNAPTICS_PROP_TAP_DURATIONS,32, 2}, {"FastTaps", PT_BOOL, 0, 1, SYNAPTICS_PROP_TAP_FAST, 8, 0}, {"EmulateMidButtonTime", PT_INT, 0, 1000, SYNAPTICS_PROP_MIDDLE_TIMEOUT,32, 0}, {"EmulateTwoFingerMinZ", PT_INT, 0, 1000, SYNAPTICS_PROP_TWOFINGER_PRESSURE, 32, 0}, {"EmulateTwoFingerMinW", PT_INT, 0, 15, SYNAPTICS_PROP_TWOFINGER_WIDTH, 32, 0}, {"VertScrollDelta", PT_INT, -1000, 1000, SYNAPTICS_PROP_SCROLL_DISTANCE, 32, 0}, {"HorizScrollDelta", PT_INT, -1000, 1000, SYNAPTICS_PROP_SCROLL_DISTANCE, 32, 1}, {"VertEdgeScroll", PT_BOOL, 0, 1, SYNAPTICS_PROP_SCROLL_EDGE, 8, 0}, {"HorizEdgeScroll", PT_BOOL, 0, 1, SYNAPTICS_PROP_SCROLL_EDGE, 8, 1}, {"CornerCoasting", PT_BOOL, 0, 1, SYNAPTICS_PROP_SCROLL_EDGE, 8, 2}, {"VertTwoFingerScroll", PT_BOOL, 0, 1, SYNAPTICS_PROP_SCROLL_TWOFINGER, 8, 0}, {"HorizTwoFingerScroll", PT_BOOL, 0, 1, SYNAPTICS_PROP_SCROLL_TWOFINGER, 8, 1}, {"MinSpeed", PT_DOUBLE, 0, 255.0, SYNAPTICS_PROP_SPEED, 0, /*float */ 0}, {"MaxSpeed", PT_DOUBLE, 0, 255.0, SYNAPTICS_PROP_SPEED, 0, /*float */ 1}, {"AccelFactor", PT_DOUBLE, 0, 1.0, SYNAPTICS_PROP_SPEED, 0, /*float */ 2}, /*{"TouchpadOff", PT_INT, 0, 2, SYNAPTICS_PROP_OFF, 8, 0},*/ {"LockedDrags", PT_BOOL, 0, 1, SYNAPTICS_PROP_LOCKED_DRAGS, 8, 0}, {"LockedDragTimeout", PT_INT, 0, 30000, SYNAPTICS_PROP_LOCKED_DRAGS_TIMEOUT, 32, 0}, {"RTCornerButton", PT_INT, 0, SYN_MAX_BUTTONS, SYNAPTICS_PROP_TAP_ACTION, 8, 0}, {"RBCornerButton", PT_INT, 0, SYN_MAX_BUTTONS, SYNAPTICS_PROP_TAP_ACTION, 8, 1}, {"LTCornerButton", PT_INT, 0, SYN_MAX_BUTTONS, SYNAPTICS_PROP_TAP_ACTION, 8, 2}, {"LBCornerButton", PT_INT, 0, SYN_MAX_BUTTONS, SYNAPTICS_PROP_TAP_ACTION, 8, 3}, {"OneFingerTapButton", PT_INT, 0, SYN_MAX_BUTTONS, SYNAPTICS_PROP_TAP_ACTION, 8, 4}, {"TwoFingerTapButton", PT_INT, 0, SYN_MAX_BUTTONS, SYNAPTICS_PROP_TAP_ACTION, 8, 5}, {"ThreeFingerTapButton", PT_INT, 0, SYN_MAX_BUTTONS, SYNAPTICS_PROP_TAP_ACTION, 8, 6}, {"ClickFinger1", PT_INT, 0, SYN_MAX_BUTTONS, SYNAPTICS_PROP_CLICK_ACTION, 8, 0}, {"ClickFinger2", PT_INT, 0, SYN_MAX_BUTTONS, SYNAPTICS_PROP_CLICK_ACTION, 8, 1}, {"ClickFinger3", PT_INT, 0, SYN_MAX_BUTTONS, SYNAPTICS_PROP_CLICK_ACTION, 8, 2}, {"CircularScrolling", PT_BOOL, 0, 1, SYNAPTICS_PROP_CIRCULAR_SCROLLING, 8, 0}, {"CircScrollDelta", PT_DOUBLE, .01, 3, SYNAPTICS_PROP_CIRCULAR_SCROLLING_DIST, 0 /* float */, 0}, {"CircScrollTrigger", PT_INT, 0, 8, SYNAPTICS_PROP_CIRCULAR_SCROLLING_TRIGGER, 8, 0}, {"PalmDetect", PT_BOOL, 0, 1, SYNAPTICS_PROP_PALM_DETECT, 8, 0}, {"PalmMinWidth", PT_INT, 0, 15, SYNAPTICS_PROP_PALM_DIMENSIONS, 32, 0}, {"PalmMinZ", PT_INT, 0, 255, SYNAPTICS_PROP_PALM_DIMENSIONS, 32, 1}, {"CoastingSpeed", PT_DOUBLE, 0, 255, SYNAPTICS_PROP_COASTING_SPEED, 0 /* float*/, 0}, {"CoastingFriction", PT_DOUBLE, 0, 255, SYNAPTICS_PROP_COASTING_SPEED, 0 /* float*/, 1}, {"PressureMotionMinZ", PT_INT, 1, 255, SYNAPTICS_PROP_PRESSURE_MOTION, 32, 0}, {"PressureMotionMaxZ", PT_INT, 1, 255, SYNAPTICS_PROP_PRESSURE_MOTION, 32, 1}, {"PressureMotionMinFactor", PT_DOUBLE, 0, 10.0,SYNAPTICS_PROP_PRESSURE_MOTION_FACTOR, 0 /*float*/, 0}, {"PressureMotionMaxFactor", PT_DOUBLE, 0, 10.0,SYNAPTICS_PROP_PRESSURE_MOTION_FACTOR, 0 /*float*/, 1}, {"GrabEventDevice", PT_BOOL, 0, 1, SYNAPTICS_PROP_GRAB, 8, 0}, {"TapAndDragGesture", PT_BOOL, 0, 1, SYNAPTICS_PROP_GESTURES, 8, 0}, {"AreaLeftEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_AREA, 32, 0}, {"AreaRightEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_AREA, 32, 1}, {"AreaTopEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_AREA, 32, 2}, {"AreaBottomEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_AREA, 32, 3}, {"HorizHysteresis", PT_INT, 0, 10000, SYNAPTICS_PROP_NOISE_CANCELLATION, 32, 0}, {"VertHysteresis", PT_INT, 0, 10000, SYNAPTICS_PROP_NOISE_CANCELLATION, 32, 1}, {"ClickPad", PT_BOOL, 0, 1, SYNAPTICS_PROP_CLICKPAD, 8, 0}, {"RightButtonAreaLeft", PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 0}, {"RightButtonAreaRight", PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 1}, {"RightButtonAreaTop", PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 2}, {"RightButtonAreaBottom", PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 3}, {"MiddleButtonAreaLeft", PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 4}, {"MiddleButtonAreaRight", PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 5}, {"MiddleButtonAreaTop", PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 6}, {"MiddleButtonAreaBottom", PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 7}, - { NULL, PT_INT, 0, 0, 0, 0, 0 } + { NULL, PT_INT, 0, 0, nullptr, 0, 0 } }; SynapticsTouchpad::SynapticsTouchpad(Display *display, int deviceId): XlibTouchpad(display, deviceId), m_resX(1), m_resY(1) { m_capsAtom.intern(m_connection, SYNAPTICS_PROP_CAPABILITIES); m_touchpadOffAtom.intern(m_connection, SYNAPTICS_PROP_OFF); XcbAtom resolutionAtom(m_connection, SYNAPTICS_PROP_RESOLUTION); XcbAtom edgesAtom(m_connection, SYNAPTICS_PROP_EDGES); loadSupportedProperties(synapticsProperties); m_toRadians.append("CircScrollDelta"); PropertyInfo edges(m_display, m_deviceId, edgesAtom, 0); if (edges.i && edges.nitems == 4) { int w = qAbs(edges.i[1] - edges.i[0]); int h = qAbs(edges.i[3] - edges.i[2]); m_resX = w / 90; m_resY = h / 50; qDebug() << "Width: " << w << " height: " << h; qDebug() << "Approx. resX: " << m_resX << " resY: " << m_resY; } PropertyInfo resolution(m_display, m_deviceId, resolutionAtom, 0); if (resolution.i && resolution.nitems == 2 && resolution.i[0] > 1 && resolution.i[1] > 1) { m_resY = qMin(static_cast(resolution.i[0]), static_cast(INT_MAX)); m_resX = qMin(static_cast(resolution.i[1]), static_cast(INT_MAX)); qDebug() << "Touchpad resolution: x: " << m_resX << " y: " << m_resY; } m_scaleByResX.append("HorizScrollDelta"); m_scaleByResY.append("VertScrollDelta"); m_scaleByResX.append("MaxTapMove"); m_scaleByResY.append("MaxTapMove"); m_resX = qMax(10, m_resX); m_resY = qMax(10, m_resY); qDebug() << "Final resolution x:" << m_resX << " y:" << m_resY; m_negate["HorizScrollDelta"] = "InvertHorizScroll"; m_negate["VertScrollDelta"] = "InvertVertScroll"; m_supported.append(m_negate.values()); m_supported.append("Coasting"); PropertyInfo caps(m_display, m_deviceId, m_capsAtom.atom(), 0); if (!caps.b) { return; } enum TouchpadCapabilitiy { TouchpadHasLeftButton, TouchpadHasMiddleButton, TouchpadHasRightButton, TouchpadTwoFingerDetect, TouchpadThreeFingerDetect, TouchpadPressureDetect, TouchpadPalmDetect, TouchpadCapsCount }; QVector cap(TouchpadCapsCount, false); qCopy(caps.b, caps.b + qMin(cap.size(), static_cast(caps.nitems)), cap.begin()); if (!cap[TouchpadTwoFingerDetect]) { m_supported.removeAll("HorizTwoFingerScroll"); m_supported.removeAll("VertTwoFingerScroll"); m_supported.removeAll("TwoFingerTapButton"); } if (!cap[TouchpadThreeFingerDetect]) { m_supported.removeAll("ThreeFingerTapButton"); } if (!cap[TouchpadPressureDetect]) { m_supported.removeAll("FingerHigh"); m_supported.removeAll("FingerLow"); m_supported.removeAll("PalmMinZ"); m_supported.removeAll("PressureMotionMinZ"); m_supported.removeAll("PressureMotionMinFactor"); m_supported.removeAll("PressureMotionMaxZ"); m_supported.removeAll("PressureMotionMaxFactor"); m_supported.removeAll("EmulateTwoFingerMinZ"); } if (!cap[TouchpadPalmDetect]) { m_supported.removeAll("PalmDetect"); m_supported.removeAll("PalmMinWidth"); m_supported.removeAll("PalmMinZ"); m_supported.removeAll("EmulateTwoFingerMinW"); } for (QMap::Iterator i = m_negate.begin(); i != m_negate.end(); ++i) { if (!m_supported.contains(i.key())) { m_supported.removeAll(i.value()); } } m_paramList = synapticsProperties; } void SynapticsTouchpad::setTouchpadOff(int touchpadOff) { PropertyInfo off(m_display, m_deviceId, m_touchpadOffAtom.atom(), 0); if (off.b && *(off.b) != touchpadOff) { *(off.b) = touchpadOff; off.set(); } flush(); } int SynapticsTouchpad::touchpadOff() { PropertyInfo off(m_display, m_deviceId, m_touchpadOffAtom.atom(), 0); return off.value(0).toInt(); } XcbAtom &SynapticsTouchpad::touchpadOffAtom() { return m_touchpadOffAtom; } double SynapticsTouchpad::getPropertyScale(const QString &name) const { if (m_scaleByResX.contains(name) && m_scaleByResY.contains(name)) { return std::sqrt(static_cast(m_resX) * m_resX + static_cast(m_resY) * m_resY); } else if (m_scaleByResX.contains(name)) { return m_resX; } else if (m_scaleByResY.contains(name)) { return m_resY; } else if (m_toRadians.contains(name)) { return M_PI_4 / 45.0; } return 1.0; } diff --git a/kcms/touchpad/src/backends/x11/xlibbackend.cpp b/kcms/touchpad/src/backends/x11/xlibbackend.cpp index 03a2e693b..730335aa9 100644 --- a/kcms/touchpad/src/backends/x11/xlibbackend.cpp +++ b/kcms/touchpad/src/backends/x11/xlibbackend.cpp @@ -1,400 +1,400 @@ /* * Copyright (C) 2013 Alexander Mezin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #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" #include #include #include #include #include #include struct DeviceListDeleter { static void cleanup(XDeviceInfo *p) { if (p) { XFreeDeviceList(p); } } }; void XlibBackend::XDisplayCleanup::cleanup(Display *p) { if (p) { XCloseDisplay(p); } } XlibBackend* XlibBackend::initialize(QObject *parent) { XlibBackend* backend = new XlibBackend(parent); if (!backend->m_display) { delete backend; return nullptr; } return backend; } XlibBackend::~XlibBackend() { } XlibBackend::XlibBackend(QObject *parent) : TouchpadBackend(parent), - m_display(XOpenDisplay(0)), m_connection(0) + m_display(XOpenDisplay(nullptr)), m_connection(nullptr) { if (m_display) { m_connection = XGetXCBConnection(m_display.data()); } if (!m_connection) { m_errorString = i18n("Cannot connect to X server"); return; } m_mouseAtom.intern(m_connection, XI_MOUSE); m_keyboardAtom.intern(m_connection, XI_KEYBOARD); m_touchpadAtom.intern(m_connection, XI_TOUCHPAD); m_enabledAtom.intern(m_connection, XI_PROP_ENABLED); m_synapticsIdentifierAtom.intern(m_connection, SYNAPTICS_PROP_CAPABILITIES); m_libinputIdentifierAtom.intern(m_connection, "libinput Send Events Modes Available"); m_device.reset(findTouchpad()); if (!m_device) { m_errorString = i18n("No touchpad found"); } } XlibTouchpad* XlibBackend::findTouchpad() { int nDevices = 0; QScopedPointer deviceInfo(XListInputDevices(m_display.data(), &nDevices)); for (XDeviceInfo *info = deviceInfo.data(); info < deviceInfo.data() + nDevices; info++) { // Make sure device is touchpad if (info->type != m_touchpadAtom.atom()) { continue; } int nProperties = 0; QSharedPointer properties( XIListProperties(m_display.data(), info->id, &nProperties), XDeleter); 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); } #endif if (*atom == m_synapticsIdentifierAtom.atom()) { setMode(TouchpadInputBackendMode::XSynaptics); return new SynapticsTouchpad(m_display.data(), info->id); } } } return nullptr; } bool XlibBackend::applyConfig(const QVariantHash &p) { if (!m_device) { return false; } bool success = m_device->applyConfig(p); if (!success) { m_errorString = i18n("Cannot apply touchpad configuration"); } return success; } bool XlibBackend::applyConfig() { if (!m_device) { return false; } bool success = m_device->applyConfig(); if (!success) { m_errorString = i18n("Cannot apply touchpad configuration"); } return success; } bool XlibBackend::getConfig(QVariantHash &p) { if (!m_device) { return false; } bool success = m_device->getConfig(p); if (!success) { m_errorString = i18n("Cannot read touchpad configuration"); } return success; } bool XlibBackend::getConfig() { if(!m_device) { return false; } bool success = m_device->getConfig(); if (!success) { m_errorString = i18n("Cannot read touchpad configuration"); } return success; } bool XlibBackend::getDefaultConfig() { if (!m_device) { return false; } bool success = m_device->getDefaultConfig(); if (!success) { m_errorString = i18n("Cannot read default touchpad configuration"); } return success; } bool XlibBackend::isChangedConfig() const { if (!m_device) { return false; } return m_device->isChangedConfig(); } void XlibBackend::setTouchpadEnabled(bool enable) { if (!m_device) { return; } m_device->setEnabled(enable); // FIXME? This should not be needed, m_notifications should trigger // a propertyChanged signal when we enable/disable the touchpad, // that will emit touchpadStateChanged, but for some reason // XlibNotifications is not getting the property change events // so we just emit touchpadStateChanged from here as a workaround Q_EMIT touchpadStateChanged(); } void XlibBackend::setTouchpadOff(TouchpadBackend::TouchpadOffState state) { if (!m_device) { return; } int touchpadOff = 0; switch (state) { case TouchpadEnabled: touchpadOff = 0; break; case TouchpadFullyDisabled: touchpadOff = 1; break; case TouchpadTapAndScrollDisabled: touchpadOff = 2; break; default: qCritical() << "Unknown TouchpadOffState" << state; return; } m_device->setTouchpadOff(touchpadOff); } bool XlibBackend::isTouchpadAvailable() { return m_device; } bool XlibBackend::isTouchpadEnabled() { if (!m_device) { return false; } return m_device->enabled(); } TouchpadBackend::TouchpadOffState XlibBackend::getTouchpadOff() { if (!m_device) { return TouchpadFullyDisabled; } int value = m_device->touchpadOff(); switch (value) { case 0: return TouchpadEnabled; case 1: return TouchpadFullyDisabled; case 2: return TouchpadTapAndScrollDisabled; default: qCritical() << "Unknown TouchpadOff value" << value; return TouchpadFullyDisabled; } } void XlibBackend::touchpadDetached() { qWarning() << "Touchpad detached"; m_device.reset(); Q_EMIT touchpadReset(); } void XlibBackend::devicePlugged(int device) { if (!m_device) { m_device.reset(findTouchpad()); if (m_device) { qWarning() << "Touchpad reset"; m_notifications.reset(); watchForEvents(m_keyboard); Q_EMIT touchpadReset(); } } if (!m_device || device != m_device->deviceId()) { Q_EMIT mousesChanged(); } } void XlibBackend::propertyChanged(xcb_atom_t prop) { if ((m_device && prop == m_device->touchpadOffAtom().atom()) || prop == m_enabledAtom.atom()) { Q_EMIT touchpadStateChanged(); } } QStringList XlibBackend::listMouses(const QStringList &blacklist) { int nDevices = 0; QScopedPointer info(XListInputDevices(m_display.data(), &nDevices)); QStringList list; for (XDeviceInfo *i = info.data(); i != info.data() + nDevices; i++) { if (m_device && i->id == static_cast(m_device->deviceId())) { continue; } if (i->use != IsXExtensionPointer && i->use != IsXPointer) { continue; } //type = KEYBOARD && use = Pointer means usb receiver for both keyboard //and mouse if (i->type != m_mouseAtom.atom() && i->type != m_keyboardAtom.atom()) { continue; } QString name(i->name); if (blacklist.contains(name, Qt::CaseInsensitive)) { continue; } PropertyInfo enabled(m_display.data(), i->id, m_enabledAtom.atom(), 0); if (enabled.value(0) == false) { continue; } list.append(name); } return list; } QVector XlibBackend::getDevices() const { QVector touchpads; #if HAVE_XORGLIBINPUT LibinputTouchpad* libinputtouchpad = 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); } return touchpads; } void XlibBackend::watchForEvents(bool keyboard) { if (!m_notifications) { m_notifications.reset(new XlibNotifications(m_display.data(), m_device ? m_device->deviceId() : XIAllDevices)); connect(m_notifications.data(), SIGNAL(devicePlugged(int)), SLOT(devicePlugged(int))); connect(m_notifications.data(), SIGNAL(touchpadDetached()), SLOT(touchpadDetached())); connect(m_notifications.data(), SIGNAL(propertyChanged(xcb_atom_t)), SLOT(propertyChanged(xcb_atom_t))); } if (keyboard == !m_keyboard.isNull()) { return; } if (!keyboard) { m_keyboard.reset(); return; } m_keyboard.reset(new XRecordKeyboardMonitor(m_display.data())); connect(m_keyboard.data(), SIGNAL(keyboardActivityStarted()), SIGNAL(keyboardActivityStarted())); connect(m_keyboard.data(), SIGNAL(keyboardActivityFinished()), SIGNAL(keyboardActivityFinished())); } diff --git a/kcms/touchpad/src/backends/x11/xlibtouchpad.cpp b/kcms/touchpad/src/backends/x11/xlibtouchpad.cpp index 569e140fa..2a177de0c 100644 --- a/kcms/touchpad/src/backends/x11/xlibtouchpad.cpp +++ b/kcms/touchpad/src/backends/x11/xlibtouchpad.cpp @@ -1,262 +1,262 @@ #include #include "xlibtouchpad.h" #include #include #include #include static QVariant negateVariant(const QVariant &value) { if (value.type() == QVariant::Double) { return QVariant(-value.toDouble()); } else if (value.type() == QVariant::Int) { return QVariant(-value.toInt()); } return value; } XlibTouchpad::XlibTouchpad(Display *display, int deviceId) : m_display(display), m_connection(XGetXCBConnection(display)), m_deviceId(deviceId) { m_floatType.intern(m_connection, "FLOAT"); m_enabledAtom.intern(m_connection, XI_PROP_ENABLED); } bool XlibTouchpad::applyConfig(const QVariantHash& p) { m_props.clear(); bool error = false; Q_FOREACH(const QString &name, m_supported) { QVariantHash::ConstIterator i = p.find(name); if (i == p.end()) { continue; } const Parameter *par = findParameter(name); if (par) { QVariant value(i.value()); double k = getPropertyScale(name); if (k != 1.0) { bool ok = false; value = QVariant(value.toDouble(&ok) * k); if (!ok) { error = true; continue; } } if (m_negate.contains(name)) { QVariantHash::ConstIterator i = p.find(m_negate[name]); if (i != p.end() && i.value().toBool()) { value = negateVariant(value); } } if (name == "CoastingSpeed") { QVariantHash::ConstIterator coastingEnabled = p.find("Coasting"); if (coastingEnabled != p.end() && !coastingEnabled.value().toBool()) { value = QVariant(0); } } if (!setParameter(par, value)) { error = true; } } } flush(); return !error; } bool XlibTouchpad::getConfig(QVariantHash& p) { if (m_supported.isEmpty()) { return false; } m_props.clear(); bool error = false; Q_FOREACH(const QString &name, m_supported) { const Parameter *par = findParameter(name); if (!par) { continue; } QVariant value(getParameter(par)); if (!value.isValid()) { error = true; continue; } double k = getPropertyScale(name); if (k != 1.0) { bool ok = false; value = QVariant(value.toDouble(&ok) / k); if (!ok) { error = true; continue; } } if (m_negate.contains(name)) { bool negative = value.toDouble() < 0.0; p[m_negate[name]] = QVariant(negative); if (negative) { value = negateVariant(value); } } if (name == "CoastingSpeed") { bool coasting = value.toDouble() != 0.0; p["Coasting"] = QVariant(coasting); if (!coasting) { continue; } } p[name] = value; } return !error; } void XlibTouchpad::loadSupportedProperties(const Parameter* props) { m_paramList = props; for (const Parameter *param = props; param->name; param++) { QLatin1String name(param->prop_name); if (!m_atoms.contains(name)) { m_atoms.insert(name, QSharedPointer( new XcbAtom(m_connection, param->prop_name))); } } for (const Parameter *p = props; p->name; p++) { if (getParameter(p).isValid()) { m_supported.append(p->name); } } } QVariant XlibTouchpad::getParameter(const Parameter* par) { PropertyInfo *p = getDevProperty(QLatin1String(par->prop_name)); if (!p || par->prop_offset >= p->nitems) { return QVariant(); } return p->value(par->prop_offset); } void XlibTouchpad::flush() { Q_FOREACH(const QLatin1String &name, m_changed) { m_props[name].set(); } m_changed.clear(); XFlush(m_display); } double XlibTouchpad::getPropertyScale(const QString& name) const { Q_UNUSED(name); return 1.0; } PropertyInfo* XlibTouchpad::getDevProperty(const QLatin1String& propName) { if (m_props.contains(propName)) { return &m_props[propName]; } if (!m_atoms.contains(propName) || !m_atoms[propName]) { - return 0; + return nullptr; } xcb_atom_t prop = m_atoms[propName]->atom(); if (!prop) { - return 0; + return nullptr; } PropertyInfo p(m_display, m_deviceId, prop, m_floatType.atom()); if (!p.b && !p.f && !p.i) { - return 0; + return nullptr; } return &m_props.insert(propName, p).value(); } bool XlibTouchpad::setParameter(const Parameter *par, const QVariant &value) { QLatin1String propName(par->prop_name); PropertyInfo *p = getDevProperty(propName); if (!p || par->prop_offset >= p->nitems) { return false; } QVariant converted(value); QVariant::Type convType = QVariant::Int; if (p->f) { convType = QVariant::Double; } else if (value.type() == QVariant::Double) { converted = QVariant(qRound(static_cast(value.toDouble()))); } if (!converted.convert(convType)) { return false; } if (converted == p->value(par->prop_offset)) { return true; } if (p->b) { p->b[par->prop_offset] = static_cast(converted.toInt()); } else if (p->i) { p->i[par->prop_offset] = converted.toInt(); } else if (p->f) { p->f[par->prop_offset] = converted.toDouble(); } m_changed.insert(propName); return true; } void XlibTouchpad::setEnabled(bool enable) { PropertyInfo enabled(m_display, m_deviceId, m_enabledAtom.atom(), 0); if (enabled.b && *(enabled.b) != enable) { *(enabled.b) = enable; enabled.set(); } flush(); } bool XlibTouchpad::enabled() { PropertyInfo enabled(m_display, m_deviceId, m_enabledAtom.atom(), 0); return enabled.value(0).toBool(); } const Parameter* XlibTouchpad::findParameter(const QString& name) { for (const Parameter *par = m_paramList; par->name; par++) { if (name == par->name) { return par; } } - return 0; + return nullptr; } diff --git a/kcms/touchpad/src/backends/x11/xlibtouchpad.h b/kcms/touchpad/src/backends/x11/xlibtouchpad.h index 999c28092..45c41effb 100644 --- a/kcms/touchpad/src/backends/x11/xlibtouchpad.h +++ b/kcms/touchpad/src/backends/x11/xlibtouchpad.h @@ -1,92 +1,92 @@ /* * Copyright (C) 2015 Weng Xuetian * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef XLIBTOUCHPAD_H #define XLIBTOUCHPAD_H #include #include #include #include #include "xcbatom.h" #include "propertyinfo.h" enum ParaType { PT_INT, PT_BOOL, PT_DOUBLE }; struct Parameter { const char *name; /* Name of parameter */ enum ParaType type; /* Type of parameter */ double min_val; /* Minimum allowed value */ double max_val; /* Maximum allowed value */ const char *prop_name; /* Property name */ int prop_format; /* Property format (0 for floats) */ unsigned prop_offset; /* Offset inside property */ }; class XlibTouchpad { public: XlibTouchpad(Display *display, int deviceId); virtual ~XlibTouchpad() {} int deviceId() { return m_deviceId; } const QStringList &supportedParameters() const { return m_supported; } bool applyConfig(const QVariantHash &p); bool getConfig(QVariantHash &p); virtual bool getConfig() { return false; } virtual bool applyConfig() { return false; } virtual bool getDefaultConfig() { return false; } virtual bool isChangedConfig() { return false; } void setEnabled(bool enable); bool enabled(); - virtual void setTouchpadOff(int touchpadOff) {} + virtual void setTouchpadOff(int /*touchpadOff*/) {} virtual int touchpadOff() = 0; virtual XcbAtom &touchpadOffAtom() = 0; protected: void loadSupportedProperties(const Parameter *props); bool setParameter(const struct Parameter *, const QVariant &); QVariant getParameter(const struct Parameter *); struct PropertyInfo *getDevProperty(const QLatin1String &propName); void flush(); virtual double getPropertyScale(const QString &name) const; const Parameter * findParameter(const QString &name); Display *m_display; xcb_connection_t *m_connection; int m_deviceId; XcbAtom m_floatType, m_enabledAtom; QMap > m_atoms; QMap m_negate; QMap m_props; QSet m_changed; QStringList m_supported; const struct Parameter *m_paramList; }; #endif diff --git a/kcms/touchpad/src/kcm/libinput/touchpadconfiglibinput.cpp b/kcms/touchpad/src/kcm/libinput/touchpadconfiglibinput.cpp index b31a22a82..ab9afdcf6 100644 --- a/kcms/touchpad/src/kcm/libinput/touchpadconfiglibinput.cpp +++ b/kcms/touchpad/src/kcm/libinput/touchpadconfiglibinput.cpp @@ -1,220 +1,220 @@ /* * Copyright 2017 Roman Gilg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "touchpadconfiglibinput.h" #include #include #include #include #include #include #include #include #include #include #include "../touchpadconfigcontainer.h" #include "touchpadbackend.h" #include "version.h" -TouchpadConfigLibinput::TouchpadConfigLibinput(TouchpadConfigContainer *parent, TouchpadBackend* backend, const QVariantList &args) +TouchpadConfigLibinput::TouchpadConfigLibinput(TouchpadConfigContainer *parent, TouchpadBackend* backend, const QVariantList &/*args*/) : TouchpadConfigPlugin(parent, backend) { KAboutData* data = new KAboutData(QStringLiteral("kcm_touchpad"), i18n("Touchpad KCM"), TOUCHPAD_KCM_VERSION, i18n("System Settings module for managing your touchpad"), KAboutLicense::GPL_V2, i18n("Copyright © 2016 Roman Gilg"), QString()); data->addAuthor(i18n("Roman Gilg"), i18n("Developer"), QStringLiteral("subdiff@gmail.com")); m_parent->setAboutData(data); m_initError = !m_backend->errorString().isNull(); m_view = new QQuickWidget(this); m_errorMessage = new KMessageWidget(this); m_errorMessage->setCloseButtonVisible(false); m_errorMessage->setWordWrap(true); m_errorMessage->setVisible(false); QVBoxLayout *layout = new QVBoxLayout(parent); layout->addWidget(m_errorMessage); layout->addWidget(m_view); parent->setLayout(layout); m_view->setResizeMode(QQuickWidget::SizeRootObjectToView); m_view->setClearColor(Qt::transparent); m_view->setAttribute(Qt::WA_AlwaysStackOnTop); m_view->rootContext()->setContextProperty("backend", m_backend); m_view->rootContext()->setContextProperty("deviceModel", QVariant::fromValue(m_backend->getDevices().toList())); KDeclarative::KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(m_view->engine()); kdeclarative.setupBindings(); m_view->setSource(QUrl("qrc:/libinput/touchpad.qml")); if (m_initError) { m_errorMessage->setMessageType(KMessageWidget::Error); m_errorMessage->setText(m_backend->errorString()); QMetaObject::invokeMethod(m_errorMessage, "animatedShow", Qt::QueuedConnection); } else { connect(m_backend, SIGNAL(touchpadAdded(bool)), this, SLOT(onTouchpadAdded(bool))); connect(m_backend, SIGNAL(touchpadRemoved(int)), this, SLOT(onTouchpadRemoved(int))); connect(m_view->rootObject(), SIGNAL(changeSignal()), this, SLOT(onChange())); } m_view->show(); } QSize TouchpadConfigLibinput::sizeHint() const { return QQmlProperty::read(m_view->rootObject(), "sizeHint").toSize(); } QSize TouchpadConfigLibinput::minimumSizeHint() const { return QQmlProperty::read(m_view->rootObject(), "minimumSizeHint").toSize(); } void TouchpadConfigLibinput::load() { // in case of critical init error in backend, don't try if (m_initError) { return; } if (!m_backend->getConfig()) { m_errorMessage->setMessageType(KMessageWidget::Error); m_errorMessage->setText(i18n("Error while loading values. See logs for more information. Please restart this configuration module.")); m_errorMessage->animatedShow(); } else { if (!m_backend->touchpadCount()) { m_errorMessage->setMessageType(KMessageWidget::Information); m_errorMessage->setText(i18n("No touchpad found. Connect touchpad now.")); m_errorMessage->animatedShow(); } } QMetaObject::invokeMethod(m_view->rootObject(), "syncValuesFromBackend"); } void TouchpadConfigLibinput::save() { if (!m_backend->applyConfig()) { m_errorMessage->setMessageType(KMessageWidget::Error); m_errorMessage->setText(i18n("Not able to save all changes. See logs for more information. Please restart this configuration module and try again.")); m_errorMessage->animatedShow(); } else { hideErrorMessage(); } // load newly written values load(); // in case of error, config still in changed state emit m_parent->changed(m_backend->isChangedConfig()); } void TouchpadConfigLibinput::defaults() { // in case of critical init error in backend, don't try if (m_initError) { return; } if (!m_backend->getDefaultConfig()) { m_errorMessage->setMessageType(KMessageWidget::Error); m_errorMessage->setText(i18n("Error while loading default values. Failed to set some options to their default values.")); m_errorMessage->animatedShow(); } QMetaObject::invokeMethod(m_view->rootObject(), "syncValuesFromBackend"); emit m_parent->changed(m_backend->isChangedConfig()); } void TouchpadConfigLibinput::onChange() { if (!m_backend->touchpadCount()) { return; } hideErrorMessage(); emit m_parent->changed(m_backend->isChangedConfig()); } void TouchpadConfigLibinput::onTouchpadAdded(bool success) { QQuickItem *rootObj = m_view->rootObject(); if (!success) { m_errorMessage->setMessageType(KMessageWidget::Error); m_errorMessage->setText(i18n("Error while adding newly connected device. Please reconnect it and restart this configuration module.")); } int activeIndex; if (m_backend->touchpadCount() == 1) { // if no touchpad was connected previously, show the new device and hide the no-device-message activeIndex = 0; hideErrorMessage(); } else { activeIndex = QQmlProperty::read(rootObj, "deviceIndex").toInt(); } m_view->rootContext()->setContextProperty("deviceModel", QVariant::fromValue(m_backend->getDevices())); QMetaObject::invokeMethod(rootObj, "resetModel", Q_ARG(QVariant, activeIndex)); QMetaObject::invokeMethod(rootObj, "syncValuesFromBackend"); } void TouchpadConfigLibinput::onTouchpadRemoved(int index) { QQuickItem *rootObj = m_view->rootObject(); int activeIndex = QQmlProperty::read(rootObj, "deviceIndex").toInt(); if (activeIndex == index) { m_errorMessage->setMessageType(KMessageWidget::Information); if (m_backend->touchpadCount()) { m_errorMessage->setText(i18n("Touchpad disconnected. Closed its setting dialog.")); } else { m_errorMessage->setText(i18n("Touchpad disconnected. No other touchpads found.")); } m_errorMessage->animatedShow(); activeIndex = 0; } else { if (index < activeIndex) { activeIndex--; } } m_view->rootContext()->setContextProperty("deviceModel", QVariant::fromValue(m_backend->getDevices())); QMetaObject::invokeMethod(m_view->rootObject(), "resetModel", Q_ARG(QVariant, activeIndex)); QMetaObject::invokeMethod(rootObj, "syncValuesFromBackend"); emit m_parent->changed(m_backend->isChangedConfig()); } void TouchpadConfigLibinput::hideErrorMessage() { if (m_errorMessage->isVisible()) { m_errorMessage->animatedHide(); } } diff --git a/kcms/touchpad/src/kcm/touchpadconfigcontainer.cpp b/kcms/touchpad/src/kcm/touchpadconfigcontainer.cpp index 0eb4b55a5..a578e3be2 100644 --- a/kcms/touchpad/src/kcm/touchpadconfigcontainer.cpp +++ b/kcms/touchpad/src/kcm/touchpadconfigcontainer.cpp @@ -1,100 +1,100 @@ /* * Copyright 2017 Roman Gilg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "touchpadconfigcontainer.h" #include "touchpadconfigplugin.h" #include "kcm/libinput/touchpadconfiglibinput.h" #include "kcm/xlib/touchpadconfigxlib.h" #include "touchpadbackend.h" #include extern "C" { Q_DECL_EXPORT void kcminit_touchpad() { if (KWindowSystem::isPlatformX11()) { TouchpadConfigContainer::kcmInit(); } } } TouchpadConfigContainer::TouchpadConfigContainer(QWidget *parent, const QVariantList &args) : KCModule(parent, args) { TouchpadBackend *backend = TouchpadBackend::implementation(); if (KWindowSystem::isPlatformX11()) { if (backend->getMode() == TouchpadInputBackendMode::XLibinput) { m_plugin = new TouchpadConfigLibinput(this, backend); } // For now, if no touchpad is found, always fall back to synaptics frontend, // which has a "no touchpad found" message. // TODO: show a disabled version of the Libinput frontend as appropriate else { m_plugin = new TouchpadConfigXlib(this, backend); } } else if (KWindowSystem::isPlatformWayland()) { m_plugin = new TouchpadConfigLibinput(this, backend); } } void TouchpadConfigContainer::kcmInit() { TouchpadBackend *backend = TouchpadBackend::implementation(); if (backend->getMode() == TouchpadInputBackendMode::XLibinput) { backend->getConfig(); backend->applyConfig(); } else if (backend->getMode() == TouchpadInputBackendMode::XSynaptics) { TouchpadConfigXlib::kcmInit(); } } QSize TouchpadConfigContainer::minimumSizeHint() const { return m_plugin->minimumSizeHint(); } QSize TouchpadConfigContainer::sizeHint() const { return m_plugin->sizeHint(); } -void TouchpadConfigContainer::resizeEvent(QResizeEvent *event) +void TouchpadConfigContainer::resizeEvent(QResizeEvent */*event*/) { Q_EMIT changed(false); m_plugin->resize(this->size()); } void TouchpadConfigContainer::load() { m_plugin->load(); } void TouchpadConfigContainer::save() { m_plugin->save(); } void TouchpadConfigContainer::defaults() { m_plugin->defaults(); } void TouchpadConfigContainer::hideEvent(QHideEvent *e) { m_plugin->hideEvent(e); KCModule::hideEvent(e); } diff --git a/kcms/touchpad/src/kcm/xlib/touchpadconfigxlib.cpp b/kcms/touchpad/src/kcm/xlib/touchpadconfigxlib.cpp index e36f4a382..aec2c09fa 100644 --- a/kcms/touchpad/src/kcm/xlib/touchpadconfigxlib.cpp +++ b/kcms/touchpad/src/kcm/xlib/touchpadconfigxlib.cpp @@ -1,394 +1,394 @@ /* * Copyright (C) 2013 Alexander Mezin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "touchpadconfigxlib.h" #include #include #include #include #include #include #include #include #include #include #include "../touchpadconfigcontainer.h" #include "customslider.h" #include "sliderpair.h" #include "touchpadbackend.h" #include "plugins.h" #include "testarea.h" #include "touchpadinterface.h" #include "customconfigdialogmanager.h" #include "kded/kdedactions.h" #include "version.h" void touchpadApplySavedConfig() { TouchpadBackend *backend = TouchpadBackend::implementation(); if (!backend) { return; } TouchpadParameters config; backend->applyConfig(config.values()); } void TouchpadConfigXlib::kcmInit() { TouchpadParameters::setSystemDefaults(); touchpadApplySavedConfig(); } static void copyHelpFromBuddy(QObject *root) { QLabel *asLabel = qobject_cast(root); if (asLabel && asLabel->buddy()) { if (asLabel->toolTip().isEmpty()) { asLabel->setToolTip(asLabel->buddy()->toolTip()); } if (asLabel->statusTip().isEmpty()) { asLabel->setStatusTip(asLabel->buddy()->statusTip()); } if (asLabel->whatsThis().isEmpty()) { asLabel->setWhatsThis(asLabel->buddy()->whatsThis()); } } Q_FOREACH(QObject *child, root->children()) { copyHelpFromBuddy(child); } } template QWidget *addTab(QTabWidget *tabs, T &form) { QScrollArea *container = new QScrollArea(tabs); container->setWidgetResizable(true); container->setFrameStyle(QFrame::NoFrame); container->setAlignment(Qt::AlignHCenter | Qt::AlignTop); QWidget *widget = new QWidget(container); form.setupUi(widget); copyHelpFromBuddy(widget); widget->setContentsMargins(20, 20, 20, 20); widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); container->setWidget(widget); tabs->addTab(container, widget->windowTitle()); return widget; } -TouchpadConfigXlib::TouchpadConfigXlib(TouchpadConfigContainer *parent, TouchpadBackend* backend, const QVariantList &args) +TouchpadConfigXlib::TouchpadConfigXlib(TouchpadConfigContainer *parent, TouchpadBackend* backend, const QVariantList &/*args*/) : TouchpadConfigPlugin(parent, backend), m_configOutOfSync(false) { KAboutData* data = new KAboutData(QStringLiteral("kcm_touchpad"), i18n("Touchpad KCM"), TOUCHPAD_KCM_VERSION, i18n("System Settings module, daemon and Plasma applet for managing your touchpad"), KAboutLicense::GPL_V2, i18n("Copyright © 2013 Alexander Mezin"), i18n("This program incorporates work covered by this copyright notice:\n" "Copyright © 2002-2005,2007 Peter Osterlund"), QStringLiteral("https://projects.kde.org/projects/playground/utils/kcm-touchpad/"), QString()); data->addAuthor(i18n("Alexander Mezin"), i18n("Developer"), QStringLiteral("mezin.alexander@gmail.com")); data->addCredit(i18n("Thomas Pfeiffer"), i18nc("Credits", "Usability, testing")); data->addCredit(i18n("Alex Fiestas"), i18nc("Credits", "Helped a bit")); data->addCredit(i18n("Peter Osterlund"), i18nc("Credits", "Developer of synclient")); data->addCredit(i18n("Vadim Zaytsev"), i18nc("Credits", "Testing")); data->addCredit(i18n("Violetta Raspryagayeva"), i18nc("Credits", "Testing")); m_parent->setAboutData(data); QGridLayout *layout = new QGridLayout(this); QVBoxLayout *messageLayout = new QVBoxLayout(); layout->addLayout(messageLayout, 0, 0, 1, 2); // Messages m_errorMessage = new KMessageWidget(this); m_errorMessage->setMessageType(KMessageWidget::Error); m_errorMessage->setVisible(false); messageLayout->addWidget(m_errorMessage); m_configOutOfSyncMessage = new KMessageWidget(this); m_configOutOfSyncMessage->setMessageType(KMessageWidget::Warning); m_configOutOfSyncMessage->setText( i18n("Active settings don't match saved settings.\n" "You currently see saved settings.")); m_configOutOfSyncMessage->setVisible(false); messageLayout->addWidget(m_configOutOfSyncMessage); m_loadActiveConfiguration = new QAction(m_configOutOfSyncMessage); m_loadActiveConfiguration->setText(i18n("Show active settings")); connect(m_loadActiveConfiguration, SIGNAL(triggered()), SLOT(loadActiveConfig())); m_configOutOfSyncMessage->addAction(m_loadActiveConfiguration); layout->setColumnStretch(0, 3); layout->setColumnStretch(1, 1); // Main UI m_tabs = new QTabWidget(this); layout->addWidget(m_tabs, 1, 0, 1, 1); addTab(m_tabs, m_tapping); addTab(m_tabs, m_scrolling); addTab(m_tabs, m_pointerMotion); addTab(m_tabs, m_sensitivity); static const CustomSlider::SqrtInterpolator interpolator; m_pointerMotion.kcfg_MinSpeed->setInterpolator(&interpolator); m_pointerMotion.kcfg_MaxSpeed->setInterpolator(&interpolator); m_pointerMotion.kcfg_AccelFactor->setInterpolator(&interpolator); new SliderPair(m_pointerMotion.kcfg_MinSpeed, m_pointerMotion.kcfg_MaxSpeed, this); new SliderPair(m_sensitivity.kcfg_FingerLow, m_sensitivity.kcfg_FingerHigh, this); new SliderPair(m_pointerMotion.kcfg_PressureMotionMinZ, m_pointerMotion.kcfg_PressureMotionMaxZ, this); KConfigDialogManager::changedMap()->insert("CustomSlider", SIGNAL(valueChanged(double))); m_manager = new CustomConfigDialogManager(this, &m_config, m_backend->supportedParameters()); connect(m_manager, SIGNAL(widgetModified()), SLOT(checkChanges()), Qt::QueuedConnection); // KDED settings m_kdedTab = addTab(m_tabs, m_kded); m_daemonConfigManager = m_parent->addConfig(&m_daemonSettings, m_kdedTab); KMessageWidget *kdedMessage = new KMessageWidget(m_kdedTab); kdedMessage->setMessageType(KMessageWidget::Information); kdedMessage->setCloseButtonVisible(false); kdedMessage->setText( i18n("These settings won't take effect in the testing area")); qobject_cast(m_kdedTab->layout())-> insertWidget(0, kdedMessage); connect(m_kded.configureNotificationsButton, SIGNAL(clicked()), SLOT(showConfigureNotificationsDialog())); m_shortcutsDialog.reset(new KShortcutsDialog(KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed)); m_shortcutsDialog->addCollection(new TouchpadGlobalActions(true, this), i18n("Enable/Disable Touchpad")); connect(m_kded.configureShortcutsButton, SIGNAL(clicked()), m_shortcutsDialog.data(), SLOT(show())); m_mouseCombo = new KComboBox(true, m_kded.kcfg_MouseBlacklist); m_kded.kcfg_MouseBlacklist->setCustomEditor(m_mouseCombo); connect(m_backend, SIGNAL(mousesChanged()), SLOT(updateMouseList())); m_backend->watchForEvents(false); updateMouseList(); m_daemon = new OrgKdeTouchpadInterface("org.kde.kded5", "/modules/touchpad", QDBusConnection::sessionBus(), this); m_kdedTab->setEnabled(false); QDBusPendingCallWatcher *watch; watch = new QDBusPendingCallWatcher(m_daemon->workingTouchpadFound(), this); connect(watch, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(gotReplyFromDaemon(QDBusPendingCallWatcher*))); // Testing area m_testArea = new TestArea(this); layout->addWidget(m_testArea, 1, 1); connect(m_testArea, SIGNAL(enter()), SLOT(beginTesting())); connect(m_testArea, SIGNAL(leave()), SLOT(endTesting())); connect(m_tabs, SIGNAL(currentChanged(int)), SLOT(updateTestAreaEnabled())); updateTestAreaEnabled(); } void TouchpadConfigXlib::gotReplyFromDaemon(QDBusPendingCallWatcher *watch) { QDBusPendingReply reply = *watch; if (reply.isValid() && reply.value()) { m_kdedTab->setEnabled(true); } watch->deleteLater(); } void TouchpadConfigXlib::updateMouseList() { QStringList mouses( m_backend->listMouses(m_daemonSettings.mouseBlacklist())); for (int i = 0; i < m_mouseCombo->count(); ) { if (!mouses.contains(m_mouseCombo->itemText(i))) { m_mouseCombo->removeItem(i); } else { i++; } } Q_FOREACH (const QString &i, mouses) { if (!m_mouseCombo->contains(i)) { m_mouseCombo->addItem(i); } } } QVariantHash TouchpadConfigXlib::getActiveConfig() { if (m_prevConfig) { return *m_prevConfig; } QVariantHash activeConfig; if (!m_backend->getConfig(activeConfig)) { m_errorMessage->setText(m_backend->errorString()); QMetaObject::invokeMethod(m_errorMessage, "animatedShow", Qt::QueuedConnection); } return activeConfig; } void TouchpadConfigXlib::loadActiveConfig() { m_manager->setWidgetProperties(getActiveConfig()); m_configOutOfSync = false; m_configOutOfSyncMessage->animatedHide(); } void TouchpadConfigXlib::load() { m_manager->updateWidgets(); m_parent->kcmLoad(); m_configOutOfSync = !m_manager->compareWidgetProperties(getActiveConfig()); } void TouchpadConfigXlib::save() { m_manager->updateSettings(); m_configOutOfSync = false; m_configOutOfSyncMessage->animatedHide(); bool daemonSettingsChanged = m_daemonConfigManager->hasChanged(); m_parent->kcmSave(); if (m_backend->applyConfig(m_config.values())) { m_errorMessage->animatedHide(); } else { m_errorMessage->setText(m_backend->errorString()); m_errorMessage->animatedShow(); } if (daemonSettingsChanged) { m_daemon->reloadSettings(); updateMouseList(); } } void TouchpadConfigXlib::defaults() { m_manager->updateWidgetsDefault(); m_parent->kcmDefaults(); } void TouchpadConfigXlib::checkChanges() { if (!m_backend->touchpadCount()) { return; } m_parent->unmanagedWidgetChangeState(m_manager->hasChangedFuzzy() || m_configOutOfSync); if (m_configOutOfSync) { m_configOutOfSyncMessage->animatedShow(); } else { m_configOutOfSyncMessage->animatedHide(); } } void TouchpadConfigXlib::hideEvent(QHideEvent *e) { Q_UNUSED( e ); endTesting(); } TouchpadConfigXlib::~TouchpadConfigXlib() { endTesting(); } void TouchpadConfigXlib::onChanged() { if (m_testArea->underMouse()) { beginTesting(); } } void TouchpadConfigXlib::beginTesting() { if (!m_prevConfig) { m_prevConfig.reset(new QVariantHash()); m_backend->getConfig(*m_prevConfig.data()); } m_backend->applyConfig(m_manager->currentWidgetProperties()); } void TouchpadConfigXlib::endTesting() { if (!m_prevConfig) { return; } m_backend->applyConfig(*m_prevConfig.data()); m_prevConfig.reset(); } void TouchpadConfigXlib::updateTestAreaEnabled() { bool enable = true; for (QWidget *i = m_kdedTab; i; i = i->parentWidget()) { if (i == m_tabs->currentWidget()) { enable = false; break; } } m_testArea->setEnabled(enable); m_testArea->setMouseTracking(enable); if (!enable) { endTesting(); } } void TouchpadConfigXlib::showConfigureNotificationsDialog() { KNotifyConfigWidget *widget = - KNotifyConfigWidget::configure(0, m_parent->componentData().componentName()); + KNotifyConfigWidget::configure(nullptr, m_parent->componentData().componentName()); QDialog *dialog = qobject_cast(widget->topLevelWidget()); connect(dialog, SIGNAL(finished()), dialog, SLOT(deleteLater())); } diff --git a/kcms/touchpad/src/kded/kded.cpp b/kcms/touchpad/src/kded/kded.cpp index 90fc5eee5..3d04c162a 100644 --- a/kcms/touchpad/src/kded/kded.cpp +++ b/kcms/touchpad/src/kded/kded.cpp @@ -1,307 +1,307 @@ /* * Copyright (C) 2013 Alexander Mezin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kded.h" #include #include #include #include #include #include #include "plugins.h" #include "kdedactions.h" bool TouchpadDisabler::workingTouchpadFound() const { return m_workingTouchpadFound; } void TouchpadDisabler::serviceRegistered(const QString &service) { if (!m_dependencies.removeWatchedService(service)) { return; } if (m_dependencies.watchedServices().isEmpty()) { lateInit(); } } TouchpadDisabler::TouchpadDisabler(QObject *parent, const QVariantList &) : KDEDModule(parent), m_backend(TouchpadBackend::implementation()), m_userRequestedState(true), m_touchpadEnabled(true), m_workingTouchpadFound(false), m_keyboardActivity(false), m_mouse(false) { if (!m_backend) { return; } m_dependencies.addWatchedService("org.kde.plasmashell"); m_dependencies.addWatchedService("org.kde.kglobalaccel"); connect(&m_dependencies, SIGNAL(serviceRegistered(QString)), SLOT(serviceRegistered(QString))); connect(m_backend, SIGNAL(mousesChanged()), SLOT(mousePlugged())); connect(m_backend, SIGNAL(keyboardActivityStarted()), SLOT(keyboardActivityStarted())); connect(m_backend, SIGNAL(keyboardActivityFinished()), SLOT(keyboardActivityFinished())); connect(m_backend, SIGNAL(touchpadStateChanged()), SLOT(updateCurrentState())); connect(m_backend, SIGNAL(touchpadReset()), SLOT(handleReset())); m_keyboardActivityTimeout.setSingleShot(true); connect(&m_keyboardActivityTimeout, SIGNAL(timeout()), SLOT(timerElapsed())); updateCurrentState(); m_userRequestedState = m_touchpadEnabled; reloadSettings(); m_dependencies.setWatchMode(QDBusServiceWatcher::WatchForRegistration); m_dependencies.setConnection(QDBusConnection::sessionBus()); QDBusPendingCall async = QDBusConnection::sessionBus().interface()->asyncCall(QLatin1String("ListNames")); QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(async, this); connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(serviceNameFetchFinished(QDBusPendingCallWatcher*))); QDBusConnection::systemBus().connect(QStringLiteral("org.freedesktop.login1"), QStringLiteral("/org/freedesktop/login1"), QStringLiteral("org.freedesktop.login1.Manager"), QStringLiteral("PrepareForSleep"), this, SLOT(onPrepareForSleep(bool))); } void TouchpadDisabler::serviceNameFetchFinished(QDBusPendingCallWatcher *callWatcher) { QDBusPendingReply reply = *callWatcher; callWatcher->deleteLater(); if (reply.isError() || reply.value().isEmpty()) { qWarning() << "Error: Couldn't get registered services list from session bus"; return; } QStringList allServices = reply.value(); Q_FOREACH (const QString &service, m_dependencies.watchedServices()) { if (allServices.contains(service)) { serviceRegistered(service); } } } bool TouchpadDisabler::isEnabled() const { return m_touchpadEnabled; } void TouchpadDisabler::updateCurrentState() { updateWorkingTouchpadFound(); if (!m_backend->isTouchpadAvailable()) { return; } bool newEnabled = m_backend->isTouchpadEnabled(); if (newEnabled != m_touchpadEnabled) { m_touchpadEnabled = newEnabled; Q_EMIT enabledChanged(m_touchpadEnabled); } } void TouchpadDisabler::toggle() { m_userRequestedState = !m_touchpadEnabled; m_backend->setTouchpadEnabled(m_userRequestedState); } void TouchpadDisabler::disable() { m_userRequestedState = false; m_backend->setTouchpadEnabled(false); } void TouchpadDisabler::enable() { m_userRequestedState = true; m_backend->setTouchpadEnabled(true); } void TouchpadDisabler::reloadSettings() { m_settings.load(); m_keyboardActivityTimeout.setInterval( m_settings.keyboardActivityTimeoutMs()); m_keyboardDisableState = m_settings.onlyDisableTapAndScrollOnKeyboardActivity() ? TouchpadBackend::TouchpadTapAndScrollDisabled : TouchpadBackend::TouchpadFullyDisabled; mousePlugged(); m_backend->watchForEvents(m_settings.disableOnKeyboardActivity()); } void TouchpadDisabler::keyboardActivityStarted() { if (m_keyboardActivity || !m_settings.disableOnKeyboardActivity()) { return; } m_keyboardActivityTimeout.stop(); m_keyboardActivity = true; m_backend->setTouchpadOff(m_keyboardDisableState); } void TouchpadDisabler::keyboardActivityFinished() { if (!m_keyboardActivity) { keyboardActivityStarted(); } m_keyboardActivityTimeout.start(); } void TouchpadDisabler::timerElapsed() { if (!m_keyboardActivity) { return; } m_keyboardActivity = false; m_backend->setTouchpadOff(TouchpadBackend::TouchpadEnabled); } void TouchpadDisabler::mousePlugged() { if (!m_dependencies.watchedServices().isEmpty()) { return; } bool pluggedIn = isMousePluggedIn(); Q_EMIT mousePluggedInChanged(pluggedIn); bool disable = pluggedIn && m_settings.disableWhenMousePluggedIn(); if (m_mouse == disable) { return; } m_mouse = disable; bool newState = disable ? false : m_userRequestedState; if (newState == m_touchpadEnabled) { return; } // If the disable is caused by plugin mouse, show the message, otherwise it might // be user already disables touchpad themselves. if (!newState && disable) { showNotification("TouchpadDisabled", i18n("Touchpad was disabled because a mouse was plugged in")); } if (newState) { showNotification("TouchpadEnabled", i18n("Touchpad was enabled because the mouse was unplugged")); } m_backend->setTouchpadEnabled(newState); } void TouchpadDisabler::showNotification(const QString &name, const QString &text) { if (m_notification) { m_notification->close(); } m_notification = KNotification::event(name, text, QPixmap(), //Icon is specified in .notifyrc - 0, + nullptr, KNotification::CloseOnTimeout, "kcm_touchpad"); // this has to match the name of the .notifyrc file //TouchpadPluginFactory::componentData()); } bool TouchpadDisabler::isMousePluggedIn() const { return !m_backend->listMouses(m_settings.mouseBlacklist()).isEmpty(); } void TouchpadDisabler::lateInit() { TouchpadGlobalActions *actions = new TouchpadGlobalActions(false, this); connect(actions, &TouchpadGlobalActions::enableTriggered, this, [this] { enable(); showOsd(); }); connect(actions, &TouchpadGlobalActions::disableTriggered, this, [this] { disable(); showOsd(); }); connect(actions, &TouchpadGlobalActions::toggleTriggered, this, [this] { toggle(); showOsd(); }); updateCurrentState(); mousePlugged(); } void touchpadApplySavedConfig(); void TouchpadDisabler::handleReset() { updateCurrentState(); if (!m_workingTouchpadFound) { return; } touchpadApplySavedConfig(); m_backend->setTouchpadEnabled(m_userRequestedState); } void TouchpadDisabler::updateWorkingTouchpadFound() { bool newWorkingTouchpadFound = m_backend && m_backend->isTouchpadAvailable(); if (newWorkingTouchpadFound != m_workingTouchpadFound) { m_workingTouchpadFound = newWorkingTouchpadFound; Q_EMIT workingTouchpadFoundChanged(m_workingTouchpadFound); } } void TouchpadDisabler::onPrepareForSleep(bool sleep) { m_preparingForSleep = sleep; } void TouchpadDisabler::showOsd() { if (m_preparingForSleep) { return; } QDBusMessage msg = QDBusMessage::createMethodCall( QStringLiteral("org.kde.plasmashell"), QStringLiteral("/org/kde/osdService"), QStringLiteral("org.kde.osdService"), QStringLiteral("touchpadEnabledChanged") ); msg.setArguments({m_backend->isTouchpadEnabled()}); QDBusConnection::sessionBus().asyncCall(msg); } diff --git a/kcms/touchpad/src/touchpadbackend.h b/kcms/touchpad/src/touchpadbackend.h index 6ed077c4b..338779df3 100644 --- a/kcms/touchpad/src/touchpadbackend.h +++ b/kcms/touchpad/src/touchpadbackend.h @@ -1,89 +1,89 @@ /* * Copyright 2017 Roman Gilg * Copyright 2013 Alexander Mezin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef TOUCHPADBACKEND_H #define TOUCHPADBACKEND_H #include #include #include enum class TouchpadInputBackendMode { Unset = 0, WaylandLibinput = 1, XLibinput = 2, XSynaptics = 3 }; class Q_DECL_EXPORT TouchpadBackend : public QObject { Q_OBJECT protected: explicit TouchpadBackend(QObject *parent) : QObject(parent), m_mode(TouchpadInputBackendMode::Unset) {} void setMode(TouchpadInputBackendMode mode); public: static TouchpadBackend *implementation(); TouchpadInputBackendMode getMode() const {return m_mode;} virtual bool applyConfig(const QVariantHash &) {return false;} virtual bool getConfig(QVariantHash &) {return false;} virtual bool applyConfig() {return false;} virtual bool getConfig() {return false;} virtual bool getDefaultConfig() {return false;} virtual bool isChangedConfig() const {return false;} virtual QStringList supportedParameters() const {return QStringList();} virtual QString errorString() const {return QString();} virtual QVector getDevices() const { return QVector(); } virtual int touchpadCount() const {return 0;} enum TouchpadOffState { TouchpadEnabled, TouchpadTapAndScrollDisabled, TouchpadFullyDisabled }; virtual void setTouchpadOff(TouchpadOffState) {} virtual TouchpadOffState getTouchpadOff() {return TouchpadFullyDisabled;} virtual bool isTouchpadAvailable() {return false;} virtual bool isTouchpadEnabled() {return false;} virtual void setTouchpadEnabled(bool) {} - virtual void watchForEvents(bool keyboard) {} + virtual void watchForEvents(bool /*keyboard*/) {} - virtual QStringList listMouses(const QStringList &blacklist) {return QStringList();} + virtual QStringList listMouses(const QStringList &/*blacklist*/) {return QStringList();} private: TouchpadInputBackendMode m_mode; Q_SIGNALS: void touchpadStateChanged(); void mousesChanged(); void touchpadReset(); void keyboardActivityStarted(); void keyboardActivityFinished(); void touchpadAdded(bool success); void touchpadRemoved(int index); }; #endif // TOUCHPADBACKEND_H