@@ -14,18 +14,18 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17−#include "HomeKeyWatcher.h"
17+#include "WindowInputMonitor.h"
19#include <QQuickWindow>
19#include <QQuickWindow>
21using namespace UnityUtil;
21using namespace UnityUtil;
23−HomeKeyWatcher::HomeKeyWatcher(QQuickItem *parent)
23+WindowInputMonitor::WindowInputMonitor(QQuickItem *parent)
24− : HomeKeyWatcher(new Timer, new ElapsedTimer, parent)
24+ : WindowInputMonitor(new Timer, new ElapsedTimer, parent)
28−HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
28+WindowInputMonitor::WindowInputMonitor(UnityUtil::AbstractTimer *timer,
29 UnityUtil::AbstractElapsedTimer *elapsedTimer,
29 UnityUtil::AbstractElapsedTimer *elapsedTimer,
30 QQuickItem *parent)
30 QQuickItem *parent)
31 : QQuickItem(parent)
31 : QQuickItem(parent)
@@ -37,20 +37,20 @@ HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
37 m_windowLastTouchedTimer->start();
37 m_windowLastTouchedTimer->start();
39 connect(this, &QQuickItem::windowChanged,
39 connect(this, &QQuickItem::windowChanged,
40− this, &HomeKeyWatcher::setupFilterOnWindow);
40+ this, &WindowInputMonitor::setupFilterOnWindow);
42 connect(m_activationTimer, &UnityUtil::AbstractTimer::timeout,
42 connect(m_activationTimer, &UnityUtil::AbstractTimer::timeout,
43− this, &HomeKeyWatcher::emitActivatedIfNoTouchesAround);
43+ this, &WindowInputMonitor::emitActivatedIfNoTouchesAround);
44 m_activationTimer->setInterval(msecsWithoutTouches);
44 m_activationTimer->setInterval(msecsWithoutTouches);
47−HomeKeyWatcher::~HomeKeyWatcher()
47+WindowInputMonitor::~WindowInputMonitor()
49 delete m_windowLastTouchedTimer;
49 delete m_windowLastTouchedTimer;
50 delete m_activationTimer;
50 delete m_activationTimer;
53−bool HomeKeyWatcher::eventFilter(QObject *watched, QEvent *event)
53+bool WindowInputMonitor::eventFilter(QObject *watched, QEvent *event)
55 Q_ASSERT(!m_filteredWindow.isNull());
55 Q_ASSERT(!m_filteredWindow.isNull());
56 Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data()));
56 Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data()));
@@ -62,7 +62,7 @@ bool HomeKeyWatcher::eventFilter(QObject *watched, QEvent *event)
62 return false;
62 return false;
65−void HomeKeyWatcher::update(QEvent *event)
65+void WindowInputMonitor::update(QEvent *event)
67 if (event->type() == QEvent::KeyPress) {
67 if (event->type() == QEvent::KeyPress) {
68 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
68 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
@@ -86,15 +86,22 @@ void HomeKeyWatcher::update(QEvent *event)
87 m_activationTimer->stop();
87 m_activationTimer->stop();
88 m_windowBeingTouched = true;
88 m_windowBeingTouched = true;
90 } else if (event->type() == QEvent::TouchEnd) {
91 } else if (event->type() == QEvent::TouchEnd) {
92 m_windowBeingTouched = false;
93 m_windowBeingTouched = false;
93 m_windowLastTouchedTimer->start();
94 m_windowLastTouchedTimer->start();
96+ QTouchEvent * touchEv = static_cast<QTouchEvent *>(event);
97+ if (touchEv && !touchEv->touchPoints().isEmpty()) {
98+ const QPointF pos = touchEv->touchPoints().last().screenPos();
99+ Q_EMIT touchEnded(pos);
97−void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
104+void WindowInputMonitor::setupFilterOnWindow(QQuickWindow *window)
99 if (!m_filteredWindow.isNull()) {
106 if (!m_filteredWindow.isNull()) {
100 m_filteredWindow->removeEventFilter(this);
107 m_filteredWindow->removeEventFilter(this);
@@ -107,10 +114,10 @@ void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
110−void HomeKeyWatcher::emitActivatedIfNoTouchesAround()
117+void WindowInputMonitor::emitActivatedIfNoTouchesAround()
112 if (!m_homeKeyPressed && !m_windowBeingTouched &&
119 if (!m_homeKeyPressed && !m_windowBeingTouched &&
113 (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
120 (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
114− Q_EMIT activated();
121+ Q_EMIT homeKeyActivated();