| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> |
| 3 | SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 6 | */ |
| 7 | #ifndef WINDOWEFFECTS_H |
| 8 | #define WINDOWEFFECTS_H |
| 9 | #include "kwindoweffects_p.h" |
| 10 | #include <kwindowsystem_version.h> |
| 11 | |
| 12 | #include <QHash> |
| 13 | #include <QObject> |
| 14 | #include <QPointer> |
| 15 | |
| 16 | class BlurManager; |
| 17 | class Blur; |
| 18 | class ContrastManager; |
| 19 | class Contrast; |
| 20 | class SlideManager; |
| 21 | |
| 22 | class WindowEffects : public QObject, public KWindowEffectsPrivate |
| 23 | { |
| 24 | Q_OBJECT |
| 25 | public: |
| 26 | WindowEffects(); |
| 27 | ~WindowEffects() override; |
| 28 | |
| 29 | bool eventFilter(QObject *watched, QEvent *event) override; |
| 30 | void trackWindow(QWindow *window); |
| 31 | void releaseWindow(QWindow *window); |
| 32 | |
| 33 | bool isEffectAvailable(KWindowEffects::Effect effect) override; |
| 34 | void slideWindow(QWindow *window, KWindowEffects::SlideFromLocation location, int offset) override; |
| 35 | void enableBlurBehind(QWindow *window, bool enable = true, const QRegion ®ion = QRegion()) override; |
| 36 | void enableBackgroundContrast(QWindow *window, |
| 37 | bool enable = true, |
| 38 | qreal contrast = 1, |
| 39 | qreal intensity = 1, |
| 40 | qreal saturation = 1, |
| 41 | const QRegion ®ion = QRegion()) override; |
| 42 | |
| 43 | private: |
| 44 | void installContrast(QWindow *window, bool enable = true, qreal contrast = 1, qreal intensity = 1, qreal saturation = 1, const QRegion ®ion = QRegion()); |
| 45 | void installBlur(QWindow *window, bool enable, const QRegion ®ion); |
| 46 | void installSlide(QWindow *window, KWindowEffects::SlideFromLocation location, int offset); |
| 47 | |
| 48 | void resetBlur(QWindow *window, Blur *blur = nullptr); |
| 49 | void resetContrast(QWindow *window, Contrast *contrast = nullptr); |
| 50 | |
| 51 | QHash<QWindow *, QList<QMetaObject::Connection>> m_windowWatchers; |
| 52 | QHash<QWindow *, QRegion> m_blurRegions; |
| 53 | struct BackgroundContrastData { |
| 54 | qreal contrast = 1; |
| 55 | qreal intensity = 1; |
| 56 | qreal saturation = 1; |
| 57 | QRegion region; |
| 58 | }; |
| 59 | QHash<QWindow *, BackgroundContrastData> m_backgroundConstrastRegions; |
| 60 | QHash<QWindow *, QPointer<Blur>> m_blurs; |
| 61 | QHash<QWindow *, QPointer<Contrast>> m_contrasts; |
| 62 | struct SlideData { |
| 63 | KWindowEffects::SlideFromLocation location; |
| 64 | int offset; |
| 65 | }; |
| 66 | QHash<QWindow *, SlideData> m_slideMap; |
| 67 | BlurManager *m_blurManager; |
| 68 | ContrastManager *m_contrastManager; |
| 69 | SlideManager *m_slideManager; |
| 70 | }; |
| 71 | |
| 72 | #endif |
| 73 | |