Commit fb8a655a authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

If no config option for accel profile is selected, use default from Xorg

Instead of hardcoding the default, read it from Xorg and use that. This
prevents overriding the value from the default set by the system.
parent 722fd4c8
Pipeline #153245 passed with stage
in 4 minutes and 49 seconds
......@@ -36,6 +36,8 @@ bool X11LibinputBackend::isChangedConfig() const
void X11LibinputBackend::kcmInit()
{
static_cast<X11LibinputDummyDevice *>(m_device)->getDefaultConfigFromX();
getConfig();
applyConfig();
X11Backend::kcmInit();
......
......@@ -150,8 +150,9 @@ X11LibinputDummyDevice::X11LibinputDummyDevice(QObject *parent, Display *dpy)
m_supportsPointerAccelerationProfileAdaptive.val = true;
m_supportsPointerAccelerationProfileFlat.val = true;
m_defaultPointerAccelerationProfileAdaptive.val = true;
m_defaultPointerAccelerationProfileFlat.val = false;
auto x11DefaultFlat = m_settings->load(QStringLiteral("X11LibInputXAccelProfileFlat"), false);
m_defaultPointerAccelerationProfileFlat.val = x11DefaultFlat;
m_defaultPointerAccelerationProfileAdaptive.val = !x11DefaultFlat;
m_supportsNaturalScroll.val = true;
m_naturalScrollEnabledByDefault.val = false;
......@@ -174,9 +175,10 @@ bool X11LibinputDummyDevice::getConfig()
reset(m_middleEmulation, false);
reset(m_naturalScroll, false);
reset(m_pointerAccelerationProfileFlat, false);
auto flatDefault = m_defaultPointerAccelerationProfileFlat.val;
reset(m_pointerAccelerationProfileFlat, flatDefault);
m_pointerAccelerationProfileAdaptive.reset(!m_settings->load(m_pointerAccelerationProfileFlat.cfgName, false));
m_pointerAccelerationProfileAdaptive.reset(!m_settings->load(m_pointerAccelerationProfileFlat.cfgName, flatDefault));
m_pointerAcceleration.reset(m_settings->load(m_pointerAcceleration.cfgName, 0.));
return true;
......@@ -207,6 +209,43 @@ bool X11LibinputDummyDevice::applyConfig()
return true;
}
void X11LibinputDummyDevice::getDefaultConfigFromX()
{
// The user can override certain values in their X configuration. We want to
// account for those in our default values, but if we just read this when
// loading the KCM, we end up reading the current settings which may already
// have been modified by us. So instead, read these defaults during startup
// and write them to config, so we can later on read them again to know the
// system-wide defaults.
bool flatProfile = true;
XIForallPointerDevices(m_dpy, [&](XDeviceInfo *info) {
Atom property = m_pointerAccelerationProfileFlat.atom;
Atom type_return;
int format_return;
unsigned long num_items_return;
unsigned long bytes_after_return;
unsigned char *_data = nullptr;
auto status =
XIGetProperty(m_dpy, info->id, property, 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 || num_items_return != 2) {
return;
}
if (data[0] == 1 && data[1] == 0) {
flatProfile = false;
}
});
m_settings->save(QStringLiteral("X11LibInputXAccelProfileFlat"), flatProfile);
}
template<typename T>
bool X11LibinputDummyDevice::valueWriter(Prop<T> &prop)
{
......
......@@ -67,6 +67,8 @@ public:
bool applyConfig();
bool isChangedConfig() const;
void getDefaultConfigFromX();
//
// general
QString name() const
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment