Unity 8
WindowInputMonitor.h
1 /*
2  * Copyright (C) 2015 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef UNITY_WINDOWINPUTMONITOR_H
18 #define UNITY_WINDOWINPUTMONITOR_H
19 
20 #include <QQuickItem>
21 #include <QPointer>
22 
23 #include "Timer.h"
24 #include "ElapsedTimer.h"
25 
33 class WindowInputMonitor : public QQuickItem
34 {
35  Q_OBJECT
36 public:
37 
38  WindowInputMonitor(QQuickItem *parent = 0);
39 
40  // for testing
42  UnityUtil::AbstractElapsedTimer *elapsedTimer,
43  QQuickItem *parent = 0);
44 
45  virtual ~WindowInputMonitor();
46 
47  bool eventFilter(QObject *watched, QEvent *event) override;
48 
49  void update(QEvent *event);
50 
51  const qint64 msecsWithoutTouches = 150;
52 
53 Q_SIGNALS:
66  void homeKeyActivated();
67 
71  void touchBegun();
72 
77  void touchEnded(const QPointF &pos);
78 
79 private Q_SLOTS:
80  void setupFilterOnWindow(QQuickWindow *window);
81  void emitActivatedIfNoTouchesAround();
82 
83 private:
84  QPointer<QQuickWindow> m_filteredWindow;
85  bool m_windowBeingTouched;
86  bool m_homeKeyPressed;
87  UnityUtil::AbstractElapsedTimer *m_windowLastTouchedTimer;
88  UnityUtil::AbstractTimer *m_activationTimer;
89 };
90 
91 #endif // UNITY_WINDOWINPUTMONITOR_H
void touchEnded(const QPointF &pos)