File indexing completed on 2024-11-10 04:57:07
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #pragma once 0010 #include "effect/effect.h" 0011 0012 #include <KConfigWatcher> 0013 0014 class QTimer; 0015 namespace KSvg 0016 { 0017 class Svg; 0018 } 0019 0020 namespace KWin 0021 { 0022 class Glow; 0023 class GLTexture; 0024 0025 class ScreenEdgeEffect : public Effect 0026 { 0027 Q_OBJECT 0028 public: 0029 ScreenEdgeEffect(); 0030 ~ScreenEdgeEffect() override; 0031 void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; 0032 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; 0033 bool isActive() const override; 0034 0035 int requestedEffectChainPosition() const override 0036 { 0037 return 10; 0038 } 0039 0040 private Q_SLOTS: 0041 void edgeApproaching(ElectricBorder border, qreal factor, const QRect &geometry); 0042 void cleanup(); 0043 0044 private: 0045 void ensureGlowSvg(); 0046 std::unique_ptr<Glow> createGlow(ElectricBorder border, qreal factor, const QRect &geometry); 0047 QImage createCornerGlow(ElectricBorder border); 0048 QImage createEdgeGlow(ElectricBorder border, const QSize &size); 0049 QSize cornerGlowSize(ElectricBorder border); 0050 KConfigWatcher::Ptr m_configWatcher; 0051 KSvg::Svg *m_glow = nullptr; 0052 std::map<ElectricBorder, std::unique_ptr<Glow>> m_borders; 0053 QTimer *m_cleanupTimer; 0054 }; 0055 0056 class Glow 0057 { 0058 public: 0059 std::unique_ptr<GLTexture> texture; 0060 QImage image; 0061 QSize pictureSize; 0062 qreal strength; 0063 QRect geometry; 0064 ElectricBorder border; 0065 }; 0066 0067 }