File indexing completed on 2024-05-12 05:35:53
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 <config-build-options.h> 0011 0012 #include <QList> 0013 #include <QObject> 0014 #include <QVariantHash> 0015 0016 enum class TouchpadInputBackendMode { 0017 Unset = 0, 0018 #if BUILD_KCM_TOUCHPAD_KWIN_WAYLAND 0019 WaylandLibinput = 1, 0020 #endif 0021 #if BUILD_KCM_TOUCHPAD_X11 0022 XLibinput = 2, 0023 #endif 0024 }; 0025 0026 void touchpadApplySavedConfig(); 0027 0028 class Q_DECL_EXPORT TouchpadBackend : public QObject 0029 { 0030 Q_OBJECT 0031 0032 protected: 0033 explicit TouchpadBackend(QObject *parent) 0034 : QObject(parent) 0035 , m_mode(TouchpadInputBackendMode::Unset) 0036 { 0037 } 0038 void setMode(TouchpadInputBackendMode mode); 0039 0040 public: 0041 static TouchpadBackend *implementation(); 0042 0043 TouchpadInputBackendMode getMode() const 0044 { 0045 return m_mode; 0046 } 0047 0048 virtual bool applyConfig(const QVariantHash &) 0049 { 0050 return false; 0051 } 0052 virtual bool getConfig(QVariantHash &) 0053 { 0054 return false; 0055 } 0056 0057 virtual bool applyConfig() 0058 { 0059 return false; 0060 } 0061 virtual bool getConfig() 0062 { 0063 return false; 0064 } 0065 virtual bool getDefaultConfig() 0066 { 0067 return false; 0068 } 0069 virtual bool isChangedConfig() const 0070 { 0071 return false; 0072 } 0073 0074 virtual QStringList supportedParameters() const 0075 { 0076 return QStringList(); 0077 } 0078 virtual QString errorString() const 0079 { 0080 return QString(); 0081 } 0082 0083 virtual QList<QObject *> getDevices() const 0084 { 0085 return QList<QObject *>(); 0086 } 0087 virtual int touchpadCount() const 0088 { 0089 return 0; 0090 } 0091 0092 enum TouchpadOffState { 0093 TouchpadEnabled, 0094 TouchpadTapAndScrollDisabled, 0095 TouchpadFullyDisabled, 0096 }; 0097 virtual void setTouchpadOff(TouchpadOffState) 0098 { 0099 } 0100 virtual TouchpadOffState getTouchpadOff() 0101 { 0102 return TouchpadFullyDisabled; 0103 } 0104 0105 virtual bool isTouchpadAvailable() 0106 { 0107 return false; 0108 } 0109 virtual bool isTouchpadEnabled() 0110 { 0111 return false; 0112 } 0113 virtual void setTouchpadEnabled(bool) 0114 { 0115 } 0116 0117 virtual void watchForEvents(bool /*keyboard*/) 0118 { 0119 } 0120 0121 virtual QStringList listMouses(const QStringList & /*blacklist*/) 0122 { 0123 return QStringList(); 0124 } 0125 0126 private: 0127 TouchpadInputBackendMode m_mode; 0128 0129 Q_SIGNALS: 0130 void touchpadStateChanged(); 0131 void mousesChanged(); 0132 void touchpadReset(); 0133 void keyboardActivityStarted(); 0134 void keyboardActivityFinished(); 0135 0136 void touchpadAdded(bool success); 0137 void touchpadRemoved(int index); 0138 };