Changeset View
Changeset View
Standalone View
Standalone View
kcms/mouse/backends/kwin_wl/kwin_wl_backend.cpp
- This file was moved from kcms/input/backends/kwin_wl/kwin_wl_backend.cpp.
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 61 | { | |||
---|---|---|---|---|---|
63 | delete m_deviceManager; | 63 | delete m_deviceManager; | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | void KWinWaylandBackend::findDevices() | 66 | void KWinWaylandBackend::findDevices() | ||
67 | { | 67 | { | ||
68 | QStringList devicesSysNames; | 68 | QStringList devicesSysNames; | ||
69 | const QVariant reply = m_deviceManager->property("devicesSysNames"); | 69 | const QVariant reply = m_deviceManager->property("devicesSysNames"); | ||
70 | if (reply.isValid()) { | 70 | if (reply.isValid()) { | ||
71 | qCDebug(KCM_INPUT) << "Devices list received successfully from KWin."; | 71 | qCDebug(KCM_MOUSE) << "Devices list received successfully from KWin."; | ||
72 | devicesSysNames = reply.toStringList(); | 72 | devicesSysNames = reply.toStringList(); | ||
73 | } | 73 | } | ||
74 | else { | 74 | else { | ||
75 | qCCritical(KCM_INPUT) << "Error on receiving device list from KWin."; | 75 | qCCritical(KCM_MOUSE) << "Error on receiving device list from KWin."; | ||
76 | m_errorString = i18n("Querying input devices failed. Please reopen this settings module."); | 76 | m_errorString = i18n("Querying input devices failed. Please reopen this settings module."); | ||
77 | return; | 77 | return; | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | for (QString sn : devicesSysNames) { | 80 | for (QString sn : devicesSysNames) { | ||
81 | QDBusInterface deviceIface(QStringLiteral("org.kde.KWin"), | 81 | QDBusInterface deviceIface(QStringLiteral("org.kde.KWin"), | ||
82 | QStringLiteral("/org/kde/KWin/InputDevice/") + sn, | 82 | QStringLiteral("/org/kde/KWin/InputDevice/") + sn, | ||
83 | QStringLiteral("org.kde.KWin.InputDevice"), | 83 | QStringLiteral("org.kde.KWin.InputDevice"), | ||
84 | QDBusConnection::sessionBus(), | 84 | QDBusConnection::sessionBus(), | ||
85 | this); | 85 | this); | ||
86 | QVariant reply = deviceIface.property("pointer"); | 86 | QVariant reply = deviceIface.property("pointer"); | ||
87 | if (reply.isValid() && reply.toBool()) { | 87 | if (reply.isValid() && reply.toBool()) { | ||
88 | reply = deviceIface.property("touchpad"); | 88 | reply = deviceIface.property("touchpad"); | ||
89 | if (reply.isValid() && reply.toBool()) { | 89 | if (reply.isValid() && reply.toBool()) { | ||
90 | continue; | 90 | continue; | ||
91 | } | 91 | } | ||
92 | 92 | | |||
93 | KWinWaylandDevice* dev = new KWinWaylandDevice(sn); | 93 | KWinWaylandDevice* dev = new KWinWaylandDevice(sn); | ||
94 | if (!dev->init()) { | 94 | if (!dev->init()) { | ||
95 | qCCritical(KCM_INPUT) << "Error on creating device object" << sn; | 95 | qCCritical(KCM_MOUSE) << "Error on creating device object" << sn; | ||
96 | m_errorString = i18n("Critical error on reading fundamental device infos of %1.", sn); | 96 | m_errorString = i18n("Critical error on reading fundamental device infos of %1.", sn); | ||
97 | return; | 97 | return; | ||
98 | } | 98 | } | ||
99 | m_devices.append(dev); | 99 | m_devices.append(dev); | ||
100 | qCDebug(KCM_INPUT).nospace() << "Device found: " << dev->name() << " (" << dev->sysName() << ")"; | 100 | qCDebug(KCM_MOUSE).nospace() << "Device found: " << dev->name() << " (" << dev->sysName() << ")"; | ||
101 | } | 101 | } | ||
102 | } | 102 | } | ||
103 | } | 103 | } | ||
104 | 104 | | |||
105 | bool KWinWaylandBackend::applyConfig() | 105 | bool KWinWaylandBackend::applyConfig() | ||
106 | { | 106 | { | ||
107 | return std::all_of(m_devices.constBegin(), m_devices.constEnd(), | 107 | return std::all_of(m_devices.constBegin(), m_devices.constEnd(), | ||
108 | [] (QObject *t) { return static_cast<KWinWaylandDevice*>(t)->applyConfig(); }); | 108 | [] (QObject *t) { return static_cast<KWinWaylandDevice*>(t)->applyConfig(); }); | ||
Show All 39 Lines | 143 | if (reply.isValid() && reply.toBool()) { | |||
148 | 148 | | |||
149 | KWinWaylandDevice* dev = new KWinWaylandDevice(sysName); | 149 | KWinWaylandDevice* dev = new KWinWaylandDevice(sysName); | ||
150 | if (!dev->init() || !dev->getConfig()) { | 150 | if (!dev->init() || !dev->getConfig()) { | ||
151 | emit deviceAdded(false); | 151 | emit deviceAdded(false); | ||
152 | return; | 152 | return; | ||
153 | } | 153 | } | ||
154 | 154 | | |||
155 | m_devices.append(dev); | 155 | m_devices.append(dev); | ||
156 | qCDebug(KCM_INPUT).nospace() << "Device connected: " << dev->name() << " (" << dev->sysName() << ")"; | 156 | qCDebug(KCM_MOUSE).nospace() << "Device connected: " << dev->name() << " (" << dev->sysName() << ")"; | ||
157 | emit deviceAdded(true); | 157 | emit deviceAdded(true); | ||
158 | } | 158 | } | ||
159 | } | 159 | } | ||
160 | 160 | | |||
161 | void KWinWaylandBackend::onDeviceRemoved(QString sysName) | 161 | void KWinWaylandBackend::onDeviceRemoved(QString sysName) | ||
162 | { | 162 | { | ||
163 | QVector<QObject*>::const_iterator it = std::find_if(m_devices.constBegin(), m_devices.constEnd(), | 163 | QVector<QObject*>::const_iterator it = std::find_if(m_devices.constBegin(), m_devices.constEnd(), | ||
164 | [sysName] (QObject *t) { return static_cast<KWinWaylandDevice*>(t)->sysName() == sysName; }); | 164 | [sysName] (QObject *t) { return static_cast<KWinWaylandDevice*>(t)->sysName() == sysName; }); | ||
165 | if (it == m_devices.cend()) { | 165 | if (it == m_devices.cend()) { | ||
166 | return; | 166 | return; | ||
167 | } | 167 | } | ||
168 | 168 | | |||
169 | KWinWaylandDevice *dev = static_cast<KWinWaylandDevice*>(*it); | 169 | KWinWaylandDevice *dev = static_cast<KWinWaylandDevice*>(*it); | ||
170 | qCDebug(KCM_INPUT).nospace() << "Device disconnected: " << dev->name() << " (" << dev->sysName() << ")"; | 170 | qCDebug(KCM_MOUSE).nospace() << "Device disconnected: " << dev->name() << " (" << dev->sysName() << ")"; | ||
171 | 171 | | |||
172 | int index = it - m_devices.cbegin(); | 172 | int index = it - m_devices.cbegin(); | ||
173 | m_devices.removeAt(index); | 173 | m_devices.removeAt(index); | ||
174 | emit deviceRemoved(index); | 174 | emit deviceRemoved(index); | ||
175 | } | 175 | } |