@@ -14,18 +14,18 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−#include "HomeKeyWatcher.h"
17+#include "WindowInputMonitor.h"
1818
1919#include <QQuickWindow>
2020
2121using namespace UnityUtil;
2222
23−HomeKeyWatcher::HomeKeyWatcher(QQuickItem *parent)
24− : HomeKeyWatcher(new Timer, new ElapsedTimer, parent)
23+WindowInputMonitor::WindowInputMonitor(QQuickItem *parent)
24+ : WindowInputMonitor(new Timer, new ElapsedTimer, parent)
2525{
2626}
2727
28−HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
28+WindowInputMonitor::WindowInputMonitor(UnityUtil::AbstractTimer *timer,
2929 UnityUtil::AbstractElapsedTimer *elapsedTimer,
3030 QQuickItem *parent)
3131 : QQuickItem(parent)
@@ -37,20 +37,20 @@ HomeKeyWatcher::HomeKeyWatcher(UnityUtil::AbstractTimer *timer,
3737 m_windowLastTouchedTimer->start();
3838
3939 connect(this, &QQuickItem::windowChanged,
40− this, &HomeKeyWatcher::setupFilterOnWindow);
40+ this, &WindowInputMonitor::setupFilterOnWindow);
4141
4242 connect(m_activationTimer, &UnityUtil::AbstractTimer::timeout,
43− this, &HomeKeyWatcher::emitActivatedIfNoTouchesAround);
43+ this, &WindowInputMonitor::emitActivatedIfNoTouchesAround);
4444 m_activationTimer->setInterval(msecsWithoutTouches);
4545}
4646
47−HomeKeyWatcher::~HomeKeyWatcher()
47+WindowInputMonitor::~WindowInputMonitor()
4848{
4949 delete m_windowLastTouchedTimer;
5050 delete m_activationTimer;
5151}
5252
53−bool HomeKeyWatcher::eventFilter(QObject *watched, QEvent *event)
53+bool WindowInputMonitor::eventFilter(QObject *watched, QEvent *event)
5454{
5555 Q_ASSERT(!m_filteredWindow.isNull());
5656 Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data()));
@@ -62,7 +62,7 @@ bool HomeKeyWatcher::eventFilter(QObject *watched, QEvent *event)
6262 return false;
6363}
6464
65−void HomeKeyWatcher::update(QEvent *event)
65+void WindowInputMonitor::update(QEvent *event)
6666{
6767 if (event->type() == QEvent::KeyPress) {
6868 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
@@ -86,15 +86,22 @@ void HomeKeyWatcher::update(QEvent *event)
8686
8787 m_activationTimer->stop();
8888 m_windowBeingTouched = true;
89+ Q_EMIT touchBegun();
8990
9091 } else if (event->type() == QEvent::TouchEnd) {
9192
9293 m_windowBeingTouched = false;
9394 m_windowLastTouchedTimer->start();
95+
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);
100+ }
94101 }
95102}
96103
97−void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
104+void WindowInputMonitor::setupFilterOnWindow(QQuickWindow *window)
98105{
99106 if (!m_filteredWindow.isNull()) {
100107 m_filteredWindow->removeEventFilter(this);
@@ -107,10 +114,10 @@ void HomeKeyWatcher::setupFilterOnWindow(QQuickWindow *window)
107114 }
108115}
109116
110−void HomeKeyWatcher::emitActivatedIfNoTouchesAround()
117+void WindowInputMonitor::emitActivatedIfNoTouchesAround()
111118{
112119 if (!m_homeKeyPressed && !m_windowBeingTouched &&
113120 (m_windowLastTouchedTimer->elapsed() > msecsWithoutTouches)) {
114− Q_EMIT activated();
121+ Q_EMIT homeKeyActivated();
115122 }
116123}