summaryrefslogtreecommitdiffstats
path: root/kcontrol/input/touchpad_settings.h
blob: 8cdfea951b0aeb41a482741f235aea002a4b7d8f (plain)
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
/*******************************************************************************
 tdecm_touchpad
 A touchpad module for the TDE Control Centre

 Copyright © 2024 Mavridis Philippe <mavridisf@gmail.com>

 This program is free software: you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
 Foundation, either version 3 of the License, or (at your option) any later
 version.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

 You should have received a copy of the GNU General Public License along with
 this program. If not, see <https://www.gnu.org/licenses/>.

*******************************************************************************/

#ifndef __TOUCHPAD_SETTINGS_H__
#define __TOUCHPAD_SETTINGS_H__

// TQt
#include <tqvaluelist.h>

// Macros
#define DEL(var) \
  if (var) { delete var; var = nullptr; }

#define ATOM(var, atom) \
  Atom var = XInternAtom(display, atom, true);

#define PROP(var, property) \
  XIProperty var = XIProperty(m_touchpad.id, property);

#define SET_PROP(property, type) \
  DEL(prop) \
  prop = new XIProperty(m_touchpad.id, property); \
  if (prop->type == nullptr) \
  { \
     kdWarning() << "Failed to set property " << property << endl; \
     ++fail; \
  } \
  else

#define IF_DRIVER(drv) \
  if (touchpad().driver == Touchpad::Driver::drv)


/****************************** struct Touchpad *******************************/
#undef None

struct Touchpad
{
    enum Driver { None, LibInput, Synaptics };

    bool valid = false;
    unsigned int id;
    TQCString name;
    Driver driver = Touchpad::Driver::None;

    void init(unsigned int _id, TQCString _name)
    {
        valid = true;
        id = _id;
        name = _name;
    }
};


/***************************** TouchpadSettings *******************************/
class TouchpadSettings
{
    public:
        TouchpadSettings();

        void load(bool defaults = false);
        void save();
        void apply(bool force = false);

        TQValueList<bool> getScrollMethodsAvailability();
        TQValueList<bool> getAccelProfilesAvailability();

        bool enabled, tapClick, tapDrag, tapDragLock, tapMapping, offWhileTyping,
             leftHandedMode, midButtonEmulation, naturalScroll, scrollMethod;
        int scrollDirections, naturalScrollDirections;

        int accelSpeed, accelProfile;

        bool foundTouchpad();
        Touchpad touchpad();

        // Enable/disable touchpad without applying all settings
        bool setTouchpadEnabled(bool on);

        bool supportedTouchpad();

    protected:
        bool findTouchpad();

    private:
        Touchpad m_touchpad;
        bool m_foundTouchpad;
};

#endif // __TOUCHPAD_SETTINGS_H__