KWin
Loading...
Searching...
No Matches
startupfeedback.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: 2010 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11#include "effect/effect.h"
12#include <KConfigWatcher>
13#include <KStartupInfo>
14#include <QObject>
15
16#include <chrono>
17
18class KSelectionOwner;
19namespace KWin
20{
21
22class GLShader;
23class GLTexture;
24
26 : public Effect
27{
28 Q_OBJECT
29 Q_PROPERTY(int type READ type)
30public:
32 ~StartupFeedbackEffect() override;
33
34 void reconfigure(ReconfigureFlags flags) override;
35 void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
36 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override;
37 void postPaintScreen() override;
38 bool isActive() const override;
39
40 int requestedEffectChainPosition() const override
41 {
42 return 90;
43 }
44
45 int type() const
46 {
47 return int(m_type);
48 }
49
50 static bool supported();
51
52private Q_SLOTS:
53 void gotNewStartup(const QString &id, const QIcon &icon);
54 void gotRemoveStartup(const QString &id);
55 void gotStartupChange(const QString &id, const QIcon &icon);
56 void slotMouseChanged(const QPointF &pos, const QPointF &oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
57
58private:
59 enum FeedbackType {
60 NoFeedback,
61 BouncingFeedback,
62 BlinkingFeedback,
63 PassiveFeedback
64 };
65
66 struct Startup
67 {
68 QIcon icon;
69 std::shared_ptr<QTimer> expiredTimer;
70 };
71
72 void start(const Startup &startup);
73 void stop();
74 QImage scalePixmap(const QPixmap &pm, const QSize &size, qreal devicePixelRatio) const;
75 void prepareTextures(const QPixmap &pix, qreal devicePixelRatio);
76 QRect feedbackRect() const;
77 QSize feedbackIconSize() const;
78
79 qreal m_bounceSizesRatio;
80 KStartupInfo *m_startupInfo;
81 KSelectionOwner *m_selection;
82 QString m_currentStartup;
83 QMap<QString, Startup> m_startups;
84 bool m_active;
85 int m_frame;
86 int m_progress;
87 std::chrono::milliseconds m_lastPresentTime;
88 std::unique_ptr<GLTexture> m_bouncingTextures[5];
89 std::unique_ptr<GLTexture> m_texture; // for passive and blinking
90 FeedbackType m_type;
91 QRect m_currentGeometry, m_dirtyRect;
92 std::unique_ptr<GLShader> m_blinkingShader;
93 int m_cursorSize;
94 KConfigWatcher::Ptr m_configWatcher;
95 bool m_splashVisible;
96 std::chrono::seconds m_timeout;
97};
98} // namespace
Base class for all KWin effects.
Definition effect.h:535
int requestedEffectChainPosition() const override
bool isActive() const override
void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override
void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override
void reconfigure(ReconfigureFlags flags) override