diff --git a/src/scene/windowitem.cpp b/src/scene/windowitem.cpp index a3f5c9f47d..4283051e7e 100644 --- a/src/scene/windowitem.cpp +++ b/src/scene/windowitem.cpp @@ -50,6 +50,7 @@ WindowItem::WindowItem(Window *window, Item *parent) connect(window, &Window::hiddenByShowDesktopChanged, this, &WindowItem::updateVisibility); connect(window, &Window::activitiesChanged, this, &WindowItem::updateVisibility); connect(window, &Window::desktopsChanged, this, &WindowItem::updateVisibility); + connect(window, &Window::offscreenRenderingChanged, this, &WindowItem::updateVisibility); connect(workspace(), &Workspace::currentActivityChanged, this, &WindowItem::updateVisibility); connect(workspace(), &Workspace::currentDesktopChanged, this, &WindowItem::updateVisibility); updateVisibility(); @@ -187,7 +188,7 @@ void WindowItem::updateVisibility() setVisible(visible); if (m_window->readyForPainting()) { - m_window->setSuspended(!visible); + m_window->setSuspended(!visible && !m_window->isOffscreenRendering()); } } diff --git a/src/window.cpp b/src/window.cpp index a4e8264b51..f58a043cf5 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -4261,10 +4261,11 @@ bool Window::isLockScreenOverlay() const void Window::refOffscreenRendering() { - if (m_offscreenRenderCount == 0) { - m_offscreenFramecallbackTimer.start(1'000'000 / output()->refreshRate()); - } m_offscreenRenderCount++; + if (m_offscreenRenderCount == 1) { + m_offscreenFramecallbackTimer.start(1'000'000 / output()->refreshRate()); + Q_EMIT offscreenRenderingChanged(); + } } void Window::unrefOffscreenRendering() @@ -4273,9 +4274,15 @@ void Window::unrefOffscreenRendering() m_offscreenRenderCount--; if (m_offscreenRenderCount == 0) { m_offscreenFramecallbackTimer.stop(); + Q_EMIT offscreenRenderingChanged(); } } +bool Window::isOffscreenRendering() const +{ + return m_offscreenRenderCount > 0; +} + void Window::maybeSendFrameCallback() { if (m_surface && !m_windowItem->isVisible()) { diff --git a/src/window.h b/src/window.h index 60d1f643c1..fb883fb6b8 100644 --- a/src/window.h +++ b/src/window.h @@ -1322,6 +1322,7 @@ public: void refOffscreenRendering(); void unrefOffscreenRendering(); + bool isOffscreenRendering() const; qreal preferredBufferScale() const; void setPreferredBufferScale(qreal scale); @@ -1447,6 +1448,7 @@ Q_SIGNALS: void readyForPaintingChanged(); void maximizeGeometryRestoreChanged(); void fullscreenGeometryRestoreChanged(); + void offscreenRenderingChanged(); protected: Window();