Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpad/src/backends/kwin_wayland/kwinwaylandtouchpad.cpp
Show All 15 Lines | |||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "kwinwaylandtouchpad.h" | 19 | #include "kwinwaylandtouchpad.h" | ||
20 | 20 | | |||
21 | #include <QDBusInterface> | 21 | #include <QDBusInterface> | ||
22 | #include <QDBusError> | 22 | #include <QDBusError> | ||
23 | #include <QVector> | 23 | #include <QVector> | ||
24 | #include <backends/libinputcommon.h> | ||||
24 | 25 | | |||
25 | #include "logging.h" | 26 | #include "logging.h" | ||
26 | 27 | | |||
27 | namespace { | 28 | KWinWaylandTouchpad::KWinWaylandTouchpad(QString dbusName) : | ||
28 | template<typename T> | 29 | LibinputCommon() | ||
29 | T valueLoaderPart(QVariant const &reply) { Q_UNUSED(reply); return T(); } | | |||
30 | | ||||
31 | template<> | | |||
32 | bool valueLoaderPart(QVariant const &reply) { return reply.toBool(); } | | |||
33 | | ||||
34 | template<> | | |||
35 | int valueLoaderPart(QVariant const &reply) { return reply.toInt(); } | | |||
36 | | ||||
37 | template<> | | |||
38 | quint32 valueLoaderPart(QVariant const &reply) { return reply.toInt(); } | | |||
39 | | ||||
40 | template<> | | |||
41 | qreal valueLoaderPart(QVariant const &reply) { return reply.toReal(); } | | |||
42 | | ||||
43 | template<> | | |||
44 | QString valueLoaderPart(QVariant const &reply) { return reply.toString(); } | | |||
45 | | ||||
46 | template<> | | |||
47 | Qt::MouseButtons valueLoaderPart(QVariant const &reply) { return static_cast<Qt::MouseButtons>(reply.toInt()); } | | |||
48 | } | | |||
49 | | ||||
50 | KWinWaylandTouchpad::KWinWaylandTouchpad(QString dbusName) | | |||
51 | { | 30 | { | ||
52 | m_iface = new QDBusInterface(QStringLiteral("org.kde.KWin"), | 31 | m_iface = new QDBusInterface(QStringLiteral("org.kde.KWin"), | ||
53 | QStringLiteral("/org/kde/KWin/InputDevice/") + dbusName, | 32 | QStringLiteral("/org/kde/KWin/InputDevice/") + dbusName, | ||
54 | QStringLiteral("org.kde.KWin.InputDevice"), | 33 | QStringLiteral("org.kde.KWin.InputDevice"), | ||
55 | QDBusConnection::sessionBus(), | 34 | QDBusConnection::sessionBus(), | ||
56 | this); | 35 | this); | ||
57 | } | 36 | } | ||
58 | 37 | | |||
▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Line(s) | |||||
231 | } | 210 | } | ||
232 | 211 | | |||
233 | template<typename T> | 212 | template<typename T> | ||
234 | QString KWinWaylandTouchpad::valueWriter(const Prop<T> &prop) | 213 | QString KWinWaylandTouchpad::valueWriter(const Prop<T> &prop) | ||
235 | { | 214 | { | ||
236 | if (!prop.changed()) { | 215 | if (!prop.changed()) { | ||
237 | return QString(); | 216 | return QString(); | ||
238 | } | 217 | } | ||
239 | m_iface->setProperty(prop.dbus, prop.val); | 218 | m_iface->setProperty(prop.name, prop.val); | ||
240 | QDBusError error = m_iface->lastError(); | 219 | QDBusError error = m_iface->lastError(); | ||
241 | if (error.isValid()) { | 220 | if (error.isValid()) { | ||
242 | qCCritical(KCM_TOUCHPAD) << error.message(); | 221 | qCCritical(KCM_TOUCHPAD) << error.message(); | ||
243 | return error.message(); | 222 | return error.message(); | ||
244 | } | 223 | } | ||
245 | return QString(); | 224 | return QString(); | ||
246 | } | 225 | } | ||
247 | 226 | | |||
248 | template<typename T> | 227 | template<typename T> | ||
249 | bool KWinWaylandTouchpad::valueLoader(Prop<T> &prop) | 228 | bool KWinWaylandTouchpad::valueLoader(Prop<T> &prop) | ||
250 | { | 229 | { | ||
251 | QVariant reply = m_iface->property(prop.dbus); | 230 | QVariant reply = m_iface->property(prop.name); | ||
252 | if (!reply.isValid()) { | 231 | if (!reply.isValid()) { | ||
253 | qCCritical(KCM_TOUCHPAD) << "Error on d-bus read of" << prop.dbus; | 232 | qCCritical(KCM_TOUCHPAD) << "Error on d-bus read of" << prop.name; | ||
254 | prop.avail = false; | 233 | prop.avail = false; | ||
255 | return false; | 234 | return false; | ||
256 | } | 235 | } | ||
257 | prop.avail = true; | 236 | prop.avail = true; | ||
258 | 237 | | |||
259 | T replyValue = valueLoaderPart<T>(reply); | 238 | T replyValue = valueLoaderPart<T>(reply); | ||
260 | 239 | | |||
261 | prop.old = replyValue; | 240 | prop.old = replyValue; | ||
262 | prop.val = replyValue; | 241 | prop.val = replyValue; | ||
263 | return true; | 242 | return true; | ||
264 | } | 243 | } |