EffectsHandler emits desktopChanged signal

The first signal used between EffectsHandler and Effects.
The signal is actually emitted by the EffectsHandlerImpl and only
the interested effects connect to this signal.
EffectsHandlerImpl itself is also notified by a signal from Workspace,
allowing to remove one of the many if (effects) checks.
icc-effect-5.14.5
Martin Gräßlin 2011-02-25 20:41:10 +01:00
parent b3a5639967
commit c3a076b6a5
11 changed files with 39 additions and 20 deletions

View File

@ -95,6 +95,8 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type)
, mouse_poll_ref_count(0)
, current_paint_effectframe(0)
{
Workspace *ws = Workspace::self();
connect(ws, SIGNAL(currentDesktopChanged(int)), this, SLOT(slotDesktopChanged(int)));
reconfigure();
}
@ -334,10 +336,12 @@ void EffectsHandlerImpl::clientGroupItemRemoved(EffectWindow* c, EffectWindow* g
ep.second->clientGroupItemRemoved(c, group);
}
void EffectsHandlerImpl::desktopChanged(int old)
void EffectsHandlerImpl::slotDesktopChanged(int old)
{
foreach (const EffectPair & ep, loaded_effects)
ep.second->desktopChanged(old);
const int newDesktop = Workspace::self()->currentDesktop();
if (old != 0 && newDesktop != old) {
emit desktopChanged(old, newDesktop);
}
}
void EffectsHandlerImpl::windowDamaged(EffectWindow* w, const QRect& r)

View File

@ -38,6 +38,7 @@ namespace KWin
class EffectsHandlerImpl : public EffectsHandler
{
Q_OBJECT
public:
EffectsHandlerImpl(CompositingType type);
virtual ~EffectsHandlerImpl();
@ -165,7 +166,6 @@ public:
void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
void clientGroupItemAdded(EffectWindow* from, EffectWindow* to);
void clientGroupItemRemoved(EffectWindow* c, EffectWindow* group);
void desktopChanged(int old);
void windowDamaged(EffectWindow* w, const QRect& r);
void windowGeometryShapeChanged(EffectWindow* w, const QRect& old);
void tabBoxAdded(int mode);
@ -191,6 +191,9 @@ public:
QList<EffectWindow*> elevatedWindows() const;
protected Q_SLOTS:
void slotDesktopChanged(int old);
protected:
KLibrary* findEffectLibrary(KService* service);
void effectsChanged();

View File

@ -38,6 +38,7 @@ CubeSlideEffect::CubeSlideEffect()
, desktopChangedWhileMoving(false)
, progressRestriction(0.0f)
{
connect(effects, SIGNAL(desktopChanged(int, int)), this, SLOT(slotDesktopChanged(int, int)));
reconfigure(ReconfigureAll);
}
@ -417,7 +418,7 @@ void CubeSlideEffect::postPaintScreen()
}
}
void CubeSlideEffect::desktopChanged(int old)
void CubeSlideEffect::slotDesktopChanged(int old, int current)
{
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
return;
@ -499,10 +500,10 @@ void CubeSlideEffect::desktopChanged(int old)
}
} else {
// ignore pager layout
int left = old - effects->currentDesktop();
int left = old - current;
if (left < 0)
left = effects->numberOfDesktops() + left;
int right = effects->currentDesktop() - old;
int right = current - old;
if (right < 0)
right = effects->numberOfDesktops() + right;
if (left < right) {

View File

@ -41,10 +41,13 @@ 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 void desktopChanged(int old);
virtual void windowUserMovedResized(EffectWindow* c, bool first, bool last);
static bool supported();
private Q_SLOTS:
void slotDesktopChanged(int old, int current);
private:
enum RotationDirection {
Left,

View File

@ -30,6 +30,7 @@ KWIN_EFFECT(fadedesktop, FadeDesktopEffect)
FadeDesktopEffect::FadeDesktopEffect()
: m_fading(false)
{
connect(effects, SIGNAL(desktopChanged(int,int)), this, SLOT(slotDesktopChanged(int)));
m_timeline.setCurveShape(TimeLine::LinearCurve);
reconfigure(ReconfigureAll);
}
@ -88,7 +89,7 @@ void FadeDesktopEffect::paintWindow(EffectWindow *w, int mask, QRegion region, W
effects->paintWindow(w, mask, region, data);
}
void FadeDesktopEffect::desktopChanged(int old)
void FadeDesktopEffect::slotDesktopChanged(int old)
{
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
return;

View File

@ -38,7 +38,9 @@ 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 void desktopChanged(int old);
private Q_SLOTS:
void slotDesktopChanged(int old);
private:
bool m_fading;

View File

@ -31,6 +31,7 @@ KWIN_EFFECT(slide, SlideEffect)
SlideEffect::SlideEffect()
: slide(false)
{
connect(effects, SIGNAL(desktopChanged(int,int)), this, SLOT(slotDesktopChanged(int,int)));
mTimeLine.setCurveShape(TimeLine::EaseInOutCurve);
reconfigure(ReconfigureAll);
}
@ -168,7 +169,7 @@ QRect SlideEffect::desktopRect(int desktop) const
return rect;
}
void SlideEffect::desktopChanged(int old)
void SlideEffect::slotDesktopChanged(int old, int current)
{
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
return;
@ -198,7 +199,7 @@ void SlideEffect::desktopChanged(int old)
currentRegion |= (currentRegion & QRect(w, 0, w, h)).translated(-w, 0);
currentRegion |= (currentRegion & QRect(0, h, w, h)).translated(0, -h);
}
QRect rect = desktopRect(effects->currentDesktop());
QRect rect = desktopRect(current);
if (currentRegion.contains(rect)) {
// current position is in new current desktop (e.g. quickly changing back),
// don't do full progress

View File

@ -40,7 +40,10 @@ 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 void desktopChanged(int old);
private Q_SLOTS:
void slotDesktopChanged(int old, int current);
private:
QRect desktopRect(int desktop) const;
TimeLine mTimeLine;

View File

@ -179,10 +179,6 @@ void Effect::propertyNotify(EffectWindow* , long)
{
}
void Effect::desktopChanged(int)
{
}
void Effect::windowDamaged(EffectWindow*, const QRect&)
{
}

View File

@ -455,7 +455,6 @@ public:
virtual void clientGroupItemAdded(EffectWindow* from, EffectWindow* to); // from merged with to
virtual void clientGroupItemRemoved(EffectWindow* c, EffectWindow* group); // c removed from group
virtual void windowInputMouseEvent(Window w, QEvent* e);
virtual void desktopChanged(int old);
virtual void windowDamaged(EffectWindow* w, const QRect& r);
virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old);
virtual void mouseChanged(const QPoint& pos, const QPoint& oldpos,
@ -832,6 +831,14 @@ public:
**/
static KConfigGroup effectConfig(const QString& effectname);
Q_SIGNALS:
/**
* Signal emitted when the current desktop changed.
* @param oldDesktop The previously current desktop
* @param newDesktop The new current desktop
* @since 4.7
**/
void desktopChanged(int oldDesktop, int newDesktop);
protected:
QVector< EffectPair > loaded_effects;

View File

@ -1463,8 +1463,6 @@ bool Workspace::setCurrentDesktop(int new_desktop)
if (old_desktop != 0 && old_desktop != new_desktop && numberOfDesktops() > 1)
desktop_change_osd->desktopChanged(old_desktop);
if (effects != NULL && old_desktop != 0 && old_desktop != new_desktop)
static_cast<EffectsHandlerImpl*>(effects)->desktopChanged(old_desktop);
if (compositing())
addRepaintFull();