KWin
Loading...
Searching...
No Matches
touchpoints.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2012 Filip Wieladek <wattos@gmail.com>
6 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include "effect/effect.h"
14
15namespace KWin
16{
17
19 : public Effect
20{
21 Q_OBJECT
22 Q_PROPERTY(qreal lineWidth READ lineWidth)
23 Q_PROPERTY(int ringLife READ ringLife)
24 Q_PROPERTY(int ringSize READ ringSize)
25 Q_PROPERTY(int ringCount READ ringCount)
26public:
28 ~TouchPointsEffect() override;
29 void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
30 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override;
31 void postPaintScreen() override;
32 bool isActive() const override;
33 bool touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time) override;
34 bool touchMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time) override;
35 bool touchUp(qint32 id, std::chrono::microseconds time) override;
36
37 // for properties
38 qreal lineWidth() const
39 {
40 return m_lineWidth;
41 }
42 int ringLife() const
43 {
44 return m_ringLife;
45 }
46 int ringSize() const
47 {
48 return m_ringMaxSize;
49 }
50 int ringCount() const
51 {
52 return m_ringCount;
53 }
54
55private:
56 inline void drawCircle(const RenderViewport &viewport, const QColor &color, float cx, float cy, float r);
57
58 void repaint();
59
60 float computeAlpha(int time, int ring);
61 float computeRadius(int time, bool press, int ring);
62 void drawCircleGl(const RenderViewport &viewport, const QColor &color, float cx, float cy, float r);
63 void drawCircleQPainter(const QColor &color, float cx, float cy, float r);
64 void paintScreenSetupGl(const RenderTarget &renderTarget, const QMatrix4x4 &projectionMatrix);
65 void paintScreenFinishGl();
66
67 Qt::GlobalColor colorForId(quint32 id);
68
69 int m_ringCount = 2;
70 float m_lineWidth = 1.0;
71 int m_ringLife = 300;
72 float m_ringMaxSize = 20.0;
73
74 struct TouchPoint
75 {
76 QPointF pos;
77 int time = 0;
78 bool press;
79 QColor color;
80 };
81 QList<TouchPoint> m_points;
82 QHash<quint32, QPointF> m_latestPositions;
83 QHash<quint32, Qt::GlobalColor> m_colors;
84 std::chrono::milliseconds m_lastPresentTime = std::chrono::milliseconds::zero();
85};
86
87} // namespace
Base class for all KWin effects.
Definition effect.h:535
void postPaintScreen() override
void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override
bool touchUp(qint32 id, std::chrono::microseconds time) override
bool touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time) override
bool isActive() const override
void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override
bool touchMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time) override