on xenial help sign in
Sync AS cursor speed properties
f8ba2c1Michael Terry
plugins/AccountsService/AccountsService.cpp+61
@@ -19,6 +19,7 @@
19#include "AccountsService.h"
19#include "AccountsService.h"
20#include "AccountsServiceDBusAdaptor.h"
20#include "AccountsServiceDBusAdaptor.h"
21
21
22+#include <QDBusInterface>
22#include <QFile>
23#include <QFile>
23#include <QStringList>
24#include <QStringList>
24#include <QDebug>
25#include <QDebug>
@@ -35,6 +36,11 @@ AccountsService::AccountsService(QObject* parent, const QString &user)
35 m_hereEnabled(false),
36 m_hereEnabled(false),
36 m_hereLicensePath() // null means not set yet
37 m_hereLicensePath() // null means not set yet
37{
38{
39+ m_unityInput = new QDBusInterface(QStringLiteral("com.canonical.Unity.Input"),
40+ QStringLiteral("/com/canonical/Unity/Input"),
41+ QStringLiteral("com.canonical.Unity.Input"),
42+ QDBusConnection::SM_BUSNAME(), this);
43+
38 connect(m_service, &AccountsServiceDBusAdaptor::propertiesChanged, this, &AccountsService::onPropertiesChanged);
44 connect(m_service, &AccountsServiceDBusAdaptor::propertiesChanged, this, &AccountsService::onPropertiesChanged);
39 connect(m_service, &AccountsServiceDBusAdaptor::maybeChanged, this, &AccountsService::onMaybeChanged);
45 connect(m_service, &AccountsServiceDBusAdaptor::maybeChanged, this, &AccountsService::onMaybeChanged);
40
46
@@ -58,6 +64,8 @@ void AccountsService::setUser(const QString &user)
58 updateEnableLauncherWhileLocked(false);
64 updateEnableLauncherWhileLocked(false);
59 updateEnableIndicatorsWhileLocked(false);
65 updateEnableIndicatorsWhileLocked(false);
60 updateBackgroundFile(false);
66 updateBackgroundFile(false);
67+ updateMouseCursorSpeed();
68+ updateTouchpadCursorSpeed();
61 updateStatsWelcomeScreen(false);
69 updateStatsWelcomeScreen(false);
62 updatePasswordDisplayHint(false);
70 updatePasswordDisplayHint(false);
63 updateFailedLogins(false);
71 updateFailedLogins(false);
@@ -246,6 +254,52 @@ void AccountsService::updateBackgroundFile(bool async)
246 }
254 }
247}
255}
248
256
257+void AccountsService::updateMouseCursorSpeed()
258+{
259+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
260+ QStringLiteral("com.ubuntu.AccountsService.Input"),
261+ QStringLiteral("MouseCursorSpeed"));
262+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
263+
264+ connect(watcher, &QDBusPendingCallWatcher::finished,
265+ this, [this](QDBusPendingCallWatcher* watcher) {
266+
267+ QDBusPendingReply<QVariant> reply = *watcher;
268+ watcher->deleteLater();
269+ if (reply.isError()) {
270+ qWarning() << "Failed to get 'MouseCursorSpeed' property - " << reply.error().message();
271+ return;
272+ }
273+
274+ // Merely proxy this along to USC. We don't care about keeping a copy
275+ // or exporting it internally.
276+ m_unityInput->asyncCall(QStringLiteral("setMouseCursorSpeed"), reply.value());
277+ });
278+}
279+
280+void AccountsService::updateTouchpadCursorSpeed()
281+{
282+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
283+ QStringLiteral("com.ubuntu.AccountsService.Input"),
284+ QStringLiteral("TouchpadCursorSpeed"));
285+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
286+
287+ connect(watcher, &QDBusPendingCallWatcher::finished,
288+ this, [this](QDBusPendingCallWatcher* watcher) {
289+
290+ QDBusPendingReply<QVariant> reply = *watcher;
291+ watcher->deleteLater();
292+ if (reply.isError()) {
293+ qWarning() << "Failed to get 'TouchpadCursorSpeed' property - " << reply.error().message();
294+ return;
295+ }
296+
297+ // Merely proxy this along to USC. We don't care about keeping a copy
298+ // or exporting it internally.
299+ m_unityInput->asyncCall(QStringLiteral("setTouchpadCursorSpeed"), reply.value());
300+ });
301+}
302+
249void AccountsService::updateStatsWelcomeScreen(bool async)
303void AccountsService::updateStatsWelcomeScreen(bool async)
250{
304{
251 QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
305 QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
@@ -423,6 +477,13 @@ void AccountsService::onPropertiesChanged(const QString &user, const QString &in
423 if (changed.contains(QStringLiteral("FailedLogins"))) {
477 if (changed.contains(QStringLiteral("FailedLogins"))) {
424 updateFailedLogins();
478 updateFailedLogins();
425 }
479 }
480+ } else if (interface == QLatin1String("com.ubuntu.AccountsService.Input")) {
481+ if (changed.contains(QStringLiteral("MouseCursorSpeed"))) {
482+ updateMouseCursorSpeed();
483+ }
484+ if (changed.contains(QStringLiteral("TouchpadCursorSpeed"))) {
485+ updateTouchpadCursorSpeed();
486+ }
426 } else if (interface == QLatin1String("com.ubuntu.touch.AccountsService.SecurityPrivacy")) {
487 } else if (interface == QLatin1String("com.ubuntu.touch.AccountsService.SecurityPrivacy")) {
427 if (changed.contains(QStringLiteral("StatsWelcomeScreen"))) {
488 if (changed.contains(QStringLiteral("StatsWelcomeScreen"))) {
428 updateStatsWelcomeScreen();
489 updateStatsWelcomeScreen();
plugins/AccountsService/AccountsService.h+4
@@ -23,6 +23,7 @@
23#include <QString>
23#include <QString>
24
24
25class AccountsServiceDBusAdaptor;
25class AccountsServiceDBusAdaptor;
26+class QDBusInterface;
26
27
27class AccountsService: public QObject
28class AccountsService: public QObject
28{
29{
@@ -112,6 +113,8 @@ private:
112 void updateEnableLauncherWhileLocked(bool async = true);
113 void updateEnableLauncherWhileLocked(bool async = true);
113 void updateEnableIndicatorsWhileLocked(bool async = true);
114 void updateEnableIndicatorsWhileLocked(bool async = true);
114 void updateBackgroundFile(bool async = true);
115 void updateBackgroundFile(bool async = true);
116+ void updateMouseCursorSpeed();
117+ void updateTouchpadCursorSpeed();
115 void updateStatsWelcomeScreen(bool async = true);
118 void updateStatsWelcomeScreen(bool async = true);
116 void updatePasswordDisplayHint(bool async = true);
119 void updatePasswordDisplayHint(bool async = true);
117 void updateFailedLogins(bool async = true);
120 void updateFailedLogins(bool async = true);
@@ -119,6 +122,7 @@ private:
119 void updateHereLicensePath(bool async = true);
122 void updateHereLicensePath(bool async = true);
120
123
121 AccountsServiceDBusAdaptor *m_service;
124 AccountsServiceDBusAdaptor *m_service;
125+ QDBusInterface *m_unityInput;
122 QString m_user;
126 QString m_user;
123 bool m_demoEdges;
127 bool m_demoEdges;
124 bool m_enableLauncherWhileLocked;
128 bool m_enableLauncherWhileLocked;