From fe4329a252c904727e687323280f4c7ec24d8dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 27 Aug 2011 11:21:31 +0200 Subject: [PATCH] Only call active effects in the effect chain Each effect is able to declare itself as currently being active, that is transforming windows or painting or screen or doing anything during the current rendered frame. This change eliminates the hottest path inside KWin identified by callgrind. REVIEW: 102449 --- effects.cpp | 78 +++++++++---------- effects.h | 9 ++- effects/boxswitch/boxswitch.cpp | 5 ++ effects/boxswitch/boxswitch.h | 1 + effects/coverswitch/coverswitch.cpp | 5 ++ effects/coverswitch/coverswitch.h | 1 + effects/cube/cube.cpp | 5 ++ effects/cube/cube.h | 1 + effects/cube/cubeslide.cpp | 5 ++ effects/cube/cubeslide.h | 1 + effects/dashboard/dashboard.cpp | 5 ++ effects/dashboard/dashboard.h | 1 + effects/desktopgrid/desktopgrid.cpp | 9 ++- effects/desktopgrid/desktopgrid.h | 3 +- effects/dialogparent/dialogparent.cpp | 5 ++ effects/dialogparent/dialogparent.h | 2 + effects/dimscreen/dimscreen.cpp | 6 ++ effects/dimscreen/dimscreen.h | 1 + effects/explosion/explosion.cpp | 5 ++ effects/explosion/explosion.h | 1 + effects/fade/fade.cpp | 5 ++ effects/fade/fade.h | 1 + effects/fadedesktop/fadedesktop.cpp | 5 ++ effects/fadedesktop/fadedesktop.h | 1 + effects/fallapart/fallapart.cpp | 5 ++ effects/fallapart/fallapart.h | 1 + effects/flipswitch/flipswitch.cpp | 5 ++ effects/flipswitch/flipswitch.h | 1 + effects/glide/glide.cpp | 5 ++ effects/glide/glide.h | 1 + effects/highlightwindow/highlightwindow.cpp | 5 ++ effects/highlightwindow/highlightwindow.h | 1 + effects/invert/invert.cpp | 5 ++ effects/invert/invert.h | 1 + effects/login/login.cpp | 5 ++ effects/login/login.h | 1 + effects/logout/logout.cpp | 5 ++ effects/logout/logout.h | 1 + effects/lookingglass/lookingglass.cpp | 5 ++ effects/lookingglass/lookingglass.h | 1 + effects/magiclamp/magiclamp.cpp | 5 ++ effects/magiclamp/magiclamp.h | 1 + effects/magnifier/magnifier.cpp | 5 ++ effects/magnifier/magnifier.h | 1 + .../minimizeanimation/minimizeanimation.cpp | 5 ++ effects/minimizeanimation/minimizeanimation.h | 1 + effects/mousemark/mousemark.cpp | 6 ++ effects/mousemark/mousemark.h | 1 + effects/outline/outline.cpp | 5 ++ effects/outline/outline.h | 1 + effects/presentwindows/presentwindows.cpp | 5 ++ effects/presentwindows/presentwindows.h | 1 + effects/scalein/scalein.cpp | 5 ++ effects/scalein/scalein.h | 1 + effects/screenshot/screenshot.cpp | 5 ++ effects/screenshot/screenshot.h | 1 + effects/sheet/sheet.cpp | 5 ++ effects/sheet/sheet.h | 1 + effects/slide/slide.cpp | 5 ++ effects/slide/slide.h | 1 + effects/slideback/slideback.cpp | 5 ++ effects/slideback/slideback.h | 1 + effects/slidingpopups/slidingpopups.cpp | 6 ++ effects/slidingpopups/slidingpopups.h | 1 + effects/snaphelper/snaphelper.cpp | 5 ++ effects/snaphelper/snaphelper.h | 1 + effects/startupfeedback/startupfeedback.cpp | 5 ++ effects/startupfeedback/startupfeedback.h | 1 + effects/taskbarthumbnail/taskbarthumbnail.cpp | 5 ++ effects/taskbarthumbnail/taskbarthumbnail.h | 1 + effects/thumbnailaside/thumbnailaside.cpp | 5 ++ effects/thumbnailaside/thumbnailaside.h | 1 + effects/trackmouse/trackmouse.cpp | 5 ++ effects/trackmouse/trackmouse.h | 1 + effects/windowgeometry/windowgeometry.cpp | 4 + effects/windowgeometry/windowgeometry.h | 1 + effects/wobblywindows/wobblywindows.cpp | 4 + effects/wobblywindows/wobblywindows.h | 1 + effects/zoom/zoom.cpp | 5 ++ effects/zoom/zoom.h | 1 + libkwineffects/kwineffects.cpp | 11 +-- libkwineffects/kwineffects.h | 21 ++++- 82 files changed, 308 insertions(+), 53 deletions(-) diff --git a/effects.cpp b/effects.cpp index bbf5a45858..daf4a754be 100644 --- a/effects.cpp +++ b/effects.cpp @@ -97,7 +97,6 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type) , fullscreen_effect(0) , next_window_quad_type(EFFECT_QUAD_TYPE_START) , mouse_poll_ref_count(0) - , current_paint_effectframe(0) { Workspace *ws = Workspace::self(); connect(ws, SIGNAL(currentDesktopChanged(int)), this, SLOT(slotDesktopChanged(int))); @@ -203,54 +202,54 @@ void EffectsHandlerImpl::reconfigure() // the idea is that effects call this function again which calls the next one void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData& data, int time) { - if (current_paint_screen < loaded_effects.size()) { - loaded_effects[current_paint_screen++].second->prePaintScreen(data, time); - --current_paint_screen; + if (m_currentPaintScreenIterator != m_activeEffects.end()) { + (*m_currentPaintScreenIterator++)->prePaintScreen(data, time); + --m_currentPaintScreenIterator; } // no special final code } void EffectsHandlerImpl::paintScreen(int mask, QRegion region, ScreenPaintData& data) { - if (current_paint_screen < loaded_effects.size()) { - loaded_effects[current_paint_screen++].second->paintScreen(mask, region, data); - --current_paint_screen; + if (m_currentPaintScreenIterator != m_activeEffects.end()) { + (*m_currentPaintScreenIterator++)->paintScreen(mask, region, data); + --m_currentPaintScreenIterator; } else scene->finalPaintScreen(mask, region, data); } void EffectsHandlerImpl::postPaintScreen() { - if (current_paint_screen < loaded_effects.size()) { - loaded_effects[current_paint_screen++].second->postPaintScreen(); - --current_paint_screen; + if (m_currentPaintScreenIterator != m_activeEffects.end()) { + (*m_currentPaintScreenIterator++)->postPaintScreen(); + --m_currentPaintScreenIterator; } // no special final code } void EffectsHandlerImpl::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) { - if (current_paint_window < loaded_effects.size()) { - loaded_effects[current_paint_window++].second->prePaintWindow(w, data, time); - --current_paint_window; + if (m_currentPaintWindowIterator != m_activeEffects.end()) { + (*m_currentPaintWindowIterator++)->prePaintWindow(w, data, time); + --m_currentPaintWindowIterator; } // no special final code } void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) { - if (current_paint_window < loaded_effects.size()) { - loaded_effects[current_paint_window++].second->paintWindow(w, mask, region, data); - --current_paint_window; + if (m_currentPaintWindowIterator != m_activeEffects.end()) { + (*m_currentPaintWindowIterator++)->paintWindow(w, mask, region, data); + --m_currentPaintWindowIterator; } else scene->finalPaintWindow(static_cast(w), mask, region, data); } void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity) { - if (current_paint_effectframe < loaded_effects.size()) { - loaded_effects[current_paint_effectframe++].second->paintEffectFrame(frame, region, opacity, frameOpacity); - --current_paint_effectframe; + if (m_currentPaintEffectFrameIterator != m_activeEffects.end()) { + (*m_currentPaintEffectFrameIterator++)->paintEffectFrame(frame, region, opacity, frameOpacity); + --m_currentPaintEffectFrameIterator; } else { const EffectFrameImpl* frameImpl = static_cast(frame); frameImpl->finalRender(region, opacity, frameOpacity); @@ -259,9 +258,9 @@ void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, QRegion region, do void EffectsHandlerImpl::postPaintWindow(EffectWindow* w) { - if (current_paint_window < loaded_effects.size()) { - loaded_effects[current_paint_window++].second->postPaintWindow(w); - --current_paint_window; + if (m_currentPaintWindowIterator != m_activeEffects.end()) { + (*m_currentPaintWindowIterator++)->postPaintWindow(w); + --m_currentPaintWindowIterator; } // no special final code } @@ -276,18 +275,18 @@ bool EffectsHandlerImpl::provides(Effect::Feature ef) void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) { - if (current_draw_window < loaded_effects.size()) { - loaded_effects[current_draw_window++].second->drawWindow(w, mask, region, data); - --current_draw_window; + if (m_currentDrawWindowIterator != m_activeEffects.end()) { + (*m_currentDrawWindowIterator++)->drawWindow(w, mask, region, data); + --m_currentDrawWindowIterator; } else scene->finalDrawWindow(static_cast(w), mask, region, data); } void EffectsHandlerImpl::buildQuads(EffectWindow* w, WindowQuadList& quadList) { - if (current_build_quads < loaded_effects.size()) { - loaded_effects[current_build_quads++].second->buildQuads(w, quadList); - --current_build_quads; + if (m_currentBuildQuadsIterator != m_activeEffects.end()) { + (*m_currentBuildQuadsIterator++)->buildQuads(w, quadList); + --m_currentBuildQuadsIterator; } } @@ -309,10 +308,17 @@ bool EffectsHandlerImpl::decorationSupportsBlurBehind() const // start another painting pass void EffectsHandlerImpl::startPaint() { - assert(current_paint_screen == 0); - assert(current_paint_window == 0); - assert(current_draw_window == 0); - assert(current_build_quads == 0); + m_activeEffects.clear(); + for(QVector< KWin::EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it) { + if (it->second->isActive()) { + m_activeEffects << it->second; + } + } + m_currentDrawWindowIterator = m_activeEffects.begin(); + m_currentPaintWindowIterator = m_activeEffects.begin(); + m_currentPaintScreenIterator = m_activeEffects.begin(); + m_currentPaintEffectFrameIterator = m_activeEffects.begin(); + m_currentBuildQuadsIterator = m_activeEffects.begin(); } void EffectsHandlerImpl::slotClientMaximized(KWin::Client *c, KDecorationDefines::MaximizeMode maxMode) @@ -1087,10 +1093,6 @@ QStringList EffectsHandlerImpl::listOfEffects() const bool EffectsHandlerImpl::loadEffect(const QString& name, bool checkDefault) { Workspace::self()->addRepaintFull(); - assert(current_paint_screen == 0); - assert(current_paint_window == 0); - assert(current_draw_window == 0); - assert(current_build_quads == 0); if (!name.startsWith(QLatin1String("kwin4_effect_"))) kWarning(1212) << "Effect names usually have kwin4_effect_ prefix" ; @@ -1201,10 +1203,6 @@ bool EffectsHandlerImpl::loadEffect(const QString& name, bool checkDefault) void EffectsHandlerImpl::unloadEffect(const QString& name) { Workspace::self()->addRepaintFull(); - assert(current_paint_screen == 0); - assert(current_paint_window == 0); - assert(current_draw_window == 0); - assert(current_build_quads == 0); for (QMap< int, EffectPair >::iterator it = effect_order.begin(); it != effect_order.end(); ++it) { if (it.value().first == name) { diff --git a/effects.h b/effects.h index 0d57339df1..59faa89f58 100644 --- a/effects.h +++ b/effects.h @@ -208,7 +208,14 @@ protected: QHash< long, int > registered_atoms; int next_window_quad_type; int mouse_poll_ref_count; - int current_paint_effectframe; + +private: + QList< Effect* > m_activeEffects; + QList< Effect* >::iterator m_currentDrawWindowIterator; + QList< Effect* >::iterator m_currentPaintWindowIterator; + QList< Effect* >::iterator m_currentPaintEffectFrameIterator; + QList< Effect* >::iterator m_currentPaintScreenIterator; + QList< Effect* >::iterator m_currentBuildQuadsIterator; }; class EffectWindowImpl : public EffectWindow diff --git a/effects/boxswitch/boxswitch.cpp b/effects/boxswitch/boxswitch.cpp index 5a09382412..d69c4201ca 100644 --- a/effects/boxswitch/boxswitch.cpp +++ b/effects/boxswitch/boxswitch.cpp @@ -947,6 +947,11 @@ void BoxSwitchEffect::activateFromProxy(int mode, bool animate, bool showText, f } } +bool BoxSwitchEffect::isActive() const +{ + return mActivated; +} + BoxSwitchEffect::ItemInfo::ItemInfo() : iconFrame(NULL) { diff --git a/effects/boxswitch/boxswitch.h b/effects/boxswitch/boxswitch.h index c0258a8d25..cfb6b47a55 100644 --- a/effects/boxswitch/boxswitch.h +++ b/effects/boxswitch/boxswitch.h @@ -55,6 +55,7 @@ public: virtual void windowInputMouseEvent(Window w, QEvent* e); virtual void* proxy(); + virtual bool isActive() const; void activateFromProxy(int mode, bool animate, bool showText, float positioningFactor); void paintWindowsBox(const QRegion& region); diff --git a/effects/coverswitch/coverswitch.cpp b/effects/coverswitch/coverswitch.cpp index 45c762138e..bdf2fbe65e 100644 --- a/effects/coverswitch/coverswitch.cpp +++ b/effects/coverswitch/coverswitch.cpp @@ -995,4 +995,9 @@ void CoverSwitchEffect::slotWindowClosed(EffectWindow* c) } } +bool CoverSwitchEffect::isActive() const +{ + return mActivated || stop || stopRequested; +} + } // namespace diff --git a/effects/coverswitch/coverswitch.h b/effects/coverswitch/coverswitch.h index 26e9a4f3ab..b49a36e660 100644 --- a/effects/coverswitch/coverswitch.h +++ b/effects/coverswitch/coverswitch.h @@ -48,6 +48,7 @@ public: virtual void postPaintScreen(); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void windowInputMouseEvent(Window w, QEvent* e); + virtual bool isActive() const; static bool supported(); diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index 91997bd3e7..f48f0f731a 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -2087,4 +2087,9 @@ void CubeEffect::unregisterCubeInsideEffect(CubeInsideEffect* effect) m_cubeInsideEffects.removeAll(effect); } +bool CubeEffect::isActive() const +{ + return activated; +} + } // namespace diff --git a/effects/cube/cube.h b/effects/cube/cube.h index c04a8659a7..ff1bd5ac90 100644 --- a/effects/cube/cube.h +++ b/effects/cube/cube.h @@ -50,6 +50,7 @@ public: virtual bool borderActivated(ElectricBorder border); virtual void grabbedKeyboardEvent(QKeyEvent* e); virtual void windowInputMouseEvent(Window w, QEvent* e); + virtual bool isActive() const; // proxy functions virtual void* proxy(); diff --git a/effects/cube/cubeslide.cpp b/effects/cube/cubeslide.cpp index a1332ead66..ed1f51875b 100644 --- a/effects/cube/cubeslide.cpp +++ b/effects/cube/cubeslide.cpp @@ -617,4 +617,9 @@ void CubeSlideEffect::windowMovingChanged(float progress, RotationDirection dire effects->addRepaintFull(); } +bool CubeSlideEffect::isActive() const +{ + return !slideRotations.isEmpty(); +} + } // namespace diff --git a/effects/cube/cubeslide.h b/effects/cube/cubeslide.h index 66f96ad4f3..ffbda88f6a 100644 --- a/effects/cube/cubeslide.h +++ b/effects/cube/cubeslide.h @@ -42,6 +42,7 @@ public: virtual void postPaintScreen(); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); + virtual bool isActive() const; static bool supported(); diff --git a/effects/dashboard/dashboard.cpp b/effects/dashboard/dashboard.cpp index ccee74b051..4f6dc65acf 100644 --- a/effects/dashboard/dashboard.cpp +++ b/effects/dashboard/dashboard.cpp @@ -199,4 +199,9 @@ void DashboardEffect::slotWindowClosed(EffectWindow* w) } } +bool DashboardEffect::isActive() const +{ + return transformWindow; +} + } // namespace diff --git a/effects/dashboard/dashboard.h b/effects/dashboard/dashboard.h index 4b3cbafa80..46d3e98129 100644 --- a/effects/dashboard/dashboard.h +++ b/effects/dashboard/dashboard.h @@ -43,6 +43,7 @@ public: virtual void propagate(); virtual void reconfigure(ReconfigureFlags); virtual void unpropagate(); + virtual bool isActive() const; public Q_SLOTS: void slotWindowAdded(EffectWindow* c); diff --git a/effects/desktopgrid/desktopgrid.cpp b/effects/desktopgrid/desktopgrid.cpp index 2f5ed2a0cf..f454814040 100644 --- a/effects/desktopgrid/desktopgrid.cpp +++ b/effects/desktopgrid/desktopgrid.cpp @@ -1221,10 +1221,10 @@ void DesktopGridEffect::globalShortcutChanged(const QKeySequence& seq) shortcut = KShortcut(seq); } -bool DesktopGridEffect::isMotionManagerMovingWindows() +bool DesktopGridEffect::isMotionManagerMovingWindows() const { if (isUsingPresentWindows()) { - QList::iterator it; + QList::const_iterator it; for (it = m_managers.begin(); it != m_managers.end(); ++it) { if ((*it).areWindowsMoving()) return true; @@ -1372,6 +1372,11 @@ void DesktopGridEffect::desktopsRemoved(int old) effects->addRepaintFull(); } +bool DesktopGridEffect::isActive() const +{ + return timeline.currentValue() != 0 || (isUsingPresentWindows() && isMotionManagerMovingWindows()); +} + /************************************************ * DesktopButtonView ************************************************/ diff --git a/effects/desktopgrid/desktopgrid.h b/effects/desktopgrid/desktopgrid.h index 8a8ddabeb9..b420389a01 100644 --- a/effects/desktopgrid/desktopgrid.h +++ b/effects/desktopgrid/desktopgrid.h @@ -75,6 +75,7 @@ public: virtual void windowInputMouseEvent(Window w, QEvent* e); virtual void grabbedKeyboardEvent(QKeyEvent* e); virtual bool borderActivated(ElectricBorder border); + virtual bool isActive() const; enum { LayoutPager, LayoutAutomatic, LayoutCustom }; // Layout modes @@ -106,7 +107,7 @@ private: void setup(); void setupGrid(); void finish(); - bool isMotionManagerMovingWindows(); + bool isMotionManagerMovingWindows() const; bool isUsingPresentWindows() const; QRectF moveGeometryToDesktop(int desktop) const; void desktopsAdded(int old); diff --git a/effects/dialogparent/dialogparent.cpp b/effects/dialogparent/dialogparent.cpp index d5a8d3fcb6..ac9493a555 100644 --- a/effects/dialogparent/dialogparent.cpp +++ b/effects/dialogparent/dialogparent.cpp @@ -95,4 +95,9 @@ void DialogParentEffect::slotWindowClosed(EffectWindow* w) effectStrength.remove(w); } +bool DialogParentEffect::isActive() const +{ + return !effectStrength.isEmpty(); +} + } // namespace diff --git a/effects/dialogparent/dialogparent.h b/effects/dialogparent/dialogparent.h index c966f60cce..439c67eb73 100644 --- a/effects/dialogparent/dialogparent.h +++ b/effects/dialogparent/dialogparent.h @@ -46,6 +46,8 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); + virtual bool isActive() const; + public Q_SLOTS: void slotWindowClosed(EffectWindow *c); void slotWindowActivated(EffectWindow *c); diff --git a/effects/dimscreen/dimscreen.cpp b/effects/dimscreen/dimscreen.cpp index cb1df9f6bb..fd4c15a6b3 100644 --- a/effects/dimscreen/dimscreen.cpp +++ b/effects/dimscreen/dimscreen.cpp @@ -108,4 +108,10 @@ void DimScreenEffect::slotWindowActivated(EffectWindow *w) } } } + +bool DimScreenEffect::isActive() const +{ + return mActivated; +} + } // namespace diff --git a/effects/dimscreen/dimscreen.h b/effects/dimscreen/dimscreen.h index 744d1149a3..ee8c114c41 100644 --- a/effects/dimscreen/dimscreen.h +++ b/effects/dimscreen/dimscreen.h @@ -39,6 +39,7 @@ public: virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void postPaintScreen(); virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data); + virtual bool isActive() const; public Q_SLOTS: void slotWindowActivated(EffectWindow *w); diff --git a/effects/explosion/explosion.cpp b/effects/explosion/explosion.cpp index 75f56ac271..bdff254f54 100644 --- a/effects/explosion/explosion.cpp +++ b/effects/explosion/explosion.cpp @@ -202,5 +202,10 @@ void ExplosionEffect::slotWindowDeleted(EffectWindow* c) mWindows.remove(c); } +bool ExplosionEffect::isActive() const +{ + return mActiveAnimations > 0; +} + } // namespace diff --git a/effects/explosion/explosion.h b/effects/explosion/explosion.h index b112ab1980..8a343c7908 100644 --- a/effects/explosion/explosion.h +++ b/effects/explosion/explosion.h @@ -47,6 +47,7 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); + virtual bool isActive() const; static bool supported(); diff --git a/effects/fade/fade.cpp b/effects/fade/fade.cpp index 52f0e3758f..271efd8081 100644 --- a/effects/fade/fade.cpp +++ b/effects/fade/fade.cpp @@ -199,4 +199,9 @@ bool FadeEffect::isFadeWindow(EffectWindow* w) return (!w->isDesktop() && !w->isUtility()); } +bool FadeEffect::isActive() const +{ + return !windows.isEmpty(); +} + } // namespace diff --git a/effects/fade/fade.h b/effects/fade/fade.h index c26298adff..ae92c1f4af 100644 --- a/effects/fade/fade.h +++ b/effects/fade/fade.h @@ -36,6 +36,7 @@ public: virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); + virtual bool isActive() const; // TODO react also on virtual desktop changes diff --git a/effects/fadedesktop/fadedesktop.cpp b/effects/fadedesktop/fadedesktop.cpp index d07b9acf58..5d71ef7355 100644 --- a/effects/fadedesktop/fadedesktop.cpp +++ b/effects/fadedesktop/fadedesktop.cpp @@ -107,6 +107,11 @@ void FadeDesktopEffect::slotDesktopChanged(int old) effects->addRepaintFull(); } +bool FadeDesktopEffect::isActive() const +{ + return m_fading; +} + } // namespace #include "fadedesktop.moc" diff --git a/effects/fadedesktop/fadedesktop.h b/effects/fadedesktop/fadedesktop.h index caee1a63de..d5d8b36784 100644 --- a/effects/fadedesktop/fadedesktop.h +++ b/effects/fadedesktop/fadedesktop.h @@ -39,6 +39,7 @@ public: virtual void postPaintScreen(); virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time); virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data); + virtual bool isActive() const; private Q_SLOTS: void slotDesktopChanged(int old); diff --git a/effects/fallapart/fallapart.cpp b/effects/fallapart/fallapart.cpp index 16fd6130c1..5db5ee7350 100644 --- a/effects/fallapart/fallapart.cpp +++ b/effects/fallapart/fallapart.cpp @@ -160,4 +160,9 @@ void FallApartEffect::slotWindowDeleted(EffectWindow* c) windows.remove(c); } +bool FallApartEffect::isActive() const +{ + return !windows.isEmpty(); +} + } // namespace diff --git a/effects/fallapart/fallapart.h b/effects/fallapart/fallapart.h index a29ea0bca8..acc1446d6f 100644 --- a/effects/fallapart/fallapart.h +++ b/effects/fallapart/fallapart.h @@ -37,6 +37,7 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); + virtual bool isActive() const; public Q_SLOTS: void slotWindowClosed(EffectWindow *c); diff --git a/effects/flipswitch/flipswitch.cpp b/effects/flipswitch/flipswitch.cpp index b68c1c9960..f7f430728d 100644 --- a/effects/flipswitch/flipswitch.cpp +++ b/effects/flipswitch/flipswitch.cpp @@ -934,6 +934,11 @@ void FlipSwitchEffect::grabbedKeyboardEvent(QKeyEvent* e) } } +bool FlipSwitchEffect::isActive() const +{ + return m_active; +} + //************************************************************* // Item Info //************************************************************* diff --git a/effects/flipswitch/flipswitch.h b/effects/flipswitch/flipswitch.h index d06005e021..559e88ba1a 100644 --- a/effects/flipswitch/flipswitch.h +++ b/effects/flipswitch/flipswitch.h @@ -47,6 +47,7 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual bool borderActivated(ElectricBorder border); virtual void grabbedKeyboardEvent(QKeyEvent* e); + virtual bool isActive() const; static bool supported(); private Q_SLOTS: diff --git a/effects/glide/glide.cpp b/effects/glide/glide.cpp index 717bd54182..1c065e2611 100644 --- a/effects/glide/glide.cpp +++ b/effects/glide/glide.cpp @@ -226,6 +226,11 @@ bool GlideEffect::isGlideWindow(EffectWindow* w) return true; } +bool GlideEffect::isActive() const +{ + return !windows.isEmpty(); +} + GlideEffect::WindowInfo::WindowInfo() : deleted(false) , added(false) diff --git a/effects/glide/glide.h b/effects/glide/glide.h index bb793dd3af..5d1714f386 100644 --- a/effects/glide/glide.h +++ b/effects/glide/glide.h @@ -41,6 +41,7 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); + virtual bool isActive() const; static bool supported(); public Q_SLOTS: diff --git a/effects/highlightwindow/highlightwindow.cpp b/effects/highlightwindow/highlightwindow.cpp index b17562009d..2174033026 100644 --- a/effects/highlightwindow/highlightwindow.cpp +++ b/effects/highlightwindow/highlightwindow.cpp @@ -257,4 +257,9 @@ void HighlightWindowEffect::finishHighlighting() m_windowOpacity.constBegin().key()->addRepaintFull(); } +bool HighlightWindowEffect::isActive() const +{ + return !m_windowOpacity.isEmpty(); +} + } // namespace diff --git a/effects/highlightwindow/highlightwindow.h b/effects/highlightwindow/highlightwindow.h index c13a887b68..fa239656b2 100644 --- a/effects/highlightwindow/highlightwindow.h +++ b/effects/highlightwindow/highlightwindow.h @@ -36,6 +36,7 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); + virtual bool isActive() const; public Q_SLOTS: void slotWindowAdded(EffectWindow* w); diff --git a/effects/invert/invert.cpp b/effects/invert/invert.cpp index 69298807b0..0ef154520a 100644 --- a/effects/invert/invert.cpp +++ b/effects/invert/invert.cpp @@ -161,6 +161,11 @@ void InvertEffect::toggleWindow() effects->activeWindow()->addRepaintFull(); } +bool InvertEffect::isActive() const +{ + return m_valid && (m_allWindows || !m_windows.isEmpty()); +} + } // namespace #include "invert.moc" diff --git a/effects/invert/invert.h b/effects/invert/invert.h index 0d79ba4eb3..3dc49fb06f 100644 --- a/effects/invert/invert.h +++ b/effects/invert/invert.h @@ -44,6 +44,7 @@ public: virtual void prePaintScreen(ScreenPrePaintData &data, int time); virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time); virtual void paintEffectFrame(KWin::EffectFrame* frame, QRegion region, double opacity, double frameOpacity); + virtual bool isActive() const; static bool supported(); diff --git a/effects/login/login.cpp b/effects/login/login.cpp index fd26f52142..63d8479762 100644 --- a/effects/login/login.cpp +++ b/effects/login/login.cpp @@ -117,4 +117,9 @@ bool LoginEffect::isLoginSplash(EffectWindow* w) return false; } +bool LoginEffect::isActive() const +{ + return login_window != NULL; +} + } // namespace diff --git a/effects/login/login.h b/effects/login/login.h index 67b4d7ec9f..db30044ccc 100644 --- a/effects/login/login.h +++ b/effects/login/login.h @@ -38,6 +38,7 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void reconfigure(ReconfigureFlags); + virtual bool isActive() const; public Q_SLOTS: void slotWindowClosed(EffectWindow *w); diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index 7880daee22..cbc429bc9e 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -400,4 +400,9 @@ void LogoutEffect::slotPropertyNotify(EffectWindow* w, long a) canDoPersistent = true; } +bool LogoutEffect::isActive() const +{ + return progress != 0; +} + } // namespace diff --git a/effects/logout/logout.h b/effects/logout/logout.h index a6a00f81ad..f08152f2a3 100644 --- a/effects/logout/logout.h +++ b/effects/logout/logout.h @@ -44,6 +44,7 @@ public: virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); virtual void postPaintScreen(); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); + virtual bool isActive() const; public Q_SLOTS: void slotWindowAdded(EffectWindow* w); void slotWindowClosed(EffectWindow *w); diff --git a/effects/lookingglass/lookingglass.cpp b/effects/lookingglass/lookingglass.cpp index 783823efdf..07739d0b25 100644 --- a/effects/lookingglass/lookingglass.cpp +++ b/effects/lookingglass/lookingglass.cpp @@ -247,6 +247,11 @@ void LookingGlassEffect::postPaintScreen() } } +bool LookingGlassEffect::isActive() const +{ + return m_valid && m_enabled; +} + } // namespace #include "lookingglass.moc" diff --git a/effects/lookingglass/lookingglass.h b/effects/lookingglass/lookingglass.h index cba2242932..892f9a20ce 100644 --- a/effects/lookingglass/lookingglass.h +++ b/effects/lookingglass/lookingglass.h @@ -48,6 +48,7 @@ public: virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void postPaintScreen(); + virtual bool isActive() const; static bool supported(); diff --git a/effects/magiclamp/magiclamp.cpp b/effects/magiclamp/magiclamp.cpp index 6f2c6eaff9..269d499800 100644 --- a/effects/magiclamp/magiclamp.cpp +++ b/effects/magiclamp/magiclamp.cpp @@ -353,4 +353,9 @@ void MagicLampEffect::slotWindowUnminimized(EffectWindow* w) mTimeLineWindows[w]->setCurrentTime(mAnimationDuration); } +bool MagicLampEffect::isActive() const +{ + return !mTimeLineWindows.isEmpty(); +} + } // namespace diff --git a/effects/magiclamp/magiclamp.h b/effects/magiclamp/magiclamp.h index 774ddb7e2c..8000081632 100644 --- a/effects/magiclamp/magiclamp.h +++ b/effects/magiclamp/magiclamp.h @@ -40,6 +40,7 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); + virtual bool isActive() const; static bool supported(); diff --git a/effects/magnifier/magnifier.cpp b/effects/magnifier/magnifier.cpp index 3e216f6736..4ad90a3dfb 100644 --- a/effects/magnifier/magnifier.cpp +++ b/effects/magnifier/magnifier.cpp @@ -232,6 +232,11 @@ void MagnifierEffect::slotMouseChanged(const QPoint& pos, const QPoint& old, effects->addRepaintFull(); } +bool MagnifierEffect::isActive() const +{ + return zoom != 1.0 || zoom != target_zoom; +} + } // namespace #include "magnifier.moc" diff --git a/effects/magnifier/magnifier.h b/effects/magnifier/magnifier.h index 0e4e6750d2..b1b6f9e2b3 100644 --- a/effects/magnifier/magnifier.h +++ b/effects/magnifier/magnifier.h @@ -41,6 +41,7 @@ public: virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); virtual void postPaintScreen(); + virtual bool isActive() const; static bool supported(); private slots: void zoomIn(); diff --git a/effects/minimizeanimation/minimizeanimation.cpp b/effects/minimizeanimation/minimizeanimation.cpp index 8eb87c42d9..44d15ec049 100644 --- a/effects/minimizeanimation/minimizeanimation.cpp +++ b/effects/minimizeanimation/minimizeanimation.cpp @@ -148,5 +148,10 @@ void MinimizeAnimationEffect::slotWindowUnminimized(EffectWindow* w) timeline->setCurrentTime(timeline->duration()); } +bool MinimizeAnimationEffect::isActive() const +{ + return !mTimeLineWindows.isEmpty(); +} + } // namespace diff --git a/effects/minimizeanimation/minimizeanimation.h b/effects/minimizeanimation/minimizeanimation.h index 20fa156156..27e0dd37f9 100644 --- a/effects/minimizeanimation/minimizeanimation.h +++ b/effects/minimizeanimation/minimizeanimation.h @@ -43,6 +43,7 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); + virtual bool isActive() const; public Q_SLOTS: void slotWindowDeleted(EffectWindow *w); diff --git a/effects/mousemark/mousemark.cpp b/effects/mousemark/mousemark.cpp index 733f94af40..d8e91d9bae 100644 --- a/effects/mousemark/mousemark.cpp +++ b/effects/mousemark/mousemark.cpp @@ -186,6 +186,12 @@ MouseMarkEffect::Mark MouseMarkEffect::createArrow(QPoint arrow_start, QPoint ar return ret; } +bool MouseMarkEffect::isActive() const +{ + return !marks.isEmpty() || !drawing.isEmpty(); +} + + } // namespace #include "mousemark.moc" diff --git a/effects/mousemark/mousemark.h b/effects/mousemark/mousemark.h index 22094bea0f..845586ad65 100644 --- a/effects/mousemark/mousemark.h +++ b/effects/mousemark/mousemark.h @@ -36,6 +36,7 @@ public: ~MouseMarkEffect(); virtual void reconfigure(ReconfigureFlags); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); + virtual bool isActive() const; private slots: void clear(); void clearLast(); diff --git a/effects/outline/outline.cpp b/effects/outline/outline.cpp index d2990e076b..9b98f71bab 100644 --- a/effects/outline/outline.cpp +++ b/effects/outline/outline.cpp @@ -75,4 +75,9 @@ void OutlineEffect::slotShowOutline(const QRect& geometry) effects->addRepaint(geometry); } +bool OutlineEffect::isActive() const +{ + return m_active; +} + } // namespace diff --git a/effects/outline/outline.h b/effects/outline/outline.h index 9c144b4c4f..5d3df9c62a 100644 --- a/effects/outline/outline.h +++ b/effects/outline/outline.h @@ -35,6 +35,7 @@ public: virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); virtual bool provides(Feature feature); + virtual bool isActive() const; public Q_SLOTS: void slotShowOutline(const QRect &geometry); diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp index 95ecf95e40..5e7589c88c 100755 --- a/effects/presentwindows/presentwindows.cpp +++ b/effects/presentwindows/presentwindows.cpp @@ -2043,6 +2043,11 @@ void PresentWindowsEffect::globalShortcutChangedClass(const QKeySequence& seq) shortcutClass = KShortcut(seq); } +bool PresentWindowsEffect::isActive() const +{ + return m_activated || m_motionManager.managingWindows(); +} + /************************************************ * CloseWindowView ************************************************/ diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h index e0c982ef44..08aa26236d 100644 --- a/effects/presentwindows/presentwindows.h +++ b/effects/presentwindows/presentwindows.h @@ -104,6 +104,7 @@ public: virtual bool borderActivated(ElectricBorder border); virtual void windowInputMouseEvent(Window w, QEvent *e); virtual void grabbedKeyboardEvent(QKeyEvent *e); + virtual bool isActive() const; enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes enum PresentWindowsMode { diff --git a/effects/scalein/scalein.cpp b/effects/scalein/scalein.cpp index 732646d917..25d78df31d 100644 --- a/effects/scalein/scalein.cpp +++ b/effects/scalein/scalein.cpp @@ -95,4 +95,9 @@ void ScaleInEffect::slotWindowClosed(EffectWindow* c) delete mTimeLineWindows.take(c); } +bool ScaleInEffect::isActive() const +{ + return !mTimeLineWindows.isEmpty(); +} + } // namespace diff --git a/effects/scalein/scalein.h b/effects/scalein/scalein.h index 6038bf0a6e..8ae7504864 100644 --- a/effects/scalein/scalein.h +++ b/effects/scalein/scalein.h @@ -38,6 +38,7 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); + virtual bool isActive() const; // TODO react also on virtual desktop changes public Q_SLOTS: void slotWindowAdded(EffectWindow* c); diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp index d12d77df96..8431c70e8d 100644 --- a/effects/screenshot/screenshot.cpp +++ b/effects/screenshot/screenshot.cpp @@ -258,4 +258,9 @@ void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h) img = img.mirrored(); } +bool ScreenShotEffect::isActive() const +{ + return m_scheduledScreenshot != NULL; +} + } // namespace diff --git a/effects/screenshot/screenshot.h b/effects/screenshot/screenshot.h index 040ef61a70..0b9e6130a8 100644 --- a/effects/screenshot/screenshot.h +++ b/effects/screenshot/screenshot.h @@ -40,6 +40,7 @@ public: ScreenShotEffect(); virtual ~ScreenShotEffect(); virtual void postPaintScreen(); + virtual bool isActive() const; static bool supported(); static void convertFromGLImage(QImage &img, int w, int h); diff --git a/effects/sheet/sheet.cpp b/effects/sheet/sheet.cpp index c28a388db1..9156f0dd0b 100644 --- a/effects/sheet/sheet.cpp +++ b/effects/sheet/sheet.cpp @@ -186,6 +186,11 @@ bool SheetEffect::isSheetWindow(EffectWindow* w) return (w->isModal() || w->data(IsSheetWindow).toBool()); } +bool SheetEffect::isActive() const +{ + return !windows.isEmpty(); +} + SheetEffect::WindowInfo::WindowInfo() : deleted(false) , added(false) diff --git a/effects/sheet/sheet.h b/effects/sheet/sheet.h index a2bb1bab41..7ec739b20c 100644 --- a/effects/sheet/sheet.h +++ b/effects/sheet/sheet.h @@ -40,6 +40,7 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); + virtual bool isActive() const; static bool supported(); diff --git a/effects/slide/slide.cpp b/effects/slide/slide.cpp index 3e0df05e04..760fdd3613 100644 --- a/effects/slide/slide.cpp +++ b/effects/slide/slide.cpp @@ -230,6 +230,11 @@ void SlideEffect::slotDesktopChanged(int old, int current) effects->addRepaintFull(); } +bool SlideEffect::isActive() const +{ + return slide; +} + } // namespace #include "slide.moc" diff --git a/effects/slide/slide.h b/effects/slide/slide.h index 9ad645e86f..8c91ad4fe0 100644 --- a/effects/slide/slide.h +++ b/effects/slide/slide.h @@ -41,6 +41,7 @@ public: virtual void postPaintScreen(); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); + virtual bool isActive() const; private Q_SLOTS: void slotDesktopChanged(int old, int current); diff --git a/effects/slideback/slideback.cpp b/effects/slideback/slideback.cpp index 562f2aa764..380b3d52af 100644 --- a/effects/slideback/slideback.cpp +++ b/effects/slideback/slideback.cpp @@ -376,4 +376,9 @@ QRect SlideBackEffect::getModalGroupGeometry(EffectWindow *w) return modalGroupGeometry; } +bool SlideBackEffect::isActive() const +{ + return motionManager.managingWindows(); +} + } //Namespace diff --git a/effects/slideback/slideback.h b/effects/slideback/slideback.h index 4c417ef1e7..0cba5561e7 100644 --- a/effects/slideback/slideback.h +++ b/effects/slideback/slideback.h @@ -40,6 +40,7 @@ public: virtual void prePaintScreen(ScreenPrePaintData &data, int time); virtual void postPaintScreen(); + virtual bool isActive() const; public Q_SLOTS: void slotWindowAdded(EffectWindow *w); diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 4ffd3e2c17..1065bfc7c4 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -246,4 +246,10 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a) } mWindowsData[ w ] = animData; } + +bool SlidingPopupsEffect::isActive() const +{ + return !mAppearingWindows.isEmpty() || !mDisappearingWindows.isEmpty(); +} + } // namespace diff --git a/effects/slidingpopups/slidingpopups.h b/effects/slidingpopups/slidingpopups.h index bc58f953ed..eca9e2e5a4 100644 --- a/effects/slidingpopups/slidingpopups.h +++ b/effects/slidingpopups/slidingpopups.h @@ -41,6 +41,7 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); virtual void reconfigure(ReconfigureFlags flags); + virtual bool isActive() const; // TODO react also on virtual desktop changes public Q_SLOTS: diff --git a/effects/snaphelper/snaphelper.cpp b/effects/snaphelper/snaphelper.cpp index 8b12532353..e1b15c686b 100644 --- a/effects/snaphelper/snaphelper.cpp +++ b/effects/snaphelper/snaphelper.cpp @@ -216,4 +216,9 @@ void SnapHelperEffect::slotWindowFinishUserMovedResized(EffectWindow *w) } } +bool SnapHelperEffect::isActive() const +{ + return m_timeline.currentValue() != 0.0; +} + } // namespace diff --git a/effects/snaphelper/snaphelper.h b/effects/snaphelper/snaphelper.h index b2ab2e0253..ee60f8fe43 100644 --- a/effects/snaphelper/snaphelper.h +++ b/effects/snaphelper/snaphelper.h @@ -39,6 +39,7 @@ public: virtual void prePaintScreen(ScreenPrePaintData &data, int time); virtual void postPaintScreen(); + virtual bool isActive() const; static bool supported(); diff --git a/effects/startupfeedback/startupfeedback.cpp b/effects/startupfeedback/startupfeedback.cpp index 0d2884b71a..a0d290be77 100644 --- a/effects/startupfeedback/startupfeedback.cpp +++ b/effects/startupfeedback/startupfeedback.cpp @@ -417,4 +417,9 @@ QRect StartupFeedbackEffect::feedbackRect() const return rect; } +bool StartupFeedbackEffect::isActive() const +{ + return m_active; +} + } // namespace diff --git a/effects/startupfeedback/startupfeedback.h b/effects/startupfeedback/startupfeedback.h index 1e272c9099..4401083cc0 100644 --- a/effects/startupfeedback/startupfeedback.h +++ b/effects/startupfeedback/startupfeedback.h @@ -41,6 +41,7 @@ public: virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); virtual void postPaintScreen(); + virtual bool isActive() const; static bool supported(); diff --git a/effects/taskbarthumbnail/taskbarthumbnail.cpp b/effects/taskbarthumbnail/taskbarthumbnail.cpp index dc5eeda4a2..c1cfdd1799 100644 --- a/effects/taskbarthumbnail/taskbarthumbnail.cpp +++ b/effects/taskbarthumbnail/taskbarthumbnail.cpp @@ -154,4 +154,9 @@ void TaskbarThumbnailEffect::slotPropertyNotify(EffectWindow* w, long a) } } +bool TaskbarThumbnailEffect::isActive() const +{ + return !thumbnails.isEmpty(); +} + } // namespace diff --git a/effects/taskbarthumbnail/taskbarthumbnail.h b/effects/taskbarthumbnail/taskbarthumbnail.h index 5412fe9a77..77e5294cb8 100644 --- a/effects/taskbarthumbnail/taskbarthumbnail.h +++ b/effects/taskbarthumbnail/taskbarthumbnail.h @@ -38,6 +38,7 @@ public: virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); + virtual bool isActive() const; public Q_SLOTS: void slotWindowAdded(EffectWindow *w); diff --git a/effects/thumbnailaside/thumbnailaside.cpp b/effects/thumbnailaside/thumbnailaside.cpp index 99bcf9a43d..3a1b4e0bba 100644 --- a/effects/thumbnailaside/thumbnailaside.cpp +++ b/effects/thumbnailaside/thumbnailaside.cpp @@ -172,6 +172,11 @@ void ThumbnailAsideEffect::repaintAll() effects->addRepaint(d.rect); } +bool ThumbnailAsideEffect::isActive() const +{ + return !windows.isEmpty(); +} + } // namespace #include "thumbnailaside.moc" diff --git a/effects/thumbnailaside/thumbnailaside.h b/effects/thumbnailaside/thumbnailaside.h index e1af63e0b7..323e2fdc45 100644 --- a/effects/thumbnailaside/thumbnailaside.h +++ b/effects/thumbnailaside/thumbnailaside.h @@ -48,6 +48,7 @@ private slots: void slotWindowClosed(EffectWindow *w); void slotWindowGeometryShapeChanged(EffectWindow *w, const QRect &old); void slotWindowDamaged(EffectWindow* w, const QRect& damage); + virtual bool isActive() const; private: void addThumbnail(EffectWindow* w); void removeThumbnail(EffectWindow* w); diff --git a/effects/trackmouse/trackmouse.cpp b/effects/trackmouse/trackmouse.cpp index 14fe15ab35..8c95a9a567 100644 --- a/effects/trackmouse/trackmouse.cpp +++ b/effects/trackmouse/trackmouse.cpp @@ -209,4 +209,9 @@ void TrackMouseEffect::loadTexture() textureSize = im.size(); } +bool TrackMouseEffect::isActive() const +{ + return active; +} + } // namespace diff --git a/effects/trackmouse/trackmouse.h b/effects/trackmouse/trackmouse.h index e78c3846b5..d43290d478 100644 --- a/effects/trackmouse/trackmouse.h +++ b/effects/trackmouse/trackmouse.h @@ -41,6 +41,7 @@ public: virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); virtual void postPaintScreen(); virtual void reconfigure(ReconfigureFlags); + virtual bool isActive() const; private slots: void toggle(); void slotMouseChanged(const QPoint& pos, const QPoint& old, diff --git a/effects/windowgeometry/windowgeometry.cpp b/effects/windowgeometry/windowgeometry.cpp index d682751488..6d772af00d 100644 --- a/effects/windowgeometry/windowgeometry.cpp +++ b/effects/windowgeometry/windowgeometry.cpp @@ -178,3 +178,7 @@ void WindowGeometry::slotWindowStepUserMovedResized(EffectWindow *w, const QRect } } +bool WindowGeometry::isActive() const +{ + return iAmActive; +} diff --git a/effects/windowgeometry/windowgeometry.h b/effects/windowgeometry/windowgeometry.h index d9b632b12c..ba20c05d05 100644 --- a/effects/windowgeometry/windowgeometry.h +++ b/effects/windowgeometry/windowgeometry.h @@ -38,6 +38,7 @@ public: } void reconfigure(ReconfigureFlags); void paintScreen(int mask, QRegion region, ScreenPaintData &data); + virtual bool isActive() const; private slots: void toggle(); diff --git a/effects/wobblywindows/wobblywindows.cpp b/effects/wobblywindows/wobblywindows.cpp index f70d7e0967..c7d30febc1 100644 --- a/effects/wobblywindows/wobblywindows.cpp +++ b/effects/wobblywindows/wobblywindows.cpp @@ -1218,6 +1218,10 @@ void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobbly wwi.buffer = tmp; } +bool WobblyWindowsEffect::isActive() const +{ + return !windows.isEmpty(); +} } // namespace KWin diff --git a/effects/wobblywindows/wobblywindows.h b/effects/wobblywindows/wobblywindows.h index d6b262b9fe..d4844d3bb1 100644 --- a/effects/wobblywindows/wobblywindows.h +++ b/effects/wobblywindows/wobblywindows.h @@ -35,6 +35,7 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); + virtual bool isActive() const; // Wobbly model parameters void setStiffness(qreal stiffness); diff --git a/effects/zoom/zoom.cpp b/effects/zoom/zoom.cpp index 31d4c7855e..4131399462 100644 --- a/effects/zoom/zoom.cpp +++ b/effects/zoom/zoom.cpp @@ -492,6 +492,11 @@ void ZoomEffect::focusChanged(int px, int py, int rx, int ry, int rwidth, int rh } } +bool ZoomEffect::isActive() const +{ + return zoom != 1.0 || zoom != target_zoom; +} + } // namespace #include "zoom.moc" diff --git a/effects/zoom/zoom.h b/effects/zoom/zoom.h index fee4dd1f09..d08a82a640 100644 --- a/effects/zoom/zoom.h +++ b/effects/zoom/zoom.h @@ -43,6 +43,7 @@ public: virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); virtual void postPaintScreen(); + virtual bool isActive() const; private slots: void zoomIn(); void zoomOut(); diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index 857cc425b5..43ab44a599 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -171,6 +171,11 @@ bool Effect::provides(Feature) return false; } +bool Effect::isActive() const +{ + return true; +} + void Effect::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) { effects->drawWindow(w, mask, region, data); @@ -229,11 +234,7 @@ double Effect::animationTime(int defaultTime) //**************************************** EffectsHandler::EffectsHandler(CompositingType type) - : current_paint_screen(0) - , current_paint_window(0) - , current_draw_window(0) - , current_build_quads(0) - , compositing_type(type) + : compositing_type(type) { if (compositing_type == NoCompositing) return; diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 07a27a1ab8..fa1b476dc1 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -447,6 +447,23 @@ public: virtual bool borderActivated(ElectricBorder border); + /** + * Overwrite this method to indicate whether your effect will be doing something in + * the next frame to be rendered. If the method returns @c false the effect will be + * excluded from the chained methods in the next rendered frame. + * + * This method is called always directly before the paint loop begins. So it is totally + * fine to e.g. react on a window event, issue a repaint to trigger an animation and + * change a flag to indicate that this method returns @c true. + * + * As the method is called each frame, you should not perform complex calculations. + * Best use just a boolean flag. + * + * The default implementation of this method returns @c true. + * @since 4.8 + **/ + virtual bool isActive() const; + static int displayWidth(); static int displayHeight(); static QPoint cursorPos(); @@ -1023,10 +1040,6 @@ protected: QHash< QString, KLibrary* > effect_libraries; QList< InputWindowPair > input_windows; //QHash< QString, EffectFactory* > effect_factories; - int current_paint_screen; - int current_paint_window; - int current_draw_window; - int current_build_quads; CompositingType compositing_type; };