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 <QLoggingCategory>
27#include <QtCore/private/qthread_p.h>
28#include <qpa/qwindowsysteminterface.h>
29#include <QtInputSupport/private/qtouchfilter_p.h>
30
31#if QT_CONFIG(mtdev)
32struct mtdev;
33#endif
34
35QT_BEGIN_NAMESPACE
36
37Q_DECLARE_LOGGING_CATEGORY(qLcEvdevTouch)
38
39class QSocketNotifier;
40class QEvdevTouchScreenData;
41class QPointingDevice;
42
43class QEvdevTouchScreenHandler : public QObject
44{
45 Q_OBJECT
46
47public:
48 explicit QEvdevTouchScreenHandler(const QString &device, const QString &spec = QString(), QObject *parent = nullptr);
49 ~QEvdevTouchScreenHandler();
50
51 QPointingDevice *touchDevice() const;
52
53 bool isFiltered() const;
54
55 void readData();
56
57signals:
58 void touchPointsUpdated();
59
60private:
61 friend class QEvdevTouchScreenData;
62 friend class QEvdevTouchScreenHandlerThread;
63
64 void registerPointingDevice();
65 void unregisterPointingDevice();
66
67 QSocketNotifier *m_notify;
68 int m_fd;
69 QEvdevTouchScreenData *d;
70 QPointingDevice *m_device;
71#if QT_CONFIG(mtdev)
72 mtdev *m_mtdev;
73#endif
74};
75
76class QEvdevTouchScreenHandlerThread : public QDaemonThread
77{
78 Q_OBJECT
79public:
80 explicit QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent = nullptr);
81 ~QEvdevTouchScreenHandlerThread();
82 void run() override;
83
84 bool isPointingDeviceRegistered() const;
85
86 bool eventFilter(QObject *object, QEvent *event) override;
87
88 void scheduleTouchPointUpdate();
89
90signals:
91 void touchDeviceRegistered();
92
93private:
94 Q_INVOKABLE void notifyTouchDeviceRegistered();
95
96 void filterAndSendTouchPoints();
97 QRect targetScreenGeometry() const;
98
99 QString m_device;
100 QString m_spec;
101 QEvdevTouchScreenHandler *m_handler;
102 bool m_touchDeviceRegistered;
103
104 bool m_touchUpdatePending;
105 QWindow *m_filterWindow;
106
107 struct FilteredTouchPoint {
108 QTouchFilter x;
109 QTouchFilter y;
110 QWindowSystemInterface::TouchPoint touchPoint;
111 };
112 QHash<int, FilteredTouchPoint> m_filteredPoints;
113
114 float m_touchRate;
115};
116
117QT_END_NAMESPACE
118
119#endif // QEVDEVTOUCH_P_H
120

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