File indexing completed on 2024-05-19 04:01:55
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 #ifndef WINDOWEFFECTS_H 0008 #define WINDOWEFFECTS_H 0009 #include "kwindoweffects_p.h" 0010 #include <kwindowsystem_version.h> 0011 0012 #include <QHash> 0013 #include <QObject> 0014 #include <QPointer> 0015 0016 class BlurManager; 0017 class Blur; 0018 class ContrastManager; 0019 class Contrast; 0020 class SlideManager; 0021 0022 class WindowEffects : public QObject, public KWindowEffectsPrivate 0023 { 0024 Q_OBJECT 0025 public: 0026 WindowEffects(); 0027 ~WindowEffects() override; 0028 0029 bool eventFilter(QObject *watched, QEvent *event) override; 0030 void trackWindow(QWindow *window); 0031 void releaseWindow(QWindow *window); 0032 0033 bool isEffectAvailable(KWindowEffects::Effect effect) override; 0034 void slideWindow(QWindow *window, KWindowEffects::SlideFromLocation location, int offset) override; 0035 void enableBlurBehind(QWindow *window, bool enable = true, const QRegion ®ion = QRegion()) override; 0036 void enableBackgroundContrast(QWindow *window, 0037 bool enable = true, 0038 qreal contrast = 1, 0039 qreal intensity = 1, 0040 qreal saturation = 1, 0041 const QRegion ®ion = QRegion()) override; 0042 0043 private: 0044 void installContrast(QWindow *window, bool enable = true, qreal contrast = 1, qreal intensity = 1, qreal saturation = 1, const QRegion ®ion = QRegion()); 0045 void installBlur(QWindow *window, bool enable, const QRegion ®ion); 0046 void installSlide(QWindow *window, KWindowEffects::SlideFromLocation location, int offset); 0047 0048 void resetBlur(QWindow *window, Blur *blur = nullptr); 0049 void resetContrast(QWindow *window, Contrast *contrast = nullptr); 0050 0051 QHash<QWindow *, QList<QMetaObject::Connection>> m_windowWatchers; 0052 QHash<QWindow *, QRegion> m_blurRegions; 0053 struct BackgroundContrastData { 0054 qreal contrast = 1; 0055 qreal intensity = 1; 0056 qreal saturation = 1; 0057 QRegion region; 0058 }; 0059 QHash<QWindow *, BackgroundContrastData> m_backgroundConstrastRegions; 0060 QHash<QWindow *, QPointer<Blur>> m_blurs; 0061 QHash<QWindow *, QPointer<Contrast>> m_contrasts; 0062 struct SlideData { 0063 KWindowEffects::SlideFromLocation location; 0064 int offset; 0065 }; 0066 QHash<QWindow *, SlideData> m_slideMap; 0067 BlurManager *m_blurManager; 0068 ContrastManager *m_contrastManager; 0069 SlideManager *m_slideManager; 0070 }; 0071 0072 #endif