plugins/windowsystem: Adapt to KWindowEffectsPrivate API change

master
David Redondo 11 months ago
parent c899cd07f8
commit c0cc162ba6

@ -25,21 +25,6 @@ WindowEffects::~WindowEffects()
{ {
} }
namespace
{
QWindow *findWindow(WId win)
{
const auto windows = qApp->allWindows();
auto it = std::find_if(windows.begin(), windows.end(), [win](QWindow *w) {
return w->handle() && w->winId() == win;
});
if (it == windows.end()) {
return nullptr;
}
return *it;
}
}
bool WindowEffects::isEffectAvailable(KWindowEffects::Effect effect) bool WindowEffects::isEffectAvailable(KWindowEffects::Effect effect)
{ {
if (!effects) { if (!effects) {
@ -59,46 +44,33 @@ bool WindowEffects::isEffectAvailable(KWindowEffects::Effect effect)
} }
} }
void WindowEffects::slideWindow(WId id, KWindowEffects::SlideFromLocation location, int offset) void WindowEffects::slideWindow(QWindow *window, KWindowEffects::SlideFromLocation location, int offset)
{ {
auto w = findWindow(id); window->setProperty("kwin_slide", QVariant::fromValue(location));
if (!w) { window->setProperty("kwin_slide_offset", offset);
return;
}
w->setProperty("kwin_slide", QVariant::fromValue(location));
w->setProperty("kwin_slide_offset", offset);
} }
void WindowEffects::enableBlurBehind(WId window, bool enable, const QRegion &region) void WindowEffects::enableBlurBehind(QWindow *window, bool enable, const QRegion &region)
{ {
auto w = findWindow(window);
if (!w) {
return;
}
if (enable) { if (enable) {
w->setProperty("kwin_blur", region); window->setProperty("kwin_blur", region);
} else { } else {
w->setProperty("kwin_blur", {}); window->setProperty("kwin_blur", {});
} }
} }
void WindowEffects::enableBackgroundContrast(WId window, bool enable, qreal contrast, qreal intensity, qreal saturation, const QRegion &region) void WindowEffects::enableBackgroundContrast(QWindow *window, bool enable, qreal contrast, qreal intensity, qreal saturation, const QRegion &region)
{ {
auto w = findWindow(window);
if (!w) {
return;
}
if (enable) { if (enable) {
w->setProperty("kwin_background_region", region); window->setProperty("kwin_background_region", region);
w->setProperty("kwin_background_contrast", contrast); window->setProperty("kwin_background_contrast", contrast);
w->setProperty("kwin_background_intensity", intensity); window->setProperty("kwin_background_intensity", intensity);
w->setProperty("kwin_background_saturation", saturation); window->setProperty("kwin_background_saturation", saturation);
} else { } else {
w->setProperty("kwin_background_region", {}); window->setProperty("kwin_background_region", {});
w->setProperty("kwin_background_contrast", {}); window->setProperty("kwin_background_contrast", {});
w->setProperty("kwin_background_intensity", {}); window->setProperty("kwin_background_intensity", {});
w->setProperty("kwin_background_saturation", {}); window->setProperty("kwin_background_saturation", {});
} }
} }
} }

@ -18,9 +18,9 @@ public:
~WindowEffects() override; ~WindowEffects() override;
bool isEffectAvailable(KWindowEffects::Effect effect) override; bool isEffectAvailable(KWindowEffects::Effect effect) override;
void slideWindow(WId id, KWindowEffects::SlideFromLocation location, int offset) override; void slideWindow(QWindow *window, KWindowEffects::SlideFromLocation location, int offset) override;
void enableBlurBehind(WId window, bool enable = true, const QRegion &region = QRegion()) override; void enableBlurBehind(QWindow *window, bool enable = true, const QRegion &region = QRegion()) override;
void enableBackgroundContrast(WId window, bool enable = true, qreal contrast = 1, qreal intensity = 1, qreal saturation = 1, const QRegion &region = QRegion()) override; void enableBackgroundContrast(QWindow *window, bool enable = true, qreal contrast = 1, qreal intensity = 1, qreal saturation = 1, const QRegion &region = QRegion()) override;
}; };
} }

Loading…
Cancel
Save