[backends/drm] Double Tap to enable output
If the output is off a double tap (touch) can re-enable it. The two taps have to happen in the double click interval (we don't have something better and it kind of matches) and have to be by only one touch point. If there are multiple touch points it's not considered as a double tap. A todo is to restrict the possible distance of the two taps to one thumb. Tested-By: Marco Martin
This commit is contained in:
parent
5b1eb584d6
commit
a66eb1a5b9
2 changed files with 55 additions and 0 deletions
|
@ -93,6 +93,54 @@ bool DpmsInputEventFilter::keyEvent(QKeyEvent *event)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DpmsInputEventFilter::touchDown(quint32 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;
|
||||
} 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;
|
||||
}
|
||||
m_touchPoints << id;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DpmsInputEventFilter::touchUp(quint32 id, quint32 time)
|
||||
{
|
||||
Q_UNUSED(time)
|
||||
m_touchPoints.removeAll(id);
|
||||
if (m_touchPoints.isEmpty() && m_doubleTapTimer.isValid() && m_secondTap) {
|
||||
if (m_doubleTapTimer.elapsed() < qApp->doubleClickInterval()) {
|
||||
notify();
|
||||
}
|
||||
m_doubleTapTimer.invalidate();
|
||||
m_secondTap = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DpmsInputEventFilter::touchMotion(quint32 id, const QPointF &pos, quint32 time)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
Q_UNUSED(pos)
|
||||
Q_UNUSED(time)
|
||||
// ignore the event
|
||||
return true;
|
||||
}
|
||||
|
||||
void DpmsInputEventFilter::notify()
|
||||
{
|
||||
// queued to not modify the list of event filters while filtering
|
||||
|
|
|
@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "abstract_backend.h"
|
||||
#include "input.h"
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QImage>
|
||||
#include <QPointer>
|
||||
#include <QSize>
|
||||
|
@ -261,10 +262,16 @@ public:
|
|||
bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override;
|
||||
bool wheelEvent(QWheelEvent *event) override;
|
||||
bool keyEvent(QKeyEvent *event) override;
|
||||
bool touchDown(quint32 id, const QPointF &pos, quint32 time) override;
|
||||
bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override;
|
||||
bool touchUp(quint32 id, quint32 time) override;
|
||||
|
||||
private:
|
||||
void notify();
|
||||
DrmBackend *m_backend;
|
||||
QElapsedTimer m_doubleTapTimer;
|
||||
QVector<qint32> m_touchPoints;
|
||||
bool m_secondTap = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue