1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QEVDEVTOUCHHANDLER_P_H
6#define QEVDEVTOUCHHANDLER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19//#include <QtGui/qpointingdevice.h>
20#include <QtGui/private/qtguiglobal_p.h>
21#include <QObject>
22#include <QString>
23#include <QList>
24#include <QHash>
25#include <QThread>
26#include <QtCore/private/qthread_p.h>
27#include <qpa/qwindowsysteminterface.h>
28#include "qevdevtouchfilter_p.h"
29
30#if QT_CONFIG(mtdev)
31struct mtdev;
32#endif
33
34QT_BEGIN_NAMESPACE
35
36class QSocketNotifier;
37class QEvdevTouchScreenData;
38class QPointingDevice;
39
40class QEvdevTouchScreenHandler : public QObject
41{
42 Q_OBJECT
43
44public:
45 explicit QEvdevTouchScreenHandler(const QString &device, const QString &spec = QString(), QObject *parent = nullptr);
46 ~QEvdevTouchScreenHandler();
47
48 QPointingDevice *touchDevice() const;
49
50 bool isFiltered() const;
51
52 void readData();
53
54signals:
55 void touchPointsUpdated();
56
57private:
58 friend class QEvdevTouchScreenData;
59 friend class QEvdevTouchScreenHandlerThread;
60
61 void registerPointingDevice();
62 void unregisterPointingDevice();
63
64 QSocketNotifier *m_notify;
65 int m_fd;
66 QEvdevTouchScreenData *d;
67 QPointingDevice *m_device;
68#if QT_CONFIG(mtdev)
69 mtdev *m_mtdev;
70#endif
71};
72
73class QEvdevTouchScreenHandlerThread : public QDaemonThread
74{
75 Q_OBJECT
76public:
77 explicit QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent = nullptr);
78 ~QEvdevTouchScreenHandlerThread();
79 void run() override;
80
81 bool isPointingDeviceRegistered() const;
82
83 bool eventFilter(QObject *object, QEvent *event) override;
84
85 void scheduleTouchPointUpdate();
86
87signals:
88 void touchDeviceRegistered();
89
90private:
91 Q_INVOKABLE void notifyTouchDeviceRegistered();
92
93 void filterAndSendTouchPoints();
94 QRect targetScreenGeometry() const;
95
96 QString m_device;
97 QString m_spec;
98 QEvdevTouchScreenHandler *m_handler;
99 bool m_touchDeviceRegistered;
100
101 bool m_touchUpdatePending;
102 QWindow *m_filterWindow;
103
104 struct FilteredTouchPoint {
105 QEvdevTouchFilter x;
106 QEvdevTouchFilter y;
107 QWindowSystemInterface::TouchPoint touchPoint;
108 };
109 QHash<int, FilteredTouchPoint> m_filteredPoints;
110
111 float m_touchRate;
112};
113
114QT_END_NAMESPACE
115
116#endif // QEVDEVTOUCH_P_H
117

source code of qtbase/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h