diff --git a/kcms/touchpad/src/kcm/touchpadconfigcontainer.cpp b/kcms/touchpad/src/kcm/touchpadconfigcontainer.cpp index 879ef003e..0eb4b55a5 100644 --- a/kcms/touchpad/src/kcm/touchpadconfigcontainer.cpp +++ b/kcms/touchpad/src/kcm/touchpadconfigcontainer.cpp @@ -1,97 +1,100 @@ /* * Copyright 2017 Roman Gilg * * 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 2 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "touchpadconfigcontainer.h" #include "touchpadconfigplugin.h" #include "kcm/libinput/touchpadconfiglibinput.h" #include "kcm/xlib/touchpadconfigxlib.h" #include "touchpadbackend.h" #include extern "C" { Q_DECL_EXPORT void kcminit_touchpad() { if (KWindowSystem::isPlatformX11()) { TouchpadConfigContainer::kcmInit(); } } } TouchpadConfigContainer::TouchpadConfigContainer(QWidget *parent, const QVariantList &args) : KCModule(parent, args) { TouchpadBackend *backend = TouchpadBackend::implementation(); if (KWindowSystem::isPlatformX11()) { if (backend->getMode() == TouchpadInputBackendMode::XLibinput) { m_plugin = new TouchpadConfigLibinput(this, backend); } - else if (backend->getMode() == TouchpadInputBackendMode::XSynaptics) { + // For now, if no touchpad is found, always fall back to synaptics frontend, + // which has a "no touchpad found" message. + // TODO: show a disabled version of the Libinput frontend as appropriate + else { m_plugin = new TouchpadConfigXlib(this, backend); } } else if (KWindowSystem::isPlatformWayland()) { m_plugin = new TouchpadConfigLibinput(this, backend); } } void TouchpadConfigContainer::kcmInit() { TouchpadBackend *backend = TouchpadBackend::implementation(); if (backend->getMode() == TouchpadInputBackendMode::XLibinput) { backend->getConfig(); backend->applyConfig(); } else if (backend->getMode() == TouchpadInputBackendMode::XSynaptics) { TouchpadConfigXlib::kcmInit(); } } QSize TouchpadConfigContainer::minimumSizeHint() const { return m_plugin->minimumSizeHint(); } QSize TouchpadConfigContainer::sizeHint() const { return m_plugin->sizeHint(); } void TouchpadConfigContainer::resizeEvent(QResizeEvent *event) { Q_EMIT changed(false); m_plugin->resize(this->size()); } void TouchpadConfigContainer::load() { m_plugin->load(); } void TouchpadConfigContainer::save() { m_plugin->save(); } void TouchpadConfigContainer::defaults() { m_plugin->defaults(); } void TouchpadConfigContainer::hideEvent(QHideEvent *e) { m_plugin->hideEvent(e); KCModule::hideEvent(e); } diff --git a/kcms/touchpad/src/touchpadbackend.h b/kcms/touchpad/src/touchpadbackend.h index 339826ac0..6ed077c4b 100644 --- a/kcms/touchpad/src/touchpadbackend.h +++ b/kcms/touchpad/src/touchpadbackend.h @@ -1,88 +1,89 @@ /* * Copyright 2017 Roman Gilg * Copyright 2013 Alexander Mezin * * 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 2 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef TOUCHPADBACKEND_H #define TOUCHPADBACKEND_H #include #include #include enum class TouchpadInputBackendMode { - WaylandLibinput = 0, - XLibinput = 1, - XSynaptics = 2 + Unset = 0, + WaylandLibinput = 1, + XLibinput = 2, + XSynaptics = 3 }; class Q_DECL_EXPORT TouchpadBackend : public QObject { Q_OBJECT protected: - explicit TouchpadBackend(QObject *parent) : QObject(parent) {} + explicit TouchpadBackend(QObject *parent) : QObject(parent), m_mode(TouchpadInputBackendMode::Unset) {} void setMode(TouchpadInputBackendMode mode); public: static TouchpadBackend *implementation(); TouchpadInputBackendMode getMode() const {return m_mode;} virtual bool applyConfig(const QVariantHash &) {return false;} virtual bool getConfig(QVariantHash &) {return false;} virtual bool applyConfig() {return false;} virtual bool getConfig() {return false;} virtual bool getDefaultConfig() {return false;} virtual bool isChangedConfig() const {return false;} virtual QStringList supportedParameters() const {return QStringList();} virtual QString errorString() const {return QString();} virtual QVector getDevices() const { return QVector(); } virtual int touchpadCount() const {return 0;} enum TouchpadOffState { TouchpadEnabled, TouchpadTapAndScrollDisabled, TouchpadFullyDisabled }; virtual void setTouchpadOff(TouchpadOffState) {} virtual TouchpadOffState getTouchpadOff() {return TouchpadFullyDisabled;} virtual bool isTouchpadAvailable() {return false;} virtual bool isTouchpadEnabled() {return false;} virtual void setTouchpadEnabled(bool) {} virtual void watchForEvents(bool keyboard) {} virtual QStringList listMouses(const QStringList &blacklist) {return QStringList();} private: TouchpadInputBackendMode m_mode; Q_SIGNALS: void touchpadStateChanged(); void mousesChanged(); void touchpadReset(); void keyboardActivityStarted(); void keyboardActivityFinished(); void touchpadAdded(bool success); void touchpadRemoved(int index); }; #endif // TOUCHPADBACKEND_H