From c0cc162ba6fe5d4b0b32e7d06e6dca06e732c47a Mon Sep 17 00:00:00 2001 From: David Redondo Date: Mon, 16 Oct 2023 17:03:08 +0200 Subject: [PATCH] plugins/windowsystem: Adapt to KWindowEffectsPrivate API change --- src/plugins/windowsystem/windoweffects.cpp | 58 ++++++---------------- src/plugins/windowsystem/windoweffects.h | 6 +-- 2 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/plugins/windowsystem/windoweffects.cpp b/src/plugins/windowsystem/windoweffects.cpp index e4fef899e4..9cbc401a4c 100644 --- a/src/plugins/windowsystem/windoweffects.cpp +++ b/src/plugins/windowsystem/windoweffects.cpp @@ -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) { 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); - if (!w) { - return; - } - w->setProperty("kwin_slide", QVariant::fromValue(location)); - w->setProperty("kwin_slide_offset", offset); + window->setProperty("kwin_slide", QVariant::fromValue(location)); + window->setProperty("kwin_slide_offset", offset); } -void WindowEffects::enableBlurBehind(WId window, bool enable, const QRegion ®ion) +void WindowEffects::enableBlurBehind(QWindow *window, bool enable, const QRegion ®ion) { - auto w = findWindow(window); - if (!w) { - return; - } if (enable) { - w->setProperty("kwin_blur", region); + window->setProperty("kwin_blur", region); } else { - w->setProperty("kwin_blur", {}); + window->setProperty("kwin_blur", {}); } } -void WindowEffects::enableBackgroundContrast(WId window, bool enable, qreal contrast, qreal intensity, qreal saturation, const QRegion ®ion) +void WindowEffects::enableBackgroundContrast(QWindow *window, bool enable, qreal contrast, qreal intensity, qreal saturation, const QRegion ®ion) { - auto w = findWindow(window); - if (!w) { - return; - } if (enable) { - w->setProperty("kwin_background_region", region); - w->setProperty("kwin_background_contrast", contrast); - w->setProperty("kwin_background_intensity", intensity); - w->setProperty("kwin_background_saturation", saturation); + window->setProperty("kwin_background_region", region); + window->setProperty("kwin_background_contrast", contrast); + window->setProperty("kwin_background_intensity", intensity); + window->setProperty("kwin_background_saturation", saturation); } else { - w->setProperty("kwin_background_region", {}); - w->setProperty("kwin_background_contrast", {}); - w->setProperty("kwin_background_intensity", {}); - w->setProperty("kwin_background_saturation", {}); + window->setProperty("kwin_background_region", {}); + window->setProperty("kwin_background_contrast", {}); + window->setProperty("kwin_background_intensity", {}); + window->setProperty("kwin_background_saturation", {}); } } - } diff --git a/src/plugins/windowsystem/windoweffects.h b/src/plugins/windowsystem/windoweffects.h index 692db8a0bb..3c4f2a70b5 100644 --- a/src/plugins/windowsystem/windoweffects.h +++ b/src/plugins/windowsystem/windoweffects.h @@ -18,9 +18,9 @@ public: ~WindowEffects() override; bool isEffectAvailable(KWindowEffects::Effect effect) override; - void slideWindow(WId id, KWindowEffects::SlideFromLocation location, int offset) override; - void enableBlurBehind(WId window, bool enable = true, const QRegion ®ion = QRegion()) override; - void enableBackgroundContrast(WId window, bool enable = true, qreal contrast = 1, qreal intensity = 1, qreal saturation = 1, const QRegion ®ion = QRegion()) override; + void slideWindow(QWindow *window, KWindowEffects::SlideFromLocation location, int offset) override; + void enableBlurBehind(QWindow *window, bool enable = true, const QRegion ®ion = QRegion()) override; + void enableBackgroundContrast(QWindow *window, bool enable = true, qreal contrast = 1, qreal intensity = 1, qreal saturation = 1, const QRegion ®ion = QRegion()) override; }; }