From ae7be07d0f88f3f9ef5e1e655fbed076dfe4c948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 29 Mar 2012 20:12:34 +0200 Subject: [PATCH] Effects Hook to paint a desktop A specialised paintScreen method to render all windows of one desktop. It's intended to be called during an already started paintScreen process to get e.g. a thumbnail of a desktop. Currently not yet exported to the Effects. --- effects.cpp | 18 ++++++++++++++++++ effects.h | 19 +++++++++++++++++++ scene.cpp | 10 ++++++++-- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/effects.cpp b/effects.cpp index 7deac29816..4443c5ba9f 100644 --- a/effects.cpp +++ b/effects.cpp @@ -215,6 +215,8 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) , m_compositor(compositor) , m_scene(scene) , m_screenLockerWatcher(new ScreenLockerWatcher(this)) + , m_desktopRendering(false) + , m_currentRenderedDesktop(0) { new EffectsAdaptor(this); QDBusConnection dbus = QDBusConnection::sessionBus(); @@ -373,6 +375,22 @@ void EffectsHandlerImpl::paintScreen(int mask, QRegion region, ScreenPaintData& m_scene->finalPaintScreen(mask, region, data); } +void EffectsHandlerImpl::paintDesktop(int desktop, int mask, QRegion region, ScreenPaintData &data) +{ + if (desktop < 1 || desktop > numberOfDesktops()) { + return; + } + m_currentRenderedDesktop = desktop; + m_desktopRendering = true; + // save the paint screen iterator + QList::iterator savedIterator = m_currentPaintScreenIterator; + m_currentPaintScreenIterator = m_activeEffects.begin(); + effects->paintScreen(mask, region, data); + // restore the saved iterator + m_currentPaintScreenIterator = savedIterator; + m_desktopRendering = false; +} + void EffectsHandlerImpl::postPaintScreen() { if (m_currentPaintScreenIterator != m_activeEffects.end()) { diff --git a/effects.h b/effects.h index 742aa59fb6..3ecad8ebac 100644 --- a/effects.h +++ b/effects.h @@ -61,6 +61,10 @@ public: virtual ~EffectsHandlerImpl(); virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); + /** + * Special hook to perform a paintScreen but just with the windows on @p desktop. + **/ + void paintDesktop(int desktop, int mask, QRegion region, ScreenPaintData& data); virtual void postPaintScreen(); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); @@ -180,6 +184,19 @@ public: QList elevatedWindows() const; QStringList activeEffects() const; + /** + * @returns Whether we are currently in a desktop rendering process triggered by paintDesktop hook + **/ + bool isDesktopRendering() const { + return m_desktopRendering; + } + /** + * @returns the desktop currently being rendered in the paintDesktop hook. + **/ + int currentRenderedDesktop() const { + return m_currentRenderedDesktop; + } + public Q_SLOTS: void slotCurrentTabAboutToChange(EffectWindow* from, EffectWindow* to); void slotTabAdded(EffectWindow* from, EffectWindow* to); @@ -248,6 +265,8 @@ private: Scene *m_scene; QList< InputWindowPair > input_windows; ScreenLockerWatcher *m_screenLockerWatcher; + bool m_desktopRendering; + int m_currentRenderedDesktop; }; class EffectWindowImpl : public EffectWindow diff --git a/scene.cpp b/scene.cpp index 93a3305287..4f0a4b7c36 100644 --- a/scene.cpp +++ b/scene.cpp @@ -589,8 +589,14 @@ void Scene::Window::resetPaintingEnabled() disable_painting = 0; if (toplevel->isDeleted()) disable_painting |= PAINT_DISABLED_BY_DELETE; - if (!toplevel->isOnCurrentDesktop()) - disable_painting |= PAINT_DISABLED_BY_DESKTOP; + if (static_cast(effects)->isDesktopRendering()) { + if (!toplevel->isOnDesktop(static_cast(effects)->currentRenderedDesktop())) { + disable_painting |= PAINT_DISABLED_BY_DESKTOP; + } + } else { + if (!toplevel->isOnCurrentDesktop()) + disable_painting |= PAINT_DISABLED_BY_DESKTOP; + } if (!toplevel->isOnCurrentActivity()) disable_painting |= PAINT_DISABLED_BY_ACTIVITY; if (toplevel->isClient()) {