KWin
Loading...
Searching...
No Matches
windoweffects.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2019 Martin Flöser <mgraesslin@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5*/
6#include "windoweffects.h"
8
9#include <QGuiApplication>
10#include <QWidget>
11#include <QWindow>
12
13Q_DECLARE_METATYPE(KWindowEffects::SlideFromLocation)
14
15namespace KWin
16{
17
19 : QObject()
20 , KWindowEffectsPrivate()
21{
22}
23
27
28bool WindowEffects::isEffectAvailable(KWindowEffects::Effect effect)
29{
30 if (!effects) {
31 return false;
32 }
33 switch (effect) {
34 case KWindowEffects::BackgroundContrast:
35 return effects->isEffectLoaded(QStringLiteral("contrast"));
36 case KWindowEffects::BlurBehind:
37 return effects->isEffectLoaded(QStringLiteral("blur"));
38 case KWindowEffects::Slide:
39 return effects->isEffectLoaded(QStringLiteral("slidingpopups"));
40 default:
41 // plugin does not provide integration for other effects
42 return false;
43 }
44}
45
46void WindowEffects::slideWindow(QWindow *window, KWindowEffects::SlideFromLocation location, int offset)
47{
48 window->setProperty("kwin_slide", QVariant::fromValue(location));
49 window->setProperty("kwin_slide_offset", offset);
50}
51
52void WindowEffects::enableBlurBehind(QWindow *window, bool enable, const QRegion &region)
53{
54 if (enable) {
55 window->setProperty("kwin_blur", region);
56 } else {
57 window->setProperty("kwin_blur", {});
58 }
59}
60
61void WindowEffects::enableBackgroundContrast(QWindow *window, bool enable, qreal contrast, qreal intensity, qreal saturation, const QRegion &region)
62{
63 if (enable) {
64 window->setProperty("kwin_background_region", region);
65 window->setProperty("kwin_background_contrast", contrast);
66 window->setProperty("kwin_background_intensity", intensity);
67 window->setProperty("kwin_background_saturation", saturation);
68 } else {
69 window->setProperty("kwin_background_region", {});
70 window->setProperty("kwin_background_contrast", {});
71 window->setProperty("kwin_background_intensity", {});
72 window->setProperty("kwin_background_saturation", {});
73 }
74}
75}
Q_SCRIPTABLE bool isEffectLoaded(const QString &name) const
void slideWindow(QWindow *window, KWindowEffects::SlideFromLocation location, int offset) override
void enableBackgroundContrast(QWindow *window, bool enable=true, qreal contrast=1, qreal intensity=1, qreal saturation=1, const QRegion &region=QRegion()) override
bool isEffectAvailable(KWindowEffects::Effect effect) override
void enableBlurBehind(QWindow *window, bool enable=true, const QRegion &region=QRegion()) override
Q_DECLARE_METATYPE(KWin::SwitchEvent::State)
EffectsHandler * effects