Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpad/src/backends/x11/xlibbackend.cpp
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 103 | { | |||
---|---|---|---|---|---|
104 | int nDevices = 0; | 104 | int nDevices = 0; | ||
105 | QScopedPointer<XDeviceInfo, DeviceListDeleter> | 105 | QScopedPointer<XDeviceInfo, DeviceListDeleter> | ||
106 | deviceInfo(XListInputDevices(m_display.data(), &nDevices)); | 106 | deviceInfo(XListInputDevices(m_display.data(), &nDevices)); | ||
107 | 107 | | |||
108 | for (XDeviceInfo *info = deviceInfo.data(); | 108 | for (XDeviceInfo *info = deviceInfo.data(); | ||
109 | info < deviceInfo.data() + nDevices; info++) | 109 | info < deviceInfo.data() + nDevices; info++) | ||
110 | { | 110 | { | ||
111 | // Make sure device is touchpad | 111 | // Make sure device is touchpad | ||
112 | | ||||
112 | if (info->type != m_touchpadAtom.atom()) { | 113 | if (info->type != m_touchpadAtom.atom()) { | ||
113 | continue; | 114 | continue; | ||
114 | } | 115 | } | ||
115 | int nProperties = 0; | 116 | int nProperties = 0; | ||
116 | QSharedPointer<Atom> properties( | 117 | QSharedPointer<Atom> properties( | ||
117 | XIListProperties(m_display.data(), info->id, | 118 | XIListProperties(m_display.data(), info->id, | ||
118 | &nProperties), XDeleter); | 119 | &nProperties), XDeleter); | ||
119 | 120 | | |||
120 | Atom *atom = properties.data(), *atomEnd = properties.data() + nProperties; | 121 | Atom *atom = properties.data(), *atomEnd = properties.data() + nProperties; | ||
121 | for (; atom != atomEnd; atom++) { | 122 | for (; atom != atomEnd; atom++) { | ||
122 | if (*atom == m_libinputIdentifierAtom.atom()) { | 123 | if (*atom == m_libinputIdentifierAtom.atom()) { | ||
124 | m_mode = TouchpadInputBackendMode::XLibinput; | ||||
123 | return new LibinputTouchpad(m_display.data(), info->id); | 125 | return new LibinputTouchpad(m_display.data(), info->id); | ||
124 | } else if (*atom == m_synapticsIdentifierAtom.atom()) { | 126 | } else if (*atom == m_synapticsIdentifierAtom.atom()) { | ||
127 | m_mode = TouchpadInputBackendMode::XSynaptics; | ||||
125 | return new SynapticsTouchpad(m_display.data(), info->id); | 128 | return new SynapticsTouchpad(m_display.data(), info->id); | ||
126 | } | 129 | } | ||
127 | } | 130 | } | ||
128 | } | 131 | } | ||
129 | 132 | | |||
130 | return nullptr; | 133 | return nullptr; | ||
131 | } | 134 | } | ||
132 | 135 | | |||
133 | bool XlibBackend::applyConfig(const QVariantHash &p) | 136 | bool XlibBackend::applyConfig(const QVariantHash &p) | ||
134 | { | 137 | { | ||
135 | if (!m_device) { | 138 | if (!m_device) { | ||
136 | return false; | 139 | return false; | ||
137 | } | 140 | } | ||
138 | 141 | | |||
139 | bool success = m_device->applyConfig(p); | 142 | bool success = m_device->applyConfig(p); | ||
140 | if (!success) { | 143 | if (!success) { | ||
141 | m_errorString = i18n("Cannot apply touchpad configuration"); | 144 | m_errorString = i18n("Cannot apply touchpad configuration"); | ||
142 | } | 145 | } | ||
143 | 146 | | |||
144 | return success; | 147 | return success; | ||
145 | } | 148 | } | ||
146 | 149 | | |||
150 | bool XlibBackend::applyConfig() | ||||
151 | { | ||||
152 | if (!m_device) { | ||||
153 | return false; | ||||
154 | } | ||||
155 | | ||||
156 | bool success = m_device->applyConfig(); | ||||
157 | if (!success) { | ||||
158 | m_errorString = i18n("Cannot apply touchpad configuration"); | ||||
159 | } | ||||
160 | | ||||
161 | return success; | ||||
162 | } | ||||
163 | | ||||
147 | bool XlibBackend::getConfig(QVariantHash &p) | 164 | bool XlibBackend::getConfig(QVariantHash &p) | ||
148 | { | 165 | { | ||
149 | if (!m_device) { | 166 | if (!m_device) { | ||
150 | return false; | 167 | return false; | ||
151 | } | 168 | } | ||
152 | 169 | | |||
153 | bool success = m_device->getConfig(p); | 170 | bool success = m_device->getConfig(p); | ||
154 | if (!success) { | 171 | if (!success) { | ||
155 | m_errorString = i18n("Cannot read touchpad configuration"); | 172 | m_errorString = i18n("Cannot read touchpad configuration"); | ||
156 | } | 173 | } | ||
157 | return success; | 174 | return success; | ||
158 | } | 175 | } | ||
159 | 176 | | |||
177 | bool XlibBackend::getConfig() | ||||
178 | { | ||||
179 | if(!m_device) { | ||||
180 | return false; | ||||
181 | } | ||||
182 | | ||||
183 | bool success = m_device->getConfig(); | ||||
184 | if (!success) { | ||||
185 | m_errorString = i18n("Cannot read touchpad configuration"); | ||||
186 | } | ||||
187 | return success; | ||||
188 | } | ||||
189 | | ||||
190 | bool XlibBackend::getDefaultConfig() | ||||
191 | { | ||||
192 | if (!m_device) { | ||||
193 | return false; | ||||
194 | } | ||||
195 | | ||||
196 | bool success = m_device->getDefaultConfig(); | ||||
197 | if (!success) { | ||||
198 | m_errorString = i18n("Cannot read default touchpad configuration"); | ||||
199 | } | ||||
200 | return success; | ||||
201 | } | ||||
202 | | ||||
203 | bool XlibBackend::isChangedConfig() const | ||||
204 | { | ||||
205 | if (!m_device) { | ||||
206 | return false; | ||||
207 | } | ||||
208 | | ||||
209 | return m_device->isChangedConfig(); | ||||
210 | } | ||||
211 | | ||||
160 | void XlibBackend::setTouchpadEnabled(bool enable) | 212 | void XlibBackend::setTouchpadEnabled(bool enable) | ||
161 | { | 213 | { | ||
162 | if (!m_device) { | 214 | if (!m_device) { | ||
163 | return; | 215 | return; | ||
164 | } | 216 | } | ||
165 | 217 | | |||
166 | m_device->setEnabled(enable); | 218 | m_device->setEnabled(enable); | ||
167 | 219 | | |||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |