@@ -16,36 +16,34 @@
16 * Author: Daniel d'Andrada <daniel.dandrada@canonical.com>
16 * Author: Daniel d'Andrada <daniel.dandrada@canonical.com>
19−#include "windowkeysfilter.h"
19+#include "windowinputfilter.h"
21#include <QQuickWindow>
21#include <QQuickWindow>
23−WindowKeysFilter::WindowKeysFilter(QQuickItem *parent)
23+WindowInputFilter::WindowInputFilter(QQuickItem *parent)
24 : QQuickItem(parent),
24 : QQuickItem(parent),
25− m_currentEventTimestamp(0)
25+ m_lastInputTimestamp(0)
27 connect(this, &QQuickItem::windowChanged,
27 connect(this, &QQuickItem::windowChanged,
28− this, &WindowKeysFilter::setupFilterOnWindow);
28+ this, &WindowInputFilter::setupFilterOnWindow);
31−bool WindowKeysFilter::eventFilter(QObject *watched, QEvent *event)
31+bool WindowInputFilter::eventFilter(QObject *watched, QEvent *event)
33 Q_ASSERT(!m_filteredWindow.isNull());
33 Q_ASSERT(!m_filteredWindow.isNull());
34 Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data()));
34 Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data()));
35 Q_UNUSED(watched);
35 Q_UNUSED(watched);
37+ QInputEvent *inputEvent = dynamic_cast<QInputEvent*>(event);
39+ m_lastInputTimestamp = inputEvent->timestamp();
40+ Q_EMIT lastInputTimestampChanged();
37 if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
43 if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
38 // Let QML see this event and decide if it does not want it
44 // Let QML see this event and decide if it does not want it
39 event->accept();
45 event->accept();
41− m_currentEventTimestamp = static_cast<QInputEvent*>(event)->timestamp();
42− Q_EMIT currentEventTimestampChanged();
44 QCoreApplication::sendEvent(this, event);
46 QCoreApplication::sendEvent(this, event);
46− m_currentEventTimestamp = 0;
47− Q_EMIT currentEventTimestampChanged();
49 return event->isAccepted();
47 return event->isAccepted();
51 // Not interested
49 // Not interested
@@ -53,7 +51,7 @@ bool WindowKeysFilter::eventFilter(QObject *watched, QEvent *event)
56−void WindowKeysFilter::setupFilterOnWindow(QQuickWindow *window)
54+void WindowInputFilter::setupFilterOnWindow(QQuickWindow *window)
58 if (!m_filteredWindow.isNull()) {
56 if (!m_filteredWindow.isNull()) {
59 m_filteredWindow->removeEventFilter(this);
57 m_filteredWindow->removeEventFilter(this);
@@ -66,7 +64,7 @@ void WindowKeysFilter::setupFilterOnWindow(QQuickWindow *window)
69−ulong WindowKeysFilter::currentEventTimestamp() const
67+ulong WindowInputFilter::lastInputTimestamp() const
71− return m_currentEventTimestamp;
69+ return m_lastInputTimestamp;