Lomiri
Loading...
Searching...
No Matches
WindowInputMonitor.h
1/*
2 * Copyright (C) 2015-2016 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 LOMIRI_WINDOWINPUTMONITOR_H
18#define LOMIRI_WINDOWINPUTMONITOR_H
19
20#include <QQuickItem>
21#include <QList>
22#include <QPointer>
23
24#include "Timer.h"
25#include "ElapsedTimer.h"
26
34class WindowInputMonitor : public QQuickItem
35{
36 Q_OBJECT
37public:
38
39 WindowInputMonitor(QQuickItem *parent = 0);
40
41 // for testing
44 QQuickItem *parent = 0);
45
46 virtual ~WindowInputMonitor();
47
48 bool eventFilter(QObject *watched, QEvent *event) override;
49
50 void update(QEvent *event);
51
52 const qint64 msecsWithoutTouches = 150;
53
54Q_SIGNALS:
68
72 void touchBegun();
73
78 void touchEnded(const QPointF &pos);
79
80private Q_SLOTS:
81 void setupFilterOnWindow(QQuickWindow *window);
82 void emitActivatedIfNoTouchesAround();
83
84private:
85 QPointer<QQuickWindow> m_filteredWindow;
86 bool m_windowBeingTouched;
87 LomiriUtil::AbstractElapsedTimer *m_windowLastTouchedTimer;
88 LomiriUtil::AbstractTimer *m_activationTimer;
89
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.
93 // 0 if none
94 int m_pressedHomeKey{0};
95};
96
97#endif // LOMIRI_WINDOWINPUTMONITOR_H
void touchEnded(const QPointF &pos)