diff --git a/src/effects.cpp b/src/effects.cpp index e372e1e077..b6aedbbbb3 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -1739,9 +1739,9 @@ EffectScreen::Transform EffectScreenImpl::transform() const // EffectWindowImpl //**************************************** -EffectWindowImpl::EffectWindowImpl(Window *window) - : m_window(window) - , m_windowItem(nullptr) +EffectWindowImpl::EffectWindowImpl(WindowItem *windowItem) + : m_window(windowItem->window()) + , m_windowItem(windowItem) { // Deleted windows are not managed. So, when windowClosed signal is // emitted, effects can't distinguish managed windows from unmanaged @@ -1750,74 +1750,74 @@ EffectWindowImpl::EffectWindowImpl(Window *window) // parent can be Client, XdgShellClient, or Unmanaged. So, later on, when // an instance of Deleted becomes parent of the EffectWindow, effects // can still figure out whether it is/was a managed window. - managed = window->isClient(); + managed = m_window->isClient(); - m_waylandWindow = qobject_cast(window) != nullptr; - m_x11Window = qobject_cast(window) != nullptr; + m_waylandWindow = qobject_cast(m_window) != nullptr; + m_x11Window = qobject_cast(m_window) != nullptr; - connect(window, &Window::windowShown, this, [this]() { + connect(m_window, &Window::windowShown, this, [this]() { Q_EMIT windowShown(this); }); - connect(window, &Window::windowHidden, this, [this]() { + connect(m_window, &Window::windowHidden, this, [this]() { Q_EMIT windowHidden(this); }); - connect(window, &Window::maximizedChanged, this, [this, window]() { - const MaximizeMode mode = window->maximizeMode(); + connect(m_window, &Window::maximizedChanged, this, [this]() { + const MaximizeMode mode = m_window->maximizeMode(); Q_EMIT windowMaximizedStateChanged(this, mode & MaximizeHorizontal, mode & MaximizeVertical); }); - connect(window, &Window::maximizedAboutToChange, this, [this](MaximizeMode m) { + connect(m_window, &Window::maximizedAboutToChange, this, [this](MaximizeMode m) { Q_EMIT windowMaximizedStateAboutToChange(this, m & MaximizeHorizontal, m & MaximizeVertical); }); - connect(window, &Window::frameGeometryAboutToChange, this, [this]() { + connect(m_window, &Window::frameGeometryAboutToChange, this, [this]() { Q_EMIT windowFrameGeometryAboutToChange(this); }); - connect(window, &Window::interactiveMoveResizeStarted, this, [this]() { + connect(m_window, &Window::interactiveMoveResizeStarted, this, [this]() { Q_EMIT windowStartUserMovedResized(this); }); - connect(window, &Window::interactiveMoveResizeStepped, this, [this](const QRectF &geometry) { + connect(m_window, &Window::interactiveMoveResizeStepped, this, [this](const QRectF &geometry) { Q_EMIT windowStepUserMovedResized(this, geometry); }); - connect(window, &Window::interactiveMoveResizeFinished, this, [this]() { + connect(m_window, &Window::interactiveMoveResizeFinished, this, [this]() { Q_EMIT windowFinishUserMovedResized(this); }); - connect(window, &Window::opacityChanged, this, [this](Window *window, qreal oldOpacity) { + connect(m_window, &Window::opacityChanged, this, [this](Window *window, qreal oldOpacity) { Q_EMIT windowOpacityChanged(this, oldOpacity, window->opacity()); }); - connect(window, &Window::minimizedChanged, this, [this, window]() { - if (window->isMinimized()) { + connect(m_window, &Window::minimizedChanged, this, [this]() { + if (m_window->isMinimized()) { Q_EMIT windowMinimized(this); } else { Q_EMIT windowUnminimized(this); } }); - connect(window, &Window::modalChanged, this, [this]() { + connect(m_window, &Window::modalChanged, this, [this]() { Q_EMIT windowModalityChanged(this); }); - connect(window, &Window::frameGeometryChanged, this, [this](const QRectF &oldGeometry) { + connect(m_window, &Window::frameGeometryChanged, this, [this](const QRectF &oldGeometry) { Q_EMIT windowFrameGeometryChanged(this, oldGeometry); }); - connect(window, &Window::damaged, this, [this]() { + connect(m_window, &Window::damaged, this, [this]() { Q_EMIT windowDamaged(this); }); - connect(window, &Window::unresponsiveChanged, this, [this](bool unresponsive) { + connect(m_window, &Window::unresponsiveChanged, this, [this](bool unresponsive) { Q_EMIT windowUnresponsiveChanged(this, unresponsive); }); - connect(window, &Window::keepAboveChanged, this, [this]() { + connect(m_window, &Window::keepAboveChanged, this, [this]() { Q_EMIT windowKeepAboveChanged(this); }); - connect(window, &Window::keepBelowChanged, this, [this]() { + connect(m_window, &Window::keepBelowChanged, this, [this]() { Q_EMIT windowKeepBelowChanged(this); }); - connect(window, &Window::fullScreenChanged, this, [this]() { + connect(m_window, &Window::fullScreenChanged, this, [this]() { Q_EMIT windowFullScreenChanged(this); }); - connect(window, &Window::visibleGeometryChanged, this, [this]() { + connect(m_window, &Window::visibleGeometryChanged, this, [this]() { Q_EMIT windowExpandedGeometryChanged(this); }); - connect(window, &Window::decorationChanged, this, [this]() { + connect(m_window, &Window::decorationChanged, this, [this]() { Q_EMIT windowDecorationChanged(this); }); - connect(window, &Window::desktopsChanged, this, [this]() { + connect(m_window, &Window::desktopsChanged, this, [this]() { Q_EMIT windowDesktopsChanged(this); }); } @@ -1989,11 +1989,6 @@ QSizeF EffectWindowImpl::basicUnit() const return QSize(1, 1); } -void EffectWindowImpl::setWindowItem(WindowItem *item) -{ - m_windowItem = item; -} - QRectF EffectWindowImpl::decorationInnerRect() const { return m_window->rect() - m_window->frameMargins(); diff --git a/src/effects.h b/src/effects.h index 0e3ea913f7..2614e9883b 100644 --- a/src/effects.h +++ b/src/effects.h @@ -352,7 +352,7 @@ class EffectWindowImpl : public EffectWindow { Q_OBJECT public: - explicit EffectWindowImpl(Window *window); + explicit EffectWindowImpl(WindowItem *windowItem); ~EffectWindowImpl() override; void addRepaint(const QRect &r) override; @@ -462,7 +462,6 @@ public: const Window *window() const; Window *window(); - void setWindowItem(WindowItem *item); // internal WindowItem *windowItem() const; // internal void elevate(bool elevate); diff --git a/src/scene/windowitem.cpp b/src/scene/windowitem.cpp index 61564ad87b..faf56dbe71 100644 --- a/src/scene/windowitem.cpp +++ b/src/scene/windowitem.cpp @@ -5,6 +5,7 @@ */ #include "scene/windowitem.h" +#include "effects.h" #include "internalwindow.h" #include "scene/decorationitem.h" #include "scene/shadowitem.h" @@ -53,6 +54,8 @@ WindowItem::WindowItem(Window *window, Scene *scene, Item *parent) connect(window, &Window::stackingOrderChanged, this, &WindowItem::updateStackingOrder); updateStackingOrder(); + + m_effectWindow = std::make_unique(this); } WindowItem::~WindowItem() @@ -79,6 +82,11 @@ Window *WindowItem::window() const return m_window; } +EffectWindowImpl *WindowItem::effectWindow() const +{ + return m_effectWindow.get(); +} + void WindowItem::refVisible(int reason) { if (reason & PAINT_DISABLED_BY_HIDDEN) { diff --git a/src/scene/windowitem.h b/src/scene/windowitem.h index a0e40ee553..f3e15ec386 100644 --- a/src/scene/windowitem.h +++ b/src/scene/windowitem.h @@ -17,6 +17,7 @@ namespace KWin { class Window; class DecorationItem; +class EffectWindowImpl; class InternalWindow; class Shadow; class ShadowItem; @@ -47,6 +48,7 @@ public: DecorationItem *decorationItem() const; ShadowItem *shadowItem() const; Window *window() const; + EffectWindowImpl *effectWindow() const; void refVisible(int reason); void unrefVisible(int reason); @@ -77,6 +79,7 @@ private: std::unique_ptr m_surfaceItem; std::unique_ptr m_decorationItem; std::unique_ptr m_shadowItem; + std::unique_ptr m_effectWindow; std::optional m_elevation; int m_forceVisibleByHiddenCount = 0; int m_forceVisibleByDesktopCount = 0; diff --git a/src/scene/workspacescene.cpp b/src/scene/workspacescene.cpp index cf0173df28..115efa1e17 100644 --- a/src/scene/workspacescene.cpp +++ b/src/scene/workspacescene.cpp @@ -292,7 +292,7 @@ void WorkspaceScene::preparePaintGenericScreen() data.mask = m_paintContext.mask; data.paint = infiniteRegion(); // no clipping, so doesn't really matter - effects->prePaintWindow(windowItem->window()->effectWindow(), data, m_expectedPresentTimestamp); + effects->prePaintWindow(windowItem->effectWindow(), data, m_expectedPresentTimestamp); m_paintContext.phase2Data.append(Phase2Data{ .item = windowItem, .region = infiniteRegion(), @@ -325,7 +325,7 @@ void WorkspaceScene::preparePaintSimpleScreen() } } - effects->prePaintWindow(window->effectWindow(), data, m_expectedPresentTimestamp); + effects->prePaintWindow(windowItem->effectWindow(), data, m_expectedPresentTimestamp); m_paintContext.phase2Data.append(Phase2Data{ .item = windowItem, .region = data.paint, @@ -352,7 +352,7 @@ void WorkspaceScene::preparePaintSimpleScreen() void WorkspaceScene::postPaint() { for (WindowItem *w : std::as_const(stacking_order)) { - effects->postPaintWindow(w->window()->effectWindow()); + effects->postPaintWindow(w->effectWindow()); } effects->postPaintScreen(); @@ -459,7 +459,7 @@ void WorkspaceScene::paintWindow(const RenderTarget &renderTarget, const RenderV } WindowPaintData data(viewport.projectionMatrix()); - effects->paintWindow(renderTarget, viewport, item->window()->effectWindow(), mask, region, data); + effects->paintWindow(renderTarget, viewport, item->effectWindow(), mask, region, data); } // the function that'll be eventually called by paintWindow() above diff --git a/src/window.cpp b/src/window.cpp index dc01d4fee7..58fcdf6edc 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -18,12 +18,12 @@ #include "core/output.h" #include "decorations/decoratedclient.h" #include "decorations/decorationpalette.h" -#include "effects.h" #include "focuschain.h" #include "input.h" #include "outline.h" #include "placement.h" #include "scene/windowitem.h" +#include "scene/workspacescene.h" #include "screenedge.h" #include "shadow.h" #if KWIN_BUILD_TABBOX @@ -211,11 +211,8 @@ bool Window::setupCompositing() return false; } - m_effectWindow = std::make_unique(this); - m_windowItem = createItem(scene); m_windowItem->setParentItem(scene->containerItem()); - m_effectWindow->setWindowItem(m_windowItem.get()); connect(windowItem(), &WindowItem::positionChanged, this, &Window::visibleGeometryChanged); connect(windowItem(), &WindowItem::boundingRectChanged, this, &Window::visibleGeometryChanged); @@ -225,7 +222,6 @@ bool Window::setupCompositing() void Window::finishCompositing() { - m_effectWindow.reset(); m_windowItem.reset(); } @@ -280,6 +276,16 @@ void Window::updateShadow() } } +EffectWindowImpl *Window::effectWindow() +{ + return m_windowItem ? m_windowItem->effectWindow() : nullptr; +} + +const EffectWindowImpl *Window::effectWindow() const +{ + return m_windowItem ? m_windowItem->effectWindow() : nullptr; +} + SurfaceItem *Window::surfaceItem() const { if (m_windowItem) { @@ -305,10 +311,13 @@ bool Window::isUnmanaged() const void Window::elevate(bool elevate) { - if (!effectWindow()) { - return; + if (m_windowItem) { + if (elevate) { + m_windowItem->elevate(); + } else { + m_windowItem->deelevate(); + } } - effectWindow()->elevate(elevate); } pid_t Window::pid() const diff --git a/src/window.h b/src/window.h index 3d9334a965..5537cfa248 100644 --- a/src/window.h +++ b/src/window.h @@ -1727,7 +1727,6 @@ protected: int m_refCount = 1; QUuid m_internalId; - std::unique_ptr m_effectWindow; std::unique_ptr m_windowItem; std::unique_ptr m_shadow; QString resource_name; @@ -2021,16 +2020,6 @@ inline bool Window::isInternal() const return false; } -inline EffectWindowImpl *Window::effectWindow() -{ - return m_effectWindow.get(); -} - -inline const EffectWindowImpl *Window::effectWindow() const -{ - return m_effectWindow.get(); -} - inline WindowItem *Window::windowItem() const { return m_windowItem.get();