mirror of https://github.com/cutefishos/settings
Move the mouse interface to settings daemon
parent
9601a2ccc2
commit
dff1ce1d84
@ -1,241 +0,0 @@
|
|||||||
/*
|
|
||||||
SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
#include "inputdummydevice.h"
|
|
||||||
#include "libinputsettings.h"
|
|
||||||
#include <QDebug>
|
|
||||||
#include <libinput-properties.h>
|
|
||||||
|
|
||||||
#include <X11/Xatom.h>
|
|
||||||
#include <X11/extensions/XInput.h>
|
|
||||||
#include <X11/extensions/XInput2.h>
|
|
||||||
|
|
||||||
static Atom s_touchpadAtom;
|
|
||||||
|
|
||||||
template<typename Callback>
|
|
||||||
static void XIForallPointerDevices(Display *dpy, const Callback &callback)
|
|
||||||
{
|
|
||||||
int ndevices_return;
|
|
||||||
XDeviceInfo *info = XListInputDevices(dpy, &ndevices_return);
|
|
||||||
if (!info) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < ndevices_return; ++i) {
|
|
||||||
XDeviceInfo *dev = info + i;
|
|
||||||
if ((dev->use == IsXPointer || dev->use == IsXExtensionPointer) && dev->type != s_touchpadAtom) {
|
|
||||||
callback(dev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
XFreeDeviceList(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ScopedXDeleter {
|
|
||||||
static inline void cleanup(void *pointer)
|
|
||||||
{
|
|
||||||
if (pointer) {
|
|
||||||
XFree(pointer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
template<typename T>
|
|
||||||
void valueWriterPart(T val, Atom valAtom, Display *dpy)
|
|
||||||
{
|
|
||||||
Q_UNUSED(val);
|
|
||||||
Q_UNUSED(valAtom);
|
|
||||||
Q_UNUSED(dpy);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void valueWriterPart<bool>(bool val, Atom valAtom, Display *dpy)
|
|
||||||
{
|
|
||||||
XIForallPointerDevices(dpy, [&](XDeviceInfo *info) {
|
|
||||||
int deviceid = info->id;
|
|
||||||
Status status;
|
|
||||||
Atom type_return;
|
|
||||||
int format_return;
|
|
||||||
unsigned long num_items_return;
|
|
||||||
unsigned long bytes_after_return;
|
|
||||||
|
|
||||||
unsigned char *_data = nullptr;
|
|
||||||
// data returned is an 1 byte boolean
|
|
||||||
status = XIGetProperty(dpy, deviceid, valAtom, 0, 1, False, XA_INTEGER, &type_return, &format_return, &num_items_return, &bytes_after_return, &_data);
|
|
||||||
if (status != Success) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QScopedArrayPointer<unsigned char, ScopedXDeleter> data(_data);
|
|
||||||
_data = nullptr;
|
|
||||||
|
|
||||||
if (type_return != XA_INTEGER || !data || format_return != 8) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char sendVal[2] = {0};
|
|
||||||
if (num_items_return == 1) {
|
|
||||||
sendVal[0] = val;
|
|
||||||
} else {
|
|
||||||
// Special case for acceleration profile.
|
|
||||||
const Atom accel = XInternAtom(dpy, LIBINPUT_PROP_ACCEL_PROFILE_ENABLED, True);
|
|
||||||
if (num_items_return != 2 || valAtom != accel) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sendVal[val] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
XIChangeProperty(dpy, deviceid, valAtom, XA_INTEGER, 8, XIPropModeReplace, sendVal, num_items_return);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void valueWriterPart<qreal>(qreal val, Atom valAtom, Display *dpy)
|
|
||||||
{
|
|
||||||
XIForallPointerDevices(dpy, [&](XDeviceInfo *info) {
|
|
||||||
int deviceid = info->id;
|
|
||||||
Status status;
|
|
||||||
Atom float_type = XInternAtom(dpy, "FLOAT", False);
|
|
||||||
Atom type_return;
|
|
||||||
int format_return;
|
|
||||||
unsigned long num_items_return;
|
|
||||||
unsigned long bytes_after_return;
|
|
||||||
|
|
||||||
unsigned char *_data = nullptr;
|
|
||||||
// data returned is an 1 byte boolean
|
|
||||||
status = XIGetProperty(dpy, deviceid, valAtom, 0, 1, False, float_type, &type_return, &format_return, &num_items_return, &bytes_after_return, &_data);
|
|
||||||
if (status != Success) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QScopedArrayPointer<unsigned char, ScopedXDeleter> data(_data);
|
|
||||||
_data = nullptr;
|
|
||||||
|
|
||||||
if (type_return != float_type || !data || format_return != 32 || num_items_return != 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char buffer[4096];
|
|
||||||
float *sendPtr = (float *)buffer;
|
|
||||||
*sendPtr = val;
|
|
||||||
|
|
||||||
XIChangeProperty(dpy, deviceid, valAtom, float_type, format_return, XIPropModeReplace, buffer, 1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
X11LibinputDummyDevice::X11LibinputDummyDevice(QObject *parent, Display *dpy)
|
|
||||||
: QObject(parent)
|
|
||||||
, m_settings(new LibinputSettings())
|
|
||||||
, m_dpy(dpy)
|
|
||||||
{
|
|
||||||
m_leftHanded.atom = XInternAtom(dpy, LIBINPUT_PROP_LEFT_HANDED, True);
|
|
||||||
m_middleEmulation.atom = XInternAtom(dpy, LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED, True);
|
|
||||||
m_naturalScroll.atom = XInternAtom(dpy, LIBINPUT_PROP_NATURAL_SCROLL, True);
|
|
||||||
m_pointerAcceleration.atom = XInternAtom(dpy, LIBINPUT_PROP_ACCEL, True);
|
|
||||||
m_pointerAccelerationProfileFlat.atom = XInternAtom(dpy, LIBINPUT_PROP_ACCEL_PROFILE_ENABLED, True);
|
|
||||||
|
|
||||||
m_supportsDisableEvents.val = false;
|
|
||||||
m_enabled.val = true;
|
|
||||||
m_supportedButtons.val = Qt::LeftButton | Qt::MiddleButton | Qt::RightButton;
|
|
||||||
m_supportsLeftHanded.val = true;
|
|
||||||
m_supportsMiddleEmulation.val = true;
|
|
||||||
m_middleEmulationEnabledByDefault.val = false;
|
|
||||||
|
|
||||||
m_supportsPointerAcceleration.val = true;
|
|
||||||
m_defaultPointerAcceleration.val = 0;
|
|
||||||
|
|
||||||
m_supportsPointerAccelerationProfileAdaptive.val = true;
|
|
||||||
m_supportsPointerAccelerationProfileFlat.val = true;
|
|
||||||
|
|
||||||
m_defaultPointerAccelerationProfileAdaptive.val = true;
|
|
||||||
m_defaultPointerAccelerationProfileFlat.val = false;
|
|
||||||
|
|
||||||
m_supportsNaturalScroll.val = true;
|
|
||||||
m_naturalScrollEnabledByDefault.val = false;
|
|
||||||
|
|
||||||
s_touchpadAtom = XInternAtom(m_dpy, XI_TOUCHPAD, True);
|
|
||||||
|
|
||||||
// Init
|
|
||||||
getConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
X11LibinputDummyDevice::~X11LibinputDummyDevice()
|
|
||||||
{
|
|
||||||
delete m_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool X11LibinputDummyDevice::getConfig()
|
|
||||||
{
|
|
||||||
auto reset = [this](Prop<bool> &prop, bool defVal) {
|
|
||||||
prop.reset(m_settings->load(prop.cfgName, defVal));
|
|
||||||
};
|
|
||||||
|
|
||||||
reset(m_leftHanded, false);
|
|
||||||
|
|
||||||
reset(m_middleEmulation, false);
|
|
||||||
reset(m_naturalScroll, false);
|
|
||||||
reset(m_pointerAccelerationProfileFlat, false);
|
|
||||||
|
|
||||||
m_pointerAccelerationProfileAdaptive.reset(!m_settings->load(m_pointerAccelerationProfileFlat.cfgName, false));
|
|
||||||
m_pointerAcceleration.reset(m_settings->load(m_pointerAcceleration.cfgName, 0.));
|
|
||||||
|
|
||||||
emit leftHandedChanged();
|
|
||||||
emit naturalScrollChanged();
|
|
||||||
emit pointerAccelerationProfileChanged();
|
|
||||||
emit pointerAccelerationChanged();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool X11LibinputDummyDevice::getDefaultConfig()
|
|
||||||
{
|
|
||||||
m_leftHanded.set(false);
|
|
||||||
|
|
||||||
m_pointerAcceleration.set(m_defaultPointerAcceleration);
|
|
||||||
m_pointerAccelerationProfileFlat.set(m_defaultPointerAccelerationProfileFlat);
|
|
||||||
m_pointerAccelerationProfileAdaptive.set(m_defaultPointerAccelerationProfileAdaptive);
|
|
||||||
|
|
||||||
m_middleEmulation.set(m_middleEmulationEnabledByDefault);
|
|
||||||
m_naturalScroll.set(m_naturalScrollEnabledByDefault);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool X11LibinputDummyDevice::applyConfig()
|
|
||||||
{
|
|
||||||
valueWriter(m_leftHanded);
|
|
||||||
valueWriter(m_middleEmulation);
|
|
||||||
valueWriter(m_naturalScroll);
|
|
||||||
valueWriter(m_pointerAcceleration);
|
|
||||||
valueWriter(m_pointerAccelerationProfileFlat);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
bool X11LibinputDummyDevice::valueWriter(Prop<T> &prop)
|
|
||||||
{
|
|
||||||
// Check atom availability first.
|
|
||||||
if (prop.atom == None) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prop.val != prop.old) {
|
|
||||||
m_settings->save(prop.cfgName, prop.val);
|
|
||||||
}
|
|
||||||
|
|
||||||
valueWriterPart(prop.val, prop.atom, m_dpy);
|
|
||||||
|
|
||||||
prop.old = prop.val;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool X11LibinputDummyDevice::isChangedConfig() const
|
|
||||||
{
|
|
||||||
return m_leftHanded.changed() || m_pointerAcceleration.changed() || m_pointerAccelerationProfileFlat.changed()
|
|
||||||
|| m_pointerAccelerationProfileAdaptive.changed() || m_middleEmulation.changed() || m_naturalScroll.changed();
|
|
||||||
}
|
|
||||||
@ -1,297 +0,0 @@
|
|||||||
/*
|
|
||||||
SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef X11LIBINPUTDUMMYDEVICE_H
|
|
||||||
#define X11LIBINPUTDUMMYDEVICE_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QString>
|
|
||||||
#include <QX11Info>
|
|
||||||
|
|
||||||
#include <X11/Xdefs.h>
|
|
||||||
|
|
||||||
struct LibinputSettings;
|
|
||||||
|
|
||||||
class X11LibinputDummyDevice : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
//
|
|
||||||
// general
|
|
||||||
Q_PROPERTY(QString name READ name CONSTANT)
|
|
||||||
Q_PROPERTY(bool supportsDisableEvents READ supportsDisableEvents CONSTANT)
|
|
||||||
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
|
|
||||||
|
|
||||||
//
|
|
||||||
// advanced
|
|
||||||
Q_PROPERTY(Qt::MouseButtons supportedButtons READ supportedButtons CONSTANT)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool supportsLeftHanded READ supportsLeftHanded CONSTANT)
|
|
||||||
Q_PROPERTY(bool leftHandedEnabledByDefault READ leftHandedEnabledByDefault CONSTANT)
|
|
||||||
Q_PROPERTY(bool leftHanded READ isLeftHanded WRITE setLeftHanded NOTIFY leftHandedChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool supportsMiddleEmulation READ supportsMiddleEmulation CONSTANT)
|
|
||||||
Q_PROPERTY(bool middleEmulationEnabledByDefault READ middleEmulationEnabledByDefault CONSTANT)
|
|
||||||
Q_PROPERTY(bool middleEmulation READ isMiddleEmulation WRITE setMiddleEmulation NOTIFY middleEmulationChanged)
|
|
||||||
|
|
||||||
//
|
|
||||||
// acceleration speed and profile
|
|
||||||
Q_PROPERTY(bool supportsPointerAcceleration READ supportsPointerAcceleration CONSTANT)
|
|
||||||
Q_PROPERTY(qreal pointerAcceleration READ pointerAcceleration WRITE setPointerAcceleration NOTIFY pointerAccelerationChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool supportsPointerAccelerationProfileFlat READ supportsPointerAccelerationProfileFlat CONSTANT)
|
|
||||||
Q_PROPERTY(bool defaultPointerAccelerationProfileFlat READ defaultPointerAccelerationProfileFlat CONSTANT)
|
|
||||||
Q_PROPERTY(bool pointerAccelerationProfileFlat READ pointerAccelerationProfileFlat WRITE setPointerAccelerationProfileFlat NOTIFY
|
|
||||||
pointerAccelerationProfileChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool supportsPointerAccelerationProfileAdaptive READ supportsPointerAccelerationProfileAdaptive CONSTANT)
|
|
||||||
Q_PROPERTY(bool defaultPointerAccelerationProfileAdaptive READ defaultPointerAccelerationProfileAdaptive CONSTANT)
|
|
||||||
Q_PROPERTY(bool pointerAccelerationProfileAdaptive READ pointerAccelerationProfileAdaptive WRITE setPointerAccelerationProfileAdaptive NOTIFY
|
|
||||||
pointerAccelerationProfileChanged)
|
|
||||||
|
|
||||||
//
|
|
||||||
// scrolling
|
|
||||||
Q_PROPERTY(bool supportsNaturalScroll READ supportsNaturalScroll CONSTANT)
|
|
||||||
Q_PROPERTY(bool naturalScrollEnabledByDefault READ naturalScrollEnabledByDefault CONSTANT)
|
|
||||||
Q_PROPERTY(bool naturalScroll READ isNaturalScroll WRITE setNaturalScroll NOTIFY naturalScrollChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
X11LibinputDummyDevice(QObject *parent, Display *dpy);
|
|
||||||
~X11LibinputDummyDevice() override;
|
|
||||||
|
|
||||||
bool getConfig();
|
|
||||||
bool getDefaultConfig();
|
|
||||||
bool applyConfig();
|
|
||||||
bool isChangedConfig() const;
|
|
||||||
|
|
||||||
//
|
|
||||||
// general
|
|
||||||
QString name() const
|
|
||||||
{
|
|
||||||
return m_name.val;
|
|
||||||
}
|
|
||||||
QString sysName() const
|
|
||||||
{
|
|
||||||
return m_sysName.val;
|
|
||||||
}
|
|
||||||
bool supportsDisableEvents() const
|
|
||||||
{
|
|
||||||
return m_supportsDisableEvents.val;
|
|
||||||
}
|
|
||||||
void setEnabled(bool enabled)
|
|
||||||
{
|
|
||||||
m_enabled.set(enabled);
|
|
||||||
}
|
|
||||||
bool isEnabled() const
|
|
||||||
{
|
|
||||||
return m_enabled.val;
|
|
||||||
}
|
|
||||||
Qt::MouseButtons supportedButtons() const
|
|
||||||
{
|
|
||||||
return m_supportedButtons.val;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// advanced
|
|
||||||
bool supportsLeftHanded() const
|
|
||||||
{
|
|
||||||
return m_supportsLeftHanded.val;
|
|
||||||
}
|
|
||||||
bool leftHandedEnabledByDefault() const
|
|
||||||
{
|
|
||||||
return m_leftHandedEnabledByDefault.val;
|
|
||||||
}
|
|
||||||
bool isLeftHanded() const
|
|
||||||
{
|
|
||||||
return m_leftHanded.val;
|
|
||||||
}
|
|
||||||
void setLeftHanded(bool set)
|
|
||||||
{
|
|
||||||
m_leftHanded.set(set);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool supportsMiddleEmulation() const
|
|
||||||
{
|
|
||||||
return m_supportsMiddleEmulation.val;
|
|
||||||
}
|
|
||||||
bool middleEmulationEnabledByDefault() const
|
|
||||||
{
|
|
||||||
return m_middleEmulationEnabledByDefault.val;
|
|
||||||
}
|
|
||||||
bool isMiddleEmulation() const
|
|
||||||
{
|
|
||||||
return m_middleEmulation.val;
|
|
||||||
}
|
|
||||||
void setMiddleEmulation(bool set)
|
|
||||||
{
|
|
||||||
m_middleEmulation.set(set);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// acceleration speed and profile
|
|
||||||
bool supportsPointerAcceleration() const
|
|
||||||
{
|
|
||||||
return m_supportsPointerAcceleration.val;
|
|
||||||
}
|
|
||||||
qreal pointerAcceleration() const
|
|
||||||
{
|
|
||||||
return m_pointerAcceleration.val;
|
|
||||||
}
|
|
||||||
void setPointerAcceleration(qreal acceleration)
|
|
||||||
{
|
|
||||||
m_pointerAcceleration.set(acceleration);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool supportsPointerAccelerationProfileFlat() const
|
|
||||||
{
|
|
||||||
return m_supportsPointerAccelerationProfileFlat.val;
|
|
||||||
}
|
|
||||||
bool defaultPointerAccelerationProfileFlat() const
|
|
||||||
{
|
|
||||||
return m_defaultPointerAccelerationProfileFlat.val;
|
|
||||||
}
|
|
||||||
bool pointerAccelerationProfileFlat() const
|
|
||||||
{
|
|
||||||
return m_pointerAccelerationProfileFlat.val;
|
|
||||||
}
|
|
||||||
void setPointerAccelerationProfileFlat(bool set)
|
|
||||||
{
|
|
||||||
m_pointerAccelerationProfileFlat.set(set);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool supportsPointerAccelerationProfileAdaptive() const
|
|
||||||
{
|
|
||||||
return m_supportsPointerAccelerationProfileAdaptive.val;
|
|
||||||
}
|
|
||||||
bool defaultPointerAccelerationProfileAdaptive() const
|
|
||||||
{
|
|
||||||
return m_defaultPointerAccelerationProfileAdaptive.val;
|
|
||||||
}
|
|
||||||
bool pointerAccelerationProfileAdaptive() const
|
|
||||||
{
|
|
||||||
return m_pointerAccelerationProfileAdaptive.val;
|
|
||||||
}
|
|
||||||
void setPointerAccelerationProfileAdaptive(bool set)
|
|
||||||
{
|
|
||||||
m_pointerAccelerationProfileAdaptive.set(set);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// scrolling
|
|
||||||
bool supportsNaturalScroll() const
|
|
||||||
{
|
|
||||||
return m_supportsNaturalScroll.val;
|
|
||||||
}
|
|
||||||
bool naturalScrollEnabledByDefault() const
|
|
||||||
{
|
|
||||||
return m_naturalScrollEnabledByDefault.val;
|
|
||||||
}
|
|
||||||
bool isNaturalScroll() const
|
|
||||||
{
|
|
||||||
return m_naturalScroll.val;
|
|
||||||
}
|
|
||||||
void setNaturalScroll(bool set)
|
|
||||||
{
|
|
||||||
m_naturalScroll.set(set);
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void leftHandedChanged();
|
|
||||||
void pointerAccelerationChanged();
|
|
||||||
void pointerAccelerationProfileChanged();
|
|
||||||
void enabledChanged();
|
|
||||||
void middleEmulationChanged();
|
|
||||||
void naturalScrollChanged();
|
|
||||||
|
|
||||||
private:
|
|
||||||
template<typename T>
|
|
||||||
struct Prop {
|
|
||||||
explicit Prop(const QString &_name, const QString &_cfgName = "")
|
|
||||||
: name(_name)
|
|
||||||
, cfgName(_cfgName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void set(T newVal)
|
|
||||||
{
|
|
||||||
if (avail && val != newVal) {
|
|
||||||
val = newVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void set(const Prop<T> &p)
|
|
||||||
{
|
|
||||||
if (avail && val != p.val) {
|
|
||||||
val = p.val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool changed() const
|
|
||||||
{
|
|
||||||
return avail && (old != val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset(T newVal)
|
|
||||||
{
|
|
||||||
val = newVal;
|
|
||||||
old = newVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString name;
|
|
||||||
QString cfgName;
|
|
||||||
|
|
||||||
bool avail = true;
|
|
||||||
T old;
|
|
||||||
T val;
|
|
||||||
|
|
||||||
Atom atom;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
bool valueWriter(Prop<T> &prop);
|
|
||||||
|
|
||||||
//
|
|
||||||
// general
|
|
||||||
Prop<QString> m_name = Prop<QString>("name");
|
|
||||||
Prop<QString> m_sysName = Prop<QString>("sysName");
|
|
||||||
Prop<bool> m_supportsDisableEvents = Prop<bool>("supportsDisableEvents");
|
|
||||||
Prop<bool> m_enabled = Prop<bool>("enabled");
|
|
||||||
|
|
||||||
//
|
|
||||||
// advanced
|
|
||||||
Prop<Qt::MouseButtons> m_supportedButtons = Prop<Qt::MouseButtons>("supportedButtons");
|
|
||||||
|
|
||||||
Prop<bool> m_supportsLeftHanded = Prop<bool>("supportsLeftHanded");
|
|
||||||
Prop<bool> m_leftHandedEnabledByDefault = Prop<bool>("leftHandedEnabledByDefault");
|
|
||||||
Prop<bool> m_leftHanded = Prop<bool>("leftHanded", "XLbInptLeftHanded");
|
|
||||||
|
|
||||||
Prop<bool> m_supportsMiddleEmulation = Prop<bool>("supportsMiddleEmulation");
|
|
||||||
Prop<bool> m_middleEmulationEnabledByDefault = Prop<bool>("middleEmulationEnabledByDefault");
|
|
||||||
Prop<bool> m_middleEmulation = Prop<bool>("middleEmulation", "XLbInptMiddleEmulation");
|
|
||||||
|
|
||||||
//
|
|
||||||
// acceleration speed and profile
|
|
||||||
Prop<bool> m_supportsPointerAcceleration = Prop<bool>("supportsPointerAcceleration");
|
|
||||||
Prop<qreal> m_defaultPointerAcceleration = Prop<qreal>("defaultPointerAcceleration");
|
|
||||||
Prop<qreal> m_pointerAcceleration = Prop<qreal>("pointerAcceleration", "XLbInptPointerAcceleration");
|
|
||||||
|
|
||||||
Prop<bool> m_supportsPointerAccelerationProfileFlat = Prop<bool>("supportsPointerAccelerationProfileFlat");
|
|
||||||
Prop<bool> m_defaultPointerAccelerationProfileFlat = Prop<bool>("defaultPointerAccelerationProfileFlat");
|
|
||||||
Prop<bool> m_pointerAccelerationProfileFlat = Prop<bool>("pointerAccelerationProfileFlat", "XLbInptAccelProfileFlat");
|
|
||||||
|
|
||||||
Prop<bool> m_supportsPointerAccelerationProfileAdaptive = Prop<bool>("supportsPointerAccelerationProfileAdaptive");
|
|
||||||
Prop<bool> m_defaultPointerAccelerationProfileAdaptive = Prop<bool>("defaultPointerAccelerationProfileAdaptive");
|
|
||||||
Prop<bool> m_pointerAccelerationProfileAdaptive = Prop<bool>("pointerAccelerationProfileAdaptive");
|
|
||||||
|
|
||||||
//
|
|
||||||
// scrolling
|
|
||||||
Prop<bool> m_supportsNaturalScroll = Prop<bool>("supportsNaturalScroll");
|
|
||||||
Prop<bool> m_naturalScrollEnabledByDefault = Prop<bool>("naturalScrollEnabledByDefault");
|
|
||||||
Prop<bool> m_naturalScroll = Prop<bool>("naturalScroll", "XLbInptNaturalScroll");
|
|
||||||
|
|
||||||
LibinputSettings *m_settings;
|
|
||||||
Display *m_dpy = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // X11LIBINPUTDUMMYDEVICE_H
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
#include "libinputsettings.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
template<>
|
|
||||||
bool LibinputSettings::load(QString key, bool defVal)
|
|
||||||
{
|
|
||||||
QSettings settings("cutefishos", "mouse");
|
|
||||||
return settings.value(key, defVal).toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
qreal LibinputSettings::load(QString key, qreal defVal)
|
|
||||||
{
|
|
||||||
QSettings settings("cutefishos", "mouse");
|
|
||||||
return settings.value(key, defVal).toReal();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void LibinputSettings::save(QString key, bool val)
|
|
||||||
{
|
|
||||||
QSettings settings("cutefishos", "mouse");
|
|
||||||
settings.setValue(key, val);
|
|
||||||
settings.sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void LibinputSettings::save(QString key, qreal val)
|
|
||||||
{
|
|
||||||
QSettings settings("cutefishos", "mouse");
|
|
||||||
settings.setValue(key, val);
|
|
||||||
settings.sync();
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LIBINPUTSETTINGS_H
|
|
||||||
#define LIBINPUTSETTINGS_H
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
struct LibinputSettings {
|
|
||||||
template<class T>
|
|
||||||
T load(QString key, T defVal);
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void save(QString key, T val);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // LIBINPUTSETTINGS_H
|
|
||||||
Loading…
Reference in New Issue