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.
This commit is contained in:
Martin Gräßlin 2012-03-29 20:12:34 +02:00
parent 8037e6529c
commit ae7be07d0f
3 changed files with 45 additions and 2 deletions

View file

@ -215,6 +215,8 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
, m_compositor(compositor) , m_compositor(compositor)
, m_scene(scene) , m_scene(scene)
, m_screenLockerWatcher(new ScreenLockerWatcher(this)) , m_screenLockerWatcher(new ScreenLockerWatcher(this))
, m_desktopRendering(false)
, m_currentRenderedDesktop(0)
{ {
new EffectsAdaptor(this); new EffectsAdaptor(this);
QDBusConnection dbus = QDBusConnection::sessionBus(); QDBusConnection dbus = QDBusConnection::sessionBus();
@ -373,6 +375,22 @@ void EffectsHandlerImpl::paintScreen(int mask, QRegion region, ScreenPaintData&
m_scene->finalPaintScreen(mask, region, data); 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<Effect*>::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() void EffectsHandlerImpl::postPaintScreen()
{ {
if (m_currentPaintScreenIterator != m_activeEffects.end()) { if (m_currentPaintScreenIterator != m_activeEffects.end()) {

View file

@ -61,6 +61,10 @@ public:
virtual ~EffectsHandlerImpl(); virtual ~EffectsHandlerImpl();
virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); 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 postPaintScreen();
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
@ -180,6 +184,19 @@ public:
QList<EffectWindow*> elevatedWindows() const; QList<EffectWindow*> elevatedWindows() const;
QStringList activeEffects() 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: public Q_SLOTS:
void slotCurrentTabAboutToChange(EffectWindow* from, EffectWindow* to); void slotCurrentTabAboutToChange(EffectWindow* from, EffectWindow* to);
void slotTabAdded(EffectWindow* from, EffectWindow* to); void slotTabAdded(EffectWindow* from, EffectWindow* to);
@ -248,6 +265,8 @@ private:
Scene *m_scene; Scene *m_scene;
QList< InputWindowPair > input_windows; QList< InputWindowPair > input_windows;
ScreenLockerWatcher *m_screenLockerWatcher; ScreenLockerWatcher *m_screenLockerWatcher;
bool m_desktopRendering;
int m_currentRenderedDesktop;
}; };
class EffectWindowImpl : public EffectWindow class EffectWindowImpl : public EffectWindow

View file

@ -589,8 +589,14 @@ void Scene::Window::resetPaintingEnabled()
disable_painting = 0; disable_painting = 0;
if (toplevel->isDeleted()) if (toplevel->isDeleted())
disable_painting |= PAINT_DISABLED_BY_DELETE; disable_painting |= PAINT_DISABLED_BY_DELETE;
if (!toplevel->isOnCurrentDesktop()) if (static_cast<EffectsHandlerImpl*>(effects)->isDesktopRendering()) {
disable_painting |= PAINT_DISABLED_BY_DESKTOP; if (!toplevel->isOnDesktop(static_cast<EffectsHandlerImpl*>(effects)->currentRenderedDesktop())) {
disable_painting |= PAINT_DISABLED_BY_DESKTOP;
}
} else {
if (!toplevel->isOnCurrentDesktop())
disable_painting |= PAINT_DISABLED_BY_DESKTOP;
}
if (!toplevel->isOnCurrentActivity()) if (!toplevel->isOnCurrentActivity())
disable_painting |= PAINT_DISABLED_BY_ACTIVITY; disable_painting |= PAINT_DISABLED_BY_ACTIVITY;
if (toplevel->isClient()) { if (toplevel->isClient()) {