2 * Copyright (C) 2015-2016 Canonical, Ltd.
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.
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.
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/>.
17#ifndef UNITY_WINDOWINPUTMONITOR_H
18#define UNITY_WINDOWINPUTMONITOR_H
25#include "ElapsedTimer.h"
28 * Monitors input events received by the window holding this item and the Home (Win aka Super_L)
31 * Additionally, this class monitors for generic touch events on the screen, to
32 * help with hiding/revealing the mouse pointer.
34class WindowInputMonitor : public QQuickItem
39 WindowInputMonitor(QQuickItem *parent = 0);
42 WindowInputMonitor(UnityUtil::AbstractTimer *timer,
43 UnityUtil::AbstractElapsedTimer *elapsedTimer,
44 QQuickItem *parent = 0);
46 virtual ~WindowInputMonitor();
48 bool eventFilter(QObject *watched, QEvent *event) override;
50 void update(QEvent *event);
52 const qint64 msecsWithoutTouches = 150;
56 * Emitted when the home key has been intentionally tapped
58 * It only says the home key has been activated if it has been tapped in isolation,
59 * that is, without being accompanied by touches on the screen. Home key taps that
60 * happen along with (or immediately after, or immediately before) touches on the
61 * screen are considered to have happened unintentionally and are thus ignored.
63 * Rationale being that it's easy to accidentally hit the home key while performing
64 * a swipe from a screen edge, for instance. That's particularly the case when the
65 * home key is a capacitive key.
67 void homeKeyActivated();
70 * Emitted when a touch begin event is detected
75 * Emitted when a touch end event is detected
76 * @param pos the position in screen coordinates
78 void touchEnded(const QPointF &pos);
81 void setupFilterOnWindow(QQuickWindow *window);
82 void emitActivatedIfNoTouchesAround();
85 QPointer<QQuickWindow> m_filteredWindow;
86 bool m_windowBeingTouched;
87 UnityUtil::AbstractElapsedTimer *m_windowLastTouchedTimer;
88 UnityUtil::AbstractTimer *m_activationTimer;
90 // Qt::Keys that are mapped to our "home" key.
91 QList<int> m_homeKeys{Qt::Key_Super_L, Qt::Key_HomePage};
92 // Which Qt::Key from m_homeKeys is currently pressed.
94 int m_pressedHomeKey{0};
97#endif // UNITY_WINDOWINPUTMONITOR_H
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list