File indexing completed on 2024-04-28 05:30:31

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
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 class Window;
0021 class TabletToolId;
0022 
0023 namespace Decoration
0024 {
0025 class DecoratedClientImpl;
0026 }
0027 
0028 namespace LibInput
0029 {
0030 class Device;
0031 }
0032 
0033 class TabletInputRedirection : public InputDeviceHandler
0034 {
0035     Q_OBJECT
0036 public:
0037     explicit TabletInputRedirection(InputRedirection *parent);
0038     ~TabletInputRedirection() override;
0039 
0040     void tabletPad();
0041     bool focusUpdatesBlocked() override;
0042 
0043     void tabletToolEvent(KWin::InputRedirection::TabletEventType type, const QPointF &pos,
0044                          qreal pressure, int xTilt, int yTilt, qreal rotation, bool tipDown,
0045                          bool tipNear, const TabletToolId &tabletToolId,
0046                          std::chrono::microseconds time);
0047     void tabletToolButtonEvent(uint button, bool isPressed, const TabletToolId &tabletToolId, std::chrono::microseconds time);
0048 
0049     void tabletPadButtonEvent(uint button, bool isPressed, const TabletPadId &tabletPadId, std::chrono::microseconds time);
0050     void tabletPadStripEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId, std::chrono::microseconds time);
0051     void tabletPadRingEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId, std::chrono::microseconds time);
0052 
0053     bool positionValid() const override
0054     {
0055         return !m_lastPosition.isNull();
0056     }
0057     void init() override;
0058 
0059     QPointF position() const override
0060     {
0061         return m_lastPosition;
0062     }
0063 
0064 private:
0065     void cleanupDecoration(Decoration::DecoratedClientImpl *old,
0066                            Decoration::DecoratedClientImpl *now) override;
0067     void focusUpdate(Window *focusOld, Window *focusNow) override;
0068 
0069     bool m_tipDown = false;
0070     bool m_tipNear = false;
0071 
0072     QPointF m_lastPosition;
0073     QMetaObject::Connection m_decorationGeometryConnection;
0074     QMetaObject::Connection m_decorationDestroyedConnection;
0075 };
0076 
0077 }