Commit 4e7c6b57 authored by Bhushan Shah's avatar Bhushan Shah 📱 Committed by Bhushan Shah
Browse files

platforms/drm: put double tap timer behind config option

This feature was implemented in commit a66eb1a5 earlier

Double tap wake up is not a feature to be implemented at compositor
level but rather at the hardware/kernel level. Double tap timer here
means when screen is turned off, libinput will continue to poll the
touchscreen for new events.

double-tap-to-wakeup is generally interrupt at driver/hardware level
which have ability to wake system up even from the sleep.

Provide a option to disable the double tap timer on kwin side for
devices which makes use of suspend since when in suspend kwin can not
wake device up, and that provides confusing user experience.
parent 8cfa3080
......@@ -316,6 +316,9 @@
</group>
<group name="Wayland">
<entry name="InputMethod" type="Path" />
<entry name="DoubleTapWakeup" type="Bool">
<default>true</default>
</entry>
</group>
<group name="Xwayland">
<entry name="XwaylandCrashPolicy" type="Enum">
......
......@@ -9,6 +9,7 @@
#include "drm_inputeventfilter.h"
#include "drm_backend.h"
#include "wayland_server.h"
#include "main.h"
#include <QApplication>
#include <QKeyEvent>
......@@ -22,6 +23,8 @@ DpmsInputEventFilter::DpmsInputEventFilter(DrmBackend *backend)
: InputEventFilter()
, m_backend(backend)
{
KSharedConfig::Ptr kwinSettings = kwinApp()->config();
m_enableDoubleTap = kwinSettings->group("Wayland").readEntry<bool>("DoubleTapWakeup", true);
}
DpmsInputEventFilter::~DpmsInputEventFilter() = default;
......@@ -53,37 +56,41 @@ bool DpmsInputEventFilter::touchDown(qint32 id, const QPointF &pos, quint32 time
{
Q_UNUSED(pos)
Q_UNUSED(time)
if (m_touchPoints.isEmpty()) {
if (!m_doubleTapTimer.isValid()) {
// this is the first tap
m_doubleTapTimer.start();
} else {
if (m_doubleTapTimer.elapsed() < qApp->doubleClickInterval()) {
m_secondTap = true;
if (m_enableDoubleTap) {
if (m_touchPoints.isEmpty()) {
if (!m_doubleTapTimer.isValid()) {
// this is the first tap
m_doubleTapTimer.start();
} else {
// took too long. Let's consider it a new click
m_doubleTapTimer.restart();
if (m_doubleTapTimer.elapsed() < qApp->doubleClickInterval()) {
m_secondTap = true;
} else {
// took too long. Let's consider it a new click
m_doubleTapTimer.restart();
}
}
} else {
// not a double tap
m_doubleTapTimer.invalidate();
m_secondTap = false;
}
} else {
// not a double tap
m_doubleTapTimer.invalidate();
m_secondTap = false;
m_touchPoints << id;
}
m_touchPoints << id;
return true;
}
bool DpmsInputEventFilter::touchUp(qint32 id, quint32 time)
{
m_touchPoints.removeAll(id);
if (m_touchPoints.isEmpty() && m_doubleTapTimer.isValid() && m_secondTap) {
if (m_doubleTapTimer.elapsed() < qApp->doubleClickInterval()) {
waylandServer()->seat()->setTimestamp(time);
notify();
if (m_enableDoubleTap) {
m_touchPoints.removeAll(id);
if (m_touchPoints.isEmpty() && m_doubleTapTimer.isValid() && m_secondTap) {
if (m_doubleTapTimer.elapsed() < qApp->doubleClickInterval()) {
waylandServer()->seat()->setTimestamp(time);
notify();
}
m_doubleTapTimer.invalidate();
m_secondTap = false;
}
m_doubleTapTimer.invalidate();
m_secondTap = false;
}
return true;
}
......
......@@ -36,6 +36,7 @@ private:
QElapsedTimer m_doubleTapTimer;
QVector<qint32> m_touchPoints;
bool m_secondTap = false;
bool m_enableDoubleTap;
};
}
......
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