File indexing completed on 2024-06-16 04:16:24

0001 /*
0002  * SPDX-FileCopyrightText: 2021 Alvin Wong <alvin@alvinhc.com>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #ifndef TOUCH_DOCKER_QQUICKWIDGET_H
0008 #define TOUCH_DOCKER_QQUICKWIDGET_H
0009 
0010 #include <QtQuickWidgets/QQuickWidget>
0011 
0012 /**
0013  * This is a hack on top of QQuickWidget to drop mouse events that might have
0014  * been synthesized by touch events. The aim is to work around a bug in the
0015  * Qt Windows QPA which sometimes misclassifies such events as non-synthesized
0016  * when handling Windows pointer input events.
0017  * 
0018  * See also:
0019  * - https://bugs.kde.org/show_bug.cgi?id=437196
0020  * - https://bugreports.qt.io/browse/QTBUG-95058
0021  */
0022 class TouchDockerQQuickWidget : public QQuickWidget
0023 {
0024     Q_OBJECT
0025 
0026     ulong m_lastTouchEventTimeMills { 0 };
0027     bool m_shouldBlockUntilMouseUp { false };
0028     bool m_shouldBlockNextDblClick { false };
0029 
0030 public:
0031     TouchDockerQQuickWidget(QWidget *parent = nullptr)
0032         : QQuickWidget(parent)
0033     {
0034     }
0035     ~TouchDockerQQuickWidget() override;
0036 
0037     bool event(QEvent *event) override;
0038 };
0039 
0040 #endif // TOUCH_DOCKER_QQUICKWIDGET_H