diff --git a/kcms/touchpad/src/backends/x11/synapticstouchpad.cpp b/kcms/touchpad/src/backends/x11/synapticstouchpad.cpp index 1e01894da..d4742bf78 100644 --- a/kcms/touchpad/src/backends/x11/synapticstouchpad.cpp +++ b/kcms/touchpad/src/backends/x11/synapticstouchpad.cpp @@ -1,235 +1,250 @@ /* * 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 "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 } }; 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; } + +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/synapticstouchpad.h b/kcms/touchpad/src/backends/x11/synapticstouchpad.h index de7512551..95b56755d 100644 --- a/kcms/touchpad/src/backends/x11/synapticstouchpad.h +++ b/kcms/touchpad/src/backends/x11/synapticstouchpad.h @@ -1,37 +1,39 @@ /* * 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 SYNAPTICSTOUCHPAD_H #define SYNAPTICSTOUCHPAD_H #include "xlibtouchpad.h" #include "xcbatom.h" class SynapticsTouchpad : public XlibTouchpad { public: SynapticsTouchpad(Display *display, int deviceId); +protected: + double getPropertyScale(const QString &name) const Q_DECL_OVERRIDE; + private: XcbAtom m_capsAtom; int m_resX, m_resY; - QMap m_negate; QStringList m_scaleByResX, m_scaleByResY, m_toRadians; }; #endif // SYNAPTICSTOUCHPAD_H diff --git a/kcms/touchpad/src/backends/x11/xlibtouchpad.cpp b/kcms/touchpad/src/backends/x11/xlibtouchpad.cpp index 441bcadef..53eb24915 100644 --- a/kcms/touchpad/src/backends/x11/xlibtouchpad.cpp +++ b/kcms/touchpad/src/backends/x11/xlibtouchpad.cpp @@ -1,294 +1,285 @@ #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 { - 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; - } + 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; } xcb_atom_t prop = m_atoms[propName]->atom(); if (!prop) { return 0; } PropertyInfo p(m_display, m_deviceId, prop, m_floatType.atom()); if (!p.b && !p.f && !p.i) { return 0; } 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(); } void XlibTouchpad::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 XlibTouchpad::touchpadOff() { PropertyInfo off(m_display, m_deviceId, m_touchpadOffAtom.atom(), 0); return off.value(0).toInt(); } XcbAtom& XlibTouchpad::touchpadOffAtom() { return m_touchpadOffAtom; } const Parameter* XlibTouchpad::findParameter(const QString& name) { for (const Parameter *par = m_paramList; par->name; par++) { if (name == par->name) { return par; } } return 0; } diff --git a/kcms/touchpad/src/backends/x11/xlibtouchpad.h b/kcms/touchpad/src/backends/x11/xlibtouchpad.h index 0eb58fb39..6e72f217b 100644 --- a/kcms/touchpad/src/backends/x11/xlibtouchpad.h +++ b/kcms/touchpad/src/backends/x11/xlibtouchpad.h @@ -1,88 +1,86 @@ /* * 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 "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); void setEnabled(bool enable); bool enabled(); void setTouchpadOff(int touchpadOff); int touchpadOff(); XcbAtom &touchpadOffAtom(); 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(); - double getPropertyScale(const QString &name) const; + 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, m_touchpadOffAtom; QMap > m_atoms; - int m_resX, m_resY; - QStringList m_scaleByResX, m_scaleByResY, m_toRadians; 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/touchpad.kcfg b/kcms/touchpad/src/kcm/touchpad.kcfg index d4d127cbc..e750bc295 100644 --- a/kcms/touchpad/src/kcm/touchpad.kcfg +++ b/kcms/touchpad/src/kcm/touchpad.kcfg @@ -1,317 +1,317 @@ systemDefault("Tapping", true) OneFingerTap TwoFingerTap ThreeFingerTap LTCorner LBCorner RTCorner RBCorner systemDefaultEnum("OneFingerTapButton", LeftButton) systemDefaultEnum("TwoFingerTapButton", RightButton) systemDefaultEnum("ThreeFingerTapButton", MiddleButton) systemDefaultEnum("LTCornerButton", NoButton) systemDefaultEnum("LBCornerButton", NoButton) systemDefaultEnum("RTCornerButton", NoButton) systemDefaultEnum("RBCornerButton", NoButton) systemDefault("VertEdgeScroll", true) systemDefault("VertTwoFingerScroll", true) systemDefault("HorizEdgeScroll", true) systemDefault("HorizTwoFingerScroll", true) 0 255 systemDefault("MinSpeed", 0.0) 0 255 systemDefault("MaxSpeed", 255.0) 0 1 systemDefault("AccelFactor", 0.0) 0 100 systemDefault("HorizHysteresis", 0) 0 100 systemDefault("VertHysteresis", 0) systemDefault("TapAndDragGesture", true) systemDefault("LockedDrags", false) 0 30000 systemDefault("LockedDragTimeout", 5000) 0 - 10 + 1000 systemDefault("VertScrollDelta", 1.0) systemDefault("InvertVertScroll", false) 0 - 10 + 1000 systemDefault("HorizScrollDelta", 1.0) systemDefault("InvertHorizScroll", false) systemDefault("CornerCoasting", false) 0.1 255 systemDefault("CoastingSpeed", 20.0) 0 255 systemDefault("CoastingFriction", 50.0) systemDefault("Coasting", true) 0 255 systemDefault("FingerHigh", 30) 0 255 systemDefault("FingerLow", 25) systemDefault("PalmDetect", false) 0 255 systemDefault("PalmMinZ", 200) 0 15 systemDefault("PalmMinWidth", 10) 0 1000 systemDefault("MaxTapTime", 180) 0 1000 systemDefault("MaxDoubleTapTime", 180) 0 1000 systemDefault("SingleTapTimeout", 180) 0 - 20 + 1000 systemDefault("MaxTapMove", 2.0) 1 255 systemDefault("PressureMotionMinZ", 30) 1 255 systemDefault("PressureMotionMaxZ", 160) 0 10 systemDefault("PressureMotionMinFactor", 1.0) 0 10 systemDefault("PressureMotionMaxFactor", 1.0) systemDefault("CircularScrolling", false) systemDefault("CircScrollDelta", 10.0) 0 45 systemDefaultEnum("CircScrollTrigger", AllEdges) diff --git a/kcms/touchpad/src/kcm/ui/scroll.ui b/kcms/touchpad/src/kcm/ui/scroll.ui index d1c2f7638..e73b54dc5 100644 --- a/kcms/touchpad/src/kcm/ui/scroll.ui +++ b/kcms/touchpad/src/kcm/ui/scroll.ui @@ -1,381 +1,393 @@ ScrollForm 0 0 610 503 Scrolling QFormLayout::FieldsStayAtSizeHint Qt::AlignHCenter|Qt::AlignTop Edge scrolling: kcfg_VertEdgeScroll Enable vertical scrolling when dragging along the right edge Vertical Enable horizontal scrolling when dragging along the bottom edge Horizontal Enable vertical scrolling when dragging with two fingers anywhere on the touchpad Vertical Enable horizontal scrolling when dragging with two fingers anywhere on the touchpad Horizontal Reverse vertical scrolling Vertical Reverse horizontal scrolling Horizontal Two-finger scrolling: kcfg_VertTwoFingerScroll Reverse scrolling: kcfg_InvertVertScroll 300 0 Scrolling Distance true QFormLayout::AllNonFixedFieldsGrow Vertical: kcfg_VertScrollDelta Move distance of the finger for a scroll event + + 1000.000000000000000 + 0.100000000000000 mm 1 Horizontal: kcfg_HorizScrollDelta Move distance of the finger for a scroll event + + 1000.000000000000000 + 0.100000000000000 mm 1 Continue scrolling after the finger is released from the edge of the touchpad Coasting true true QFormLayout::AllNonFixedFieldsGrow Minimum speed: kcfg_CoastingSpeed Your finger needs to produce this many scrolls per second in order to start coasting 1.000000000000000 scrolls/sec Deceleration: kcfg_CoastingFriction Number of scrolls/second² to decrease the coasting speed 1.000000000000000 scrolls/sec² Corner coasting: kcfg_CornerCoasting Enable edge scrolling to continue while the finger stays in an edge corner Enable Scrolling is engaged when a drag starts in the given trigger region. Moving your finger in clockwise circles around the center of the touchpad will scroll down and counter clockwise motion will scroll up Circular Scrolling true true QFormLayout::ExpandingFieldsGrow Trigger region: kcfg_CircScrollTrigger Trigger region on the touchpad to start circular scrolling Angle: kcfg_CircScrollDelta - + 0 0 + + 45.000000000000000 + + + 0.100000000000000 + Move angle (radians) of finger to generate a scroll event ° When used together with vertical scrolling, hitting the upper or lower right corner will seamlessly switch over from vertical to circular scrolling true KComboBox QComboBox
kcombobox.h
kcfg_VertEdgeScroll kcfg_HorizEdgeScroll kcfg_VertTwoFingerScroll kcfg_HorizTwoFingerScroll kcfg_InvertVertScroll kcfg_InvertHorizScroll kcfg_VertScrollDelta kcfg_HorizScrollDelta kcfg_Coasting kcfg_CoastingSpeed kcfg_CoastingFriction kcfg_CornerCoasting kcfg_CircularScrolling kcfg_CircScrollTrigger kcfg_CircScrollDelta
diff --git a/kcms/touchpad/src/kcm/ui/tap.ui b/kcms/touchpad/src/kcm/ui/tap.ui index 389db5e2a..cfe553465 100644 --- a/kcms/touchpad/src/kcm/ui/tap.ui +++ b/kcms/touchpad/src/kcm/ui/tap.ui @@ -1,497 +1,500 @@ TapForm 0 0 516 531 Taps 0 0 Mouse Click Emulation true true Qt::AlignHCenter|Qt::AlignTop One finger: kcfg_OneFingerTapButton Which mouse button is reported on a non-corner one-finger tap Two fingers: kcfg_TwoFingerTapButton Which mouse button is reported on a non-corner two-finger tap Three fingers: kcfg_ThreeFingerTapButton Which mouse button is reported on a non-corner three-finger tap 0 0 Corners true 0 0 QFrame::StyledPanel QFrame::Raised Top left: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter kcfg_LTCornerButton Which mouse button is reported on a left top corner tap Bottom left: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter kcfg_LBCornerButton Top right: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter kcfg_RTCornerButton Which mouse button is reported on a left bottom corner tap Which mouse button is reported on a right top corner tap Which mouse button is reported on a right bottom corner tap Qt::Horizontal QSizePolicy::Expanding 30 20 Bottom right: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter kcfg_RBCornerButton Qt::Vertical QSizePolicy::Fixed 20 20 This gesture is an alternative way of dragging. It is performed by tapping (touching and releasing the finger), then touching again and moving the finger on the touchpad Tap-and-Drag Gesture true true If off, a tap-and-drag gesture ends when you release the finger. If on, the gesture is active until you tap a second time, or until timeout expires Locked Drags false true QFormLayout::AllNonFixedFieldsGrow Timeout: kcfg_LockedDragTimeout How long it takes (in milliseconds) for the "Locked Drags" mode to be automatically turned off after the finger is released from the touchpad 0 99 99 ms 300 0 Tap Detection true QFormLayout::AllNonFixedFieldsGrow Maximum time: kcfg_MaxTapTime Maximum finger movement: kcfg_MaxTapMove Maximum time for double tap: kcfg_MaxDoubleTapTime Single tap timeout: kcfg_SingleTapTimeout Maximum time (in milliseconds) for detecting a tap 0 99 10 ms Maximum movement of the finger for detecting a tap + + 1000.000000000000000 + 0.100000000000000 mm 1 Maximum time (in milliseconds) for detecting a double tap 0 99 10 ms Timeout after a tap to recognize it as a single tap 0 99 10 ms QSpinBox QWidget KComboBox QComboBox
kcombobox.h
QSpinBox QWidget
kcfg_OneFingerTapButton kcfg_TwoFingerTapButton kcfg_ThreeFingerTapButton kcfg_LTCornerButton kcfg_RTCornerButton kcfg_LBCornerButton kcfg_RBCornerButton kcfg_TapAndDragGesture kcfg_LockedDrags kcfg_LockedDragTimeout kcfg_MaxTapTime kcfg_MaxTapMove kcfg_MaxDoubleTapTime kcfg_SingleTapTimeout