Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpad/src/backends/x11/xlibbackend.cpp
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | 110 | { | |||
---|---|---|---|---|---|
115 | int nProperties = 0; | 115 | int nProperties = 0; | ||
116 | QSharedPointer<Atom> properties( | 116 | QSharedPointer<Atom> properties( | ||
117 | XIListProperties(m_display.data(), info->id, | 117 | XIListProperties(m_display.data(), info->id, | ||
118 | &nProperties), XDeleter); | 118 | &nProperties), XDeleter); | ||
119 | 119 | | |||
120 | Atom *atom = properties.data(), *atomEnd = properties.data() + nProperties; | 120 | Atom *atom = properties.data(), *atomEnd = properties.data() + nProperties; | ||
121 | for (; atom != atomEnd; atom++) { | 121 | for (; atom != atomEnd; atom++) { | ||
122 | if (*atom == m_libinputIdentifierAtom.atom()) { | 122 | if (*atom == m_libinputIdentifierAtom.atom()) { | ||
123 | setMode(TouchpadInputBackendMode::XLibinput); | ||||
123 | return new LibinputTouchpad(m_display.data(), info->id); | 124 | return new LibinputTouchpad(m_display.data(), info->id); | ||
124 | } else if (*atom == m_synapticsIdentifierAtom.atom()) { | 125 | } else if (*atom == m_synapticsIdentifierAtom.atom()) { | ||
126 | setMode(TouchpadInputBackendMode::XSynaptics); | ||||
125 | return new SynapticsTouchpad(m_display.data(), info->id); | 127 | return new SynapticsTouchpad(m_display.data(), info->id); | ||
126 | } | 128 | } | ||
127 | } | 129 | } | ||
128 | } | 130 | } | ||
129 | 131 | | |||
130 | return nullptr; | 132 | return nullptr; | ||
131 | } | 133 | } | ||
132 | 134 | | |||
133 | bool XlibBackend::applyConfig(const QVariantHash &p) | 135 | bool XlibBackend::applyConfig(const QVariantHash &p) | ||
134 | { | 136 | { | ||
135 | if (!m_device) { | 137 | if (!m_device) { | ||
136 | return false; | 138 | return false; | ||
137 | } | 139 | } | ||
138 | 140 | | |||
139 | bool success = m_device->applyConfig(p); | 141 | bool success = m_device->applyConfig(p); | ||
140 | if (!success) { | 142 | if (!success) { | ||
141 | m_errorString = i18n("Cannot apply touchpad configuration"); | 143 | m_errorString = i18n("Cannot apply touchpad configuration"); | ||
142 | } | 144 | } | ||
143 | 145 | | |||
144 | return success; | 146 | return success; | ||
145 | } | 147 | } | ||
146 | 148 | | |||
149 | bool XlibBackend::applyConfig() | ||||
150 | { | ||||
151 | if (!m_device) { | ||||
152 | return false; | ||||
153 | } | ||||
154 | | ||||
155 | bool success = m_device->applyConfig(); | ||||
156 | if (!success) { | ||||
157 | m_errorString = i18n("Cannot apply touchpad configuration"); | ||||
158 | } | ||||
159 | | ||||
160 | return success; | ||||
161 | } | ||||
162 | | ||||
147 | bool XlibBackend::getConfig(QVariantHash &p) | 163 | bool XlibBackend::getConfig(QVariantHash &p) | ||
148 | { | 164 | { | ||
149 | if (!m_device) { | 165 | if (!m_device) { | ||
150 | return false; | 166 | return false; | ||
151 | } | 167 | } | ||
152 | 168 | | |||
153 | bool success = m_device->getConfig(p); | 169 | bool success = m_device->getConfig(p); | ||
154 | if (!success) { | 170 | if (!success) { | ||
155 | m_errorString = i18n("Cannot read touchpad configuration"); | 171 | m_errorString = i18n("Cannot read touchpad configuration"); | ||
156 | } | 172 | } | ||
157 | return success; | 173 | return success; | ||
158 | } | 174 | } | ||
159 | 175 | | |||
176 | bool XlibBackend::getConfig() | ||||
177 | { | ||||
178 | if(!m_device) { | ||||
179 | return false; | ||||
180 | } | ||||
181 | | ||||
182 | bool success = m_device->getConfig(); | ||||
183 | if (!success) { | ||||
184 | m_errorString = i18n("Cannot read touchpad configuration"); | ||||
185 | } | ||||
186 | return success; | ||||
187 | } | ||||
188 | | ||||
189 | bool XlibBackend::getDefaultConfig() | ||||
190 | { | ||||
191 | if (!m_device) { | ||||
192 | return false; | ||||
193 | } | ||||
194 | | ||||
195 | bool success = m_device->getDefaultConfig(); | ||||
196 | if (!success) { | ||||
197 | m_errorString = i18n("Cannot read default touchpad configuration"); | ||||
198 | } | ||||
199 | return success; | ||||
200 | } | ||||
201 | | ||||
202 | bool XlibBackend::isChangedConfig() const | ||||
203 | { | ||||
204 | if (!m_device) { | ||||
205 | return false; | ||||
206 | } | ||||
207 | | ||||
208 | return m_device->isChangedConfig(); | ||||
209 | } | ||||
210 | | ||||
160 | void XlibBackend::setTouchpadEnabled(bool enable) | 211 | void XlibBackend::setTouchpadEnabled(bool enable) | ||
161 | { | 212 | { | ||
162 | if (!m_device) { | 213 | if (!m_device) { | ||
163 | return; | 214 | return; | ||
164 | } | 215 | } | ||
165 | 216 | | |||
166 | m_device->setEnabled(enable); | 217 | m_device->setEnabled(enable); | ||
167 | 218 | | |||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 340 | if (enabled.value(0) == false) { | |||
290 | continue; | 341 | continue; | ||
291 | } | 342 | } | ||
292 | list.append(name); | 343 | list.append(name); | ||
293 | } | 344 | } | ||
294 | 345 | | |||
295 | return list; | 346 | return list; | ||
296 | } | 347 | } | ||
297 | 348 | | |||
349 | QVector<QObject *> XlibBackend::getDevices() const | ||||
350 | { | ||||
351 | QVector<QObject*> touchpads; | ||||
352 | | ||||
353 | LibinputTouchpad* libinputtouchpad = dynamic_cast<LibinputTouchpad*> (m_device.data()); | ||||
354 | SynapticsTouchpad* synaptics = dynamic_cast<SynapticsTouchpad*> (m_device.data()); | ||||
355 | | ||||
356 | if ( libinputtouchpad) { | ||||
357 | touchpads.push_back(libinputtouchpad); | ||||
358 | } | ||||
359 | if (synaptics) { | ||||
360 | touchpads.push_back(synaptics); | ||||
361 | } | ||||
362 | return touchpads; | ||||
363 | } | ||||
364 | | ||||
298 | void XlibBackend::watchForEvents(bool keyboard) | 365 | void XlibBackend::watchForEvents(bool keyboard) | ||
299 | { | 366 | { | ||
300 | if (!m_notifications) { | 367 | if (!m_notifications) { | ||
301 | m_notifications.reset(new XlibNotifications(m_display.data(), m_device ? m_device->deviceId() : XIAllDevices)); | 368 | m_notifications.reset(new XlibNotifications(m_display.data(), m_device ? m_device->deviceId() : XIAllDevices)); | ||
302 | connect(m_notifications.data(), SIGNAL(devicePlugged(int)), | 369 | connect(m_notifications.data(), SIGNAL(devicePlugged(int)), | ||
303 | SLOT(devicePlugged(int))); | 370 | SLOT(devicePlugged(int))); | ||
304 | connect(m_notifications.data(), SIGNAL(touchpadDetached()), | 371 | connect(m_notifications.data(), SIGNAL(touchpadDetached()), | ||
305 | SLOT(touchpadDetached())); | 372 | SLOT(touchpadDetached())); | ||
Show All 19 Lines |