File indexing completed on 2024-02-18 16:20:16

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2013, 2016 Martin Gräßlin <mgraesslin@kde.org>
0006     SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 #pragma once
0011 #include "input.h"
0012 
0013 #include <QHash>
0014 #include <QObject>
0015 #include <QPointF>
0016 #include <QPointer>
0017 
0018 namespace KWin
0019 {
0020 
0021 class InputDevice;
0022 class InputRedirection;
0023 class Window;
0024 
0025 namespace Decoration
0026 {
0027 class DecoratedClientImpl;
0028 }
0029 
0030 class KWIN_EXPORT TouchInputRedirection : public InputDeviceHandler
0031 {
0032     Q_OBJECT
0033 public:
0034     explicit TouchInputRedirection(InputRedirection *parent);
0035     ~TouchInputRedirection() override;
0036 
0037     bool positionValid() const override;
0038     bool focusUpdatesBlocked() override;
0039     void init() override;
0040 
0041     void processDown(qint32 id, const QPointF &pos, std::chrono::microseconds time, InputDevice *device = nullptr);
0042     void processUp(qint32 id, std::chrono::microseconds time, InputDevice *device = nullptr);
0043     void processMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time, InputDevice *device = nullptr);
0044     void cancel();
0045     void frame();
0046 
0047     void setDecorationPressId(qint32 id)
0048     {
0049         m_decorationId = id;
0050     }
0051     qint32 decorationPressId() const
0052     {
0053         return m_decorationId;
0054     }
0055     void setInternalPressId(qint32 id)
0056     {
0057         m_internalId = id;
0058     }
0059     qint32 internalPressId() const
0060     {
0061         return m_internalId;
0062     }
0063 
0064     QPointF position() const override
0065     {
0066         return m_lastPosition;
0067     }
0068 
0069     int touchPointCount() const
0070     {
0071         return m_activeTouchPoints.count();
0072     }
0073 
0074 private:
0075     void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) override;
0076 
0077     void focusUpdate(Window *focusOld, Window *focusNow) override;
0078 
0079     QSet<qint32> m_activeTouchPoints;
0080     bool m_inited = false;
0081     qint32 m_decorationId = -1;
0082     qint32 m_internalId = -1;
0083     QMetaObject::Connection m_focusGeometryConnection;
0084     bool m_windowUpdatedInCycle = false;
0085     QPointF m_lastPosition;
0086 };
0087 
0088 }