diff --git a/src/effects.cpp b/src/effects.cpp index 6f97f68708..5f3c68b708 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -1917,27 +1917,17 @@ void EffectWindowImpl::unrefVisible(int reason) void EffectWindowImpl::addRepaint(const QRect &r) { - m_window->addRepaint(r); -} - -void EffectWindowImpl::addRepaint(int x, int y, int w, int h) -{ - m_window->addRepaint(x, y, w, h); + m_windowItem->scheduleRepaint(r); } void EffectWindowImpl::addRepaintFull() { - m_window->addRepaintFull(); + m_windowItem->scheduleRepaint(m_windowItem->boundingRect()); } void EffectWindowImpl::addLayerRepaint(const QRect &r) { - m_window->addLayerRepaint(r); -} - -void EffectWindowImpl::addLayerRepaint(int x, int y, int w, int h) -{ - m_window->addLayerRepaint(x, y, w, h); + m_windowItem->scheduleRepaint(m_windowItem->mapFromGlobal(r)); } const EffectWindowGroup *EffectWindowImpl::group() const diff --git a/src/effects.h b/src/effects.h index 01b67a335d..a01f8fba3e 100644 --- a/src/effects.h +++ b/src/effects.h @@ -382,10 +382,8 @@ public: void unrefVisible(int reason) override; void addRepaint(const QRect &r) override; - void addRepaint(int x, int y, int w, int h) override; void addRepaintFull() override; void addLayerRepaint(const QRect &r) override; - void addLayerRepaint(int x, int y, int w, int h) override; void refWindow() override; void unrefWindow() override; diff --git a/src/item.cpp b/src/item.cpp index 7e63a96b99..d53230f1c6 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -219,6 +219,14 @@ QRect Item::mapToGlobal(const QRect &rect) const return rect.translated(rootPosition()); } +QRect Item::mapFromGlobal(const QRect &rect) const +{ + if (rect.isEmpty()) { + return QRect(); + } + return rect.translated(-rootPosition()); +} + void Item::stackBefore(Item *sibling) { if (Q_UNLIKELY(!sibling)) { diff --git a/src/item.h b/src/item.h index f23c274cc0..c2f2fea386 100644 --- a/src/item.h +++ b/src/item.h @@ -78,6 +78,11 @@ public: * system. */ QRect mapToGlobal(const QRect &rect) const; + /** + * Maps the given @a rect from the scene's coordinate system to the item's coordinate + * system. + */ + QRect mapFromGlobal(const QRect &rect) const; /** * Moves this item right before the specified @a sibling in the parent's children list. diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index a6e19db6b7..5ccf08b027 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -2350,10 +2350,10 @@ public: ~EffectWindow() override; Q_SCRIPTABLE virtual void addRepaint(const QRect &r) = 0; - Q_SCRIPTABLE virtual void addRepaint(int x, int y, int w, int h) = 0; + Q_SCRIPTABLE void addRepaint(int x, int y, int w, int h); Q_SCRIPTABLE virtual void addRepaintFull() = 0; Q_SCRIPTABLE virtual void addLayerRepaint(const QRect &r) = 0; - Q_SCRIPTABLE virtual void addLayerRepaint(int x, int y, int w, int h) = 0; + Q_SCRIPTABLE void addLayerRepaint(int x, int y, int w, int h); virtual void refWindow() = 0; virtual void unrefWindow() = 0; @@ -4183,6 +4183,20 @@ void Effect::initConfig() T::instance(effects->config()); } +/*************************************************************** + EffectWindow +***************************************************************/ + +inline void EffectWindow::addRepaint(int x, int y, int w, int h) +{ + addRepaint(QRect(x, y, w, h)); +} + +inline void EffectWindow::addLayerRepaint(int x, int y, int w, int h) +{ + addLayerRepaint(QRect(x, y, w, h)); +} + } // namespace Q_DECLARE_METATYPE(KWin::EffectWindow *) Q_DECLARE_METATYPE(KWin::EffectWindowList) diff --git a/src/window.cpp b/src/window.cpp index 4a0036df52..409686364d 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -365,43 +365,6 @@ void Window::finishCompositing(ReleaseReason releaseReason) deleteItem(); } -void Window::addRepaint(const QRect &rect) -{ - addRepaint(QRegion(rect)); -} - -void Window::addRepaint(int x, int y, int width, int height) -{ - addRepaint(QRegion(x, y, width, height)); -} - -void Window::addRepaint(const QRegion ®ion) -{ - if (auto item = windowItem()) { - item->scheduleRepaint(region); - } -} - -void Window::addLayerRepaint(const QRect &rect) -{ - addLayerRepaint(QRegion(rect)); -} - -void Window::addLayerRepaint(int x, int y, int width, int height) -{ - addLayerRepaint(QRegion(x, y, width, height)); -} - -void Window::addLayerRepaint(const QRegion ®ion) -{ - addRepaint(region.translated(-pos())); -} - -void Window::addRepaintFull() -{ - addLayerRepaint(visibleGeometry()); -} - void Window::addWorkspaceRepaint(int x, int y, int w, int h) { addWorkspaceRepaint(QRect(x, y, w, h)); diff --git a/src/window.h b/src/window.h index fda119780d..6dce937f48 100644 --- a/src/window.h +++ b/src/window.h @@ -719,13 +719,6 @@ public: bool hasAlpha() const; virtual bool setupCompositing(); virtual void finishCompositing(ReleaseReason releaseReason = ReleaseReason::Release); - Q_INVOKABLE void addRepaint(const QRect &r); - Q_INVOKABLE void addRepaint(const QRegion &r); - Q_INVOKABLE void addRepaint(int x, int y, int w, int h); - Q_INVOKABLE void addLayerRepaint(const QRect &r); - Q_INVOKABLE void addLayerRepaint(const QRegion &r); - Q_INVOKABLE void addLayerRepaint(int x, int y, int w, int h); - Q_INVOKABLE virtual void addRepaintFull(); // these call workspace->addRepaint(), but first transform the damage if needed void addWorkspaceRepaint(const QRect &r); void addWorkspaceRepaint(int x, int y, int w, int h);