1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
|
/*
SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef X11LIBINPUTDUMMYDEVICE_H
#define X11LIBINPUTDUMMYDEVICE_H
#include <QObject>
#include <QString>
#include <QX11Info>
#include <X11/Xdefs.h>
struct LibinputSettings;
class X11LibinputDummyDevice : public QObject
{
Q_OBJECT
//
// general
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(bool supportsDisableEvents READ supportsDisableEvents CONSTANT)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
//
// advanced
Q_PROPERTY(Qt::MouseButtons supportedButtons READ supportedButtons CONSTANT)
Q_PROPERTY(bool supportsLeftHanded READ supportsLeftHanded CONSTANT)
Q_PROPERTY(bool leftHandedEnabledByDefault READ leftHandedEnabledByDefault CONSTANT)
Q_PROPERTY(bool leftHanded READ isLeftHanded WRITE setLeftHanded NOTIFY leftHandedChanged)
Q_PROPERTY(bool supportsMiddleEmulation READ supportsMiddleEmulation CONSTANT)
Q_PROPERTY(bool middleEmulationEnabledByDefault READ middleEmulationEnabledByDefault CONSTANT)
Q_PROPERTY(bool middleEmulation READ isMiddleEmulation WRITE setMiddleEmulation NOTIFY middleEmulationChanged)
//
// acceleration speed and profile
Q_PROPERTY(bool supportsPointerAcceleration READ supportsPointerAcceleration CONSTANT)
Q_PROPERTY(qreal pointerAcceleration READ pointerAcceleration WRITE setPointerAcceleration NOTIFY pointerAccelerationChanged)
Q_PROPERTY(bool supportsPointerAccelerationProfileFlat READ supportsPointerAccelerationProfileFlat CONSTANT)
Q_PROPERTY(bool defaultPointerAccelerationProfileFlat READ defaultPointerAccelerationProfileFlat CONSTANT)
Q_PROPERTY(bool pointerAccelerationProfileFlat READ pointerAccelerationProfileFlat WRITE setPointerAccelerationProfileFlat NOTIFY
pointerAccelerationProfileChanged)
Q_PROPERTY(bool supportsPointerAccelerationProfileAdaptive READ supportsPointerAccelerationProfileAdaptive CONSTANT)
Q_PROPERTY(bool defaultPointerAccelerationProfileAdaptive READ defaultPointerAccelerationProfileAdaptive CONSTANT)
Q_PROPERTY(bool pointerAccelerationProfileAdaptive READ pointerAccelerationProfileAdaptive WRITE setPointerAccelerationProfileAdaptive NOTIFY
pointerAccelerationProfileChanged)
//
// scrolling
Q_PROPERTY(bool supportsNaturalScroll READ supportsNaturalScroll CONSTANT)
Q_PROPERTY(bool naturalScrollEnabledByDefault READ naturalScrollEnabledByDefault CONSTANT)
Q_PROPERTY(bool naturalScroll READ isNaturalScroll WRITE setNaturalScroll NOTIFY naturalScrollChanged)
public:
X11LibinputDummyDevice(QObject *parent, Display *dpy);
~X11LibinputDummyDevice() override;
bool getConfig();
bool getDefaultConfig();
bool applyConfig();
bool isChangedConfig() const;
//
// general
QString name() const
{
return m_name.val;
}
QString sysName() const
{
return m_sysName.val;
}
bool supportsDisableEvents() const
{
return m_supportsDisableEvents.val;
}
void setEnabled(bool enabled)
{
m_enabled.set(enabled);
}
bool isEnabled() const
{
return m_enabled.val;
}
Qt::MouseButtons supportedButtons() const
{
return m_supportedButtons.val;
}
//
// advanced
bool supportsLeftHanded() const
{
return m_supportsLeftHanded.val;
}
bool leftHandedEnabledByDefault() const
{
return m_leftHandedEnabledByDefault.val;
}
bool isLeftHanded() const
{
return m_leftHanded.val;
}
void setLeftHanded(bool set)
{
m_leftHanded.set(set);
}
bool supportsMiddleEmulation() const
{
return m_supportsMiddleEmulation.val;
}
bool middleEmulationEnabledByDefault() const
{
return m_middleEmulationEnabledByDefault.val;
}
bool isMiddleEmulation() const
{
return m_middleEmulation.val;
}
void setMiddleEmulation(bool set)
{
m_middleEmulation.set(set);
}
//
// acceleration speed and profile
bool supportsPointerAcceleration() const
{
return m_supportsPointerAcceleration.val;
}
qreal pointerAcceleration() const
{
return m_pointerAcceleration.val;
}
void setPointerAcceleration(qreal acceleration)
{
m_pointerAcceleration.set(acceleration);
}
bool supportsPointerAccelerationProfileFlat() const
{
return m_supportsPointerAccelerationProfileFlat.val;
}
bool defaultPointerAccelerationProfileFlat() const
{
return m_defaultPointerAccelerationProfileFlat.val;
}
bool pointerAccelerationProfileFlat() const
{
return m_pointerAccelerationProfileFlat.val;
}
void setPointerAccelerationProfileFlat(bool set)
{
m_pointerAccelerationProfileFlat.set(set);
}
bool supportsPointerAccelerationProfileAdaptive() const
{
return m_supportsPointerAccelerationProfileAdaptive.val;
}
bool defaultPointerAccelerationProfileAdaptive() const
{
return m_defaultPointerAccelerationProfileAdaptive.val;
}
bool pointerAccelerationProfileAdaptive() const
{
return m_pointerAccelerationProfileAdaptive.val;
}
void setPointerAccelerationProfileAdaptive(bool set)
{
m_pointerAccelerationProfileAdaptive.set(set);
}
//
// scrolling
bool supportsNaturalScroll() const
{
return m_supportsNaturalScroll.val;
}
bool naturalScrollEnabledByDefault() const
{
return m_naturalScrollEnabledByDefault.val;
}
bool isNaturalScroll() const
{
return m_naturalScroll.val;
}
void setNaturalScroll(bool set)
{
m_naturalScroll.set(set);
}
Q_SIGNALS:
void leftHandedChanged();
void pointerAccelerationChanged();
void pointerAccelerationProfileChanged();
void enabledChanged();
void middleEmulationChanged();
void naturalScrollChanged();
private:
template<typename T>
struct Prop {
explicit Prop(const QString &_name, const QString &_cfgName = "")
: name(_name)
, cfgName(_cfgName)
{
}
void set(T newVal)
{
if (avail && val != newVal) {
val = newVal;
}
}
void set(const Prop<T> &p)
{
if (avail && val != p.val) {
val = p.val;
}
}
bool changed() const
{
return avail && (old != val);
}
void reset(T newVal)
{
val = newVal;
old = newVal;
}
QString name;
QString cfgName;
bool avail = true;
T old;
T val;
Atom atom;
};
template<typename T>
bool valueWriter(Prop<T> &prop);
//
// general
Prop<QString> m_name = Prop<QString>("name");
Prop<QString> m_sysName = Prop<QString>("sysName");
Prop<bool> m_supportsDisableEvents = Prop<bool>("supportsDisableEvents");
Prop<bool> m_enabled = Prop<bool>("enabled");
//
// advanced
Prop<Qt::MouseButtons> m_supportedButtons = Prop<Qt::MouseButtons>("supportedButtons");
Prop<bool> m_supportsLeftHanded = Prop<bool>("supportsLeftHanded");
Prop<bool> m_leftHandedEnabledByDefault = Prop<bool>("leftHandedEnabledByDefault");
Prop<bool> m_leftHanded = Prop<bool>("leftHanded", "XLbInptLeftHanded");
Prop<bool> m_supportsMiddleEmulation = Prop<bool>("supportsMiddleEmulation");
Prop<bool> m_middleEmulationEnabledByDefault = Prop<bool>("middleEmulationEnabledByDefault");
Prop<bool> m_middleEmulation = Prop<bool>("middleEmulation", "XLbInptMiddleEmulation");
//
// acceleration speed and profile
Prop<bool> m_supportsPointerAcceleration = Prop<bool>("supportsPointerAcceleration");
Prop<qreal> m_defaultPointerAcceleration = Prop<qreal>("defaultPointerAcceleration");
Prop<qreal> m_pointerAcceleration = Prop<qreal>("pointerAcceleration", "XLbInptPointerAcceleration");
Prop<bool> m_supportsPointerAccelerationProfileFlat = Prop<bool>("supportsPointerAccelerationProfileFlat");
Prop<bool> m_defaultPointerAccelerationProfileFlat = Prop<bool>("defaultPointerAccelerationProfileFlat");
Prop<bool> m_pointerAccelerationProfileFlat = Prop<bool>("pointerAccelerationProfileFlat", "XLbInptAccelProfileFlat");
Prop<bool> m_supportsPointerAccelerationProfileAdaptive = Prop<bool>("supportsPointerAccelerationProfileAdaptive");
Prop<bool> m_defaultPointerAccelerationProfileAdaptive = Prop<bool>("defaultPointerAccelerationProfileAdaptive");
Prop<bool> m_pointerAccelerationProfileAdaptive = Prop<bool>("pointerAccelerationProfileAdaptive");
//
// scrolling
Prop<bool> m_supportsNaturalScroll = Prop<bool>("supportsNaturalScroll");
Prop<bool> m_naturalScrollEnabledByDefault = Prop<bool>("naturalScrollEnabledByDefault");
Prop<bool> m_naturalScroll = Prop<bool>("naturalScroll", "XLbInptNaturalScroll");
LibinputSettings *m_settings;
Display *m_dpy = nullptr;
};
#endif // X11LIBINPUTDUMMYDEVICE_H
|