Warning, file /plasma/kwin/src/plugins/touchpoints/touchpoints.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2012 Filip Wieladek <wattos@gmail.com>
0006     SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #pragma once
0012 
0013 #include "effect/effect.h"
0014 
0015 namespace KWin
0016 {
0017 
0018 class TouchPointsEffect
0019     : public Effect
0020 {
0021     Q_OBJECT
0022     Q_PROPERTY(qreal lineWidth READ lineWidth)
0023     Q_PROPERTY(int ringLife READ ringLife)
0024     Q_PROPERTY(int ringSize READ ringSize)
0025     Q_PROPERTY(int ringCount READ ringCount)
0026 public:
0027     TouchPointsEffect();
0028     ~TouchPointsEffect() override;
0029     void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
0030     void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override;
0031     void postPaintScreen() override;
0032     bool isActive() const override;
0033     bool touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time) override;
0034     bool touchMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time) override;
0035     bool touchUp(qint32 id, std::chrono::microseconds time) override;
0036 
0037     // for properties
0038     qreal lineWidth() const
0039     {
0040         return m_lineWidth;
0041     }
0042     int ringLife() const
0043     {
0044         return m_ringLife;
0045     }
0046     int ringSize() const
0047     {
0048         return m_ringMaxSize;
0049     }
0050     int ringCount() const
0051     {
0052         return m_ringCount;
0053     }
0054 
0055 private:
0056     inline void drawCircle(const RenderViewport &viewport, const QColor &color, float cx, float cy, float r);
0057 
0058     void repaint();
0059 
0060     float computeAlpha(int time, int ring);
0061     float computeRadius(int time, bool press, int ring);
0062     void drawCircleGl(const RenderViewport &viewport, const QColor &color, float cx, float cy, float r);
0063     void drawCircleQPainter(const QColor &color, float cx, float cy, float r);
0064     void paintScreenSetupGl(const RenderTarget &renderTarget, const QMatrix4x4 &projectionMatrix);
0065     void paintScreenFinishGl();
0066 
0067     Qt::GlobalColor colorForId(quint32 id);
0068 
0069     int m_ringCount = 2;
0070     float m_lineWidth = 1.0;
0071     int m_ringLife = 300;
0072     float m_ringMaxSize = 20.0;
0073 
0074     struct TouchPoint
0075     {
0076         QPointF pos;
0077         int time = 0;
0078         bool press;
0079         QColor color;
0080     };
0081     QList<TouchPoint> m_points;
0082     QHash<quint32, QPointF> m_latestPositions;
0083     QHash<quint32, Qt::GlobalColor> m_colors;
0084     std::chrono::milliseconds m_lastPresentTime = std::chrono::milliseconds::zero();
0085 };
0086 
0087 } // namespace