Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpadx/src/backends/x11/xlibtouchpad.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2015 Weng Xuetian <wengxt@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License | ||||
15 | * along with this program; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | */ | ||||
18 | | ||||
19 | #ifndef XLIBTOUCHPAD_H | ||||
20 | #define XLIBTOUCHPAD_H | ||||
21 | | ||||
22 | #include <QVariantHash> | ||||
23 | #include <QSet> | ||||
24 | | ||||
25 | #include <xcb/xcb.h> | ||||
26 | #include "xcbatom.h" | ||||
27 | #include "propertyinfo.h" | ||||
28 | | ||||
29 | enum ParaType { | ||||
30 | PT_INT, | ||||
31 | PT_BOOL, | ||||
32 | PT_DOUBLE | ||||
33 | }; | ||||
34 | | ||||
35 | struct Parameter { | ||||
36 | const char *name; /* Name of parameter */ | ||||
37 | enum ParaType type; /* Type of parameter */ | ||||
38 | double min_val; /* Minimum allowed value */ | ||||
39 | double max_val; /* Maximum allowed value */ | ||||
40 | const char *prop_name; /* Property name */ | ||||
41 | int prop_format; /* Property format (0 for floats) */ | ||||
42 | unsigned prop_offset; /* Offset inside property */ | ||||
43 | }; | ||||
44 | | ||||
45 | class XlibTouchpad | ||||
46 | { | ||||
47 | public: | ||||
48 | XlibTouchpad(Display *display, int deviceId); | ||||
49 | virtual ~XlibTouchpad() {}; | ||||
50 | | ||||
51 | int deviceId() { return m_deviceId; } | ||||
52 | const QStringList &supportedParameters() const { return m_supported; } | ||||
53 | bool applyConfig(const QVariantHash &p); | ||||
54 | bool getConfig(QVariantHash &p); | ||||
55 | void setEnabled(bool enable); | ||||
56 | bool enabled(); | ||||
57 | void setTouchpadOff(int touchpadOff); | ||||
58 | int touchpadOff(); | ||||
59 | | ||||
60 | XcbAtom &touchpadOffAtom(); | ||||
61 | | ||||
62 | protected: | ||||
63 | void loadSupportedProperties(const Parameter *props); | ||||
64 | bool setParameter(const struct Parameter *, const QVariant &); | ||||
65 | QVariant getParameter(const struct Parameter *); | ||||
66 | struct PropertyInfo *getDevProperty(const QLatin1String &propName); | ||||
67 | void flush(); | ||||
68 | virtual double getPropertyScale(const QString &name) const; | ||||
69 | const Parameter * findParameter(const QString &name); | ||||
70 | | ||||
71 | Display *m_display; | ||||
72 | xcb_connection_t *m_connection; | ||||
73 | int m_deviceId; | ||||
74 | | ||||
75 | XcbAtom m_floatType, m_enabledAtom, m_touchpadOffAtom; | ||||
76 | | ||||
77 | QMap<QLatin1String, QSharedPointer<XcbAtom> > m_atoms; | ||||
78 | | ||||
79 | QMap<QString, QString> m_negate; | ||||
80 | QMap<QLatin1String, struct PropertyInfo> m_props; | ||||
81 | QSet<QLatin1String> m_changed; | ||||
82 | QStringList m_supported; | ||||
83 | const struct Parameter *m_paramList; | ||||
84 | }; | ||||
85 | | ||||
86 | #endif |