File indexing completed on 2024-05-12 17:07:30

0001 /*
0002     SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>
0003     SPDX-FileCopyrightText: 2013 Alexander Mezin <mezin.alexander@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include <QObject>
0011 #include <QVariantHash>
0012 #include <QVector>
0013 
0014 enum class TouchpadInputBackendMode {
0015     Unset = 0,
0016     WaylandLibinput = 1,
0017     XLibinput = 2,
0018     XSynaptics = 3,
0019 };
0020 
0021 void touchpadApplySavedConfig();
0022 
0023 class Q_DECL_EXPORT TouchpadBackend : public QObject
0024 {
0025     Q_OBJECT
0026 
0027 protected:
0028     explicit TouchpadBackend(QObject *parent)
0029         : QObject(parent)
0030         , m_mode(TouchpadInputBackendMode::Unset)
0031     {
0032     }
0033     void setMode(TouchpadInputBackendMode mode);
0034 
0035 public:
0036     static TouchpadBackend *implementation();
0037 
0038     TouchpadInputBackendMode getMode() const
0039     {
0040         return m_mode;
0041     }
0042 
0043     virtual bool applyConfig(const QVariantHash &)
0044     {
0045         return false;
0046     }
0047     virtual bool getConfig(QVariantHash &)
0048     {
0049         return false;
0050     }
0051 
0052     virtual bool applyConfig()
0053     {
0054         return false;
0055     }
0056     virtual bool getConfig()
0057     {
0058         return false;
0059     }
0060     virtual bool getDefaultConfig()
0061     {
0062         return false;
0063     }
0064     virtual bool isChangedConfig() const
0065     {
0066         return false;
0067     }
0068 
0069     virtual QStringList supportedParameters() const
0070     {
0071         return QStringList();
0072     }
0073     virtual QString errorString() const
0074     {
0075         return QString();
0076     }
0077 
0078     virtual QVector<QObject *> getDevices() const
0079     {
0080         return QVector<QObject *>();
0081     }
0082     virtual int touchpadCount() const
0083     {
0084         return 0;
0085     }
0086 
0087     enum TouchpadOffState {
0088         TouchpadEnabled,
0089         TouchpadTapAndScrollDisabled,
0090         TouchpadFullyDisabled,
0091     };
0092     virtual void setTouchpadOff(TouchpadOffState)
0093     {
0094     }
0095     virtual TouchpadOffState getTouchpadOff()
0096     {
0097         return TouchpadFullyDisabled;
0098     }
0099 
0100     virtual bool isTouchpadAvailable()
0101     {
0102         return false;
0103     }
0104     virtual bool isTouchpadEnabled()
0105     {
0106         return false;
0107     }
0108     virtual void setTouchpadEnabled(bool)
0109     {
0110     }
0111 
0112     virtual void watchForEvents(bool /*keyboard*/)
0113     {
0114     }
0115 
0116     virtual QStringList listMouses(const QStringList & /*blacklist*/)
0117     {
0118         return QStringList();
0119     }
0120 
0121 private:
0122     TouchpadInputBackendMode m_mode;
0123 
0124 Q_SIGNALS:
0125     void touchpadStateChanged();
0126     void mousesChanged();
0127     void touchpadReset();
0128     void keyboardActivityStarted();
0129     void keyboardActivityFinished();
0130 
0131     void touchpadAdded(bool success);
0132     void touchpadRemoved(int index);
0133 };