EffectsHandler emits signal on windowActivated

EffectsHandlerImpl connects to the Workspace signal clientActivated.
The emitting of the signal is slightly moved from before the activation logic
to after the activation logic. This might change behavior in the scripting
component, but the previous code looked wrong.
This commit is contained in:
Martin Gräßlin 2011-02-27 10:05:04 +01:00
parent 0b85768ec5
commit 0795ae89ac
17 changed files with 45 additions and 31 deletions

View file

@ -229,11 +229,6 @@ void Workspace::setActiveClient(Client* c, allowed_t)
if (active_client == c)
return;
if (c != 0) {
emit clientActivated(c);
c->sl_activated();
}
if (active_popup && active_popup_client != c && set_active_client_recursion == 0)
closeActivePopup();
StackingUpdatesBlocker blocker(this);
@ -264,8 +259,11 @@ void Workspace::setActiveClient(Client* c, allowed_t)
rootInfo->setActiveWindow(active_client ? active_client->window() : 0);
updateColormap();
if (effects)
static_cast<EffectsHandlerImpl*>(effects)->windowActivated(active_client ? active_client->effectWindow() : NULL);
emit clientActivated(active_client);
if (active_client) {
active_client->sl_activated();
}
if (tilingEnabled())
notifyTilingWindowActivated(active_client);

View file

@ -99,6 +99,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type)
connect(ws, SIGNAL(currentDesktopChanged(int)), this, SLOT(slotDesktopChanged(int)));
connect(ws, SIGNAL(clientAdded(KWin::Client*)), this, SLOT(slotClientAdded(KWin::Client*)));
connect(ws, SIGNAL(unmanagedAdded(KWin::Unmanaged*)), this, SLOT(slotUnmanagedAdded(KWin::Unmanaged*)));
connect(ws, SIGNAL(clientActivated(KWin::Client*)), this, SLOT(slotClientActivated(KWin::Client*)));
// connect all clients
foreach (Client *c, ws->clientList()) {
connect(c, SIGNAL(clientClosed(KWin::Client*)), this, SLOT(slotClientClosed(KWin::Client*)));
@ -319,10 +320,9 @@ void EffectsHandlerImpl::slotUnmanagedClosed(Unmanaged* u)
emit windowClosed(u->effectWindow());
}
void EffectsHandlerImpl::windowActivated(EffectWindow* c)
void EffectsHandlerImpl::slotClientActivated(KWin::Client *c)
{
foreach (const EffectPair & ep, loaded_effects)
ep.second->windowActivated(c);
emit windowActivated(c ? c->effectWindow() : NULL);
}
void EffectsHandlerImpl::windowMinimized(EffectWindow* c)

View file

@ -161,7 +161,6 @@ public:
void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry);
void windowOpacityChanged(EffectWindow* c, double old_opacity);
void windowDeleted(EffectWindow* c);
void windowActivated(EffectWindow* c);
void windowMinimized(EffectWindow* c);
void windowUnminimized(EffectWindow* c);
void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
@ -198,6 +197,7 @@ protected Q_SLOTS:
void slotUnmanagedAdded(KWin::Unmanaged *u);
void slotClientClosed(KWin::Client *c);
void slotUnmanagedClosed(KWin::Unmanaged *u);
void slotClientActivated(KWin::Client *c);
protected:
KLibrary* findEffectLibrary(KService* service);

View file

@ -37,6 +37,7 @@ DashboardEffect::DashboardEffect()
reconfigure(ReconfigureAll);
connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*)));
connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*)));
connect(effects, SIGNAL(windowActivated(EffectWindow*)), this, SLOT(slotWindowActivated(EffectWindow*)));
}
DashboardEffect::~DashboardEffect()
@ -149,7 +150,7 @@ bool DashboardEffect::isDashboard(EffectWindow *w)
}
}
void DashboardEffect::windowActivated(EffectWindow *w)
void DashboardEffect::slotWindowActivated(EffectWindow *w)
{
if (!w)
return;

View file

@ -42,11 +42,11 @@ public:
virtual void propagate();
virtual void reconfigure(ReconfigureFlags);
virtual void unpropagate();
virtual void windowActivated(EffectWindow *w);
public Q_SLOTS:
void slotWindowAdded(EffectWindow* c);
void slotWindowClosed(EffectWindow *c);
void slotWindowActivated(EffectWindow *w);
private:
bool blur;
bool isDashboard(EffectWindow* w);

View file

@ -29,6 +29,7 @@ DialogParentEffect::DialogParentEffect()
{
reconfigure(ReconfigureAll);
connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*)));
connect(effects, SIGNAL(windowActivated(EffectWindow*)), this, SLOT(slotWindowActivated(EffectWindow*)));
}
void DialogParentEffect::reconfigure(ReconfigureFlags)
@ -80,7 +81,7 @@ void DialogParentEffect::postPaintWindow(EffectWindow* w)
effects->postPaintWindow(w);
}
void DialogParentEffect::windowActivated(EffectWindow* w)
void DialogParentEffect::slotWindowActivated(EffectWindow* w)
{
// If this window is a dialog, we need to repaint it's parent window, so
// that the effect could be run for it

View file

@ -46,10 +46,9 @@ public:
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void postPaintWindow(EffectWindow* w);
virtual void windowActivated(EffectWindow* c);
public Q_SLOTS:
void slotWindowClosed(EffectWindow *c);
void slotWindowActivated(EffectWindow *c);
protected:
bool hasModalWindow(EffectWindow* t);
private:

View file

@ -35,6 +35,7 @@ DimInactiveEffect::DimInactiveEffect()
previousActiveTimeline.setDuration(animationTime(250));
active = effects->activeWindow();
previousActive = NULL;
connect(effects, SIGNAL(windowActivated(EffectWindow*)), this, SLOT(slotWindowActivated(EffectWindow*)));
}
void DimInactiveEffect::reconfigure(ReconfigureFlags)
@ -105,7 +106,7 @@ void DimInactiveEffect::windowDeleted(EffectWindow* w)
previousActive = NULL;
}
void DimInactiveEffect::windowActivated(EffectWindow* w)
void DimInactiveEffect::slotWindowActivated(EffectWindow* w)
{
if (active != NULL) {
previousActive = active;

View file

@ -32,13 +32,17 @@ namespace KWin
class DimInactiveEffect
: public Effect
{
Q_OBJECT
public:
DimInactiveEffect();
virtual void reconfigure(ReconfigureFlags);
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void windowDeleted(EffectWindow* w);
virtual void windowActivated(EffectWindow* c);
public Q_SLOTS:
void slotWindowActivated(EffectWindow* c);
private:
bool dimWindow(const EffectWindow* w) const;
TimeLine timeline;

View file

@ -32,6 +32,7 @@ DimScreenEffect::DimScreenEffect()
, deactivateAnimation(false)
{
reconfigure(ReconfigureAll);
connect(effects, SIGNAL(windowActivated(EffectWindow*)), this, SLOT(slotWindowActivated(EffectWindow*)));
}
DimScreenEffect::~DimScreenEffect()
@ -84,7 +85,7 @@ void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, Win
effects->paintWindow(w, mask, region, data);
}
void DimScreenEffect::windowActivated(EffectWindow *w)
void DimScreenEffect::slotWindowActivated(EffectWindow *w)
{
if (!w) return;
QStringList check;

View file

@ -29,6 +29,7 @@ namespace KWin
class DimScreenEffect
: public Effect
{
Q_OBJECT
public:
DimScreenEffect();
~DimScreenEffect();
@ -37,7 +38,9 @@ public:
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
virtual void postPaintScreen();
virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data);
virtual void windowActivated(EffectWindow *w);
public Q_SLOTS:
void slotWindowActivated(EffectWindow *w);
private:
bool mActivated;

View file

@ -34,6 +34,7 @@ SlideBackEffect::SlideBackEffect()
disabled = false;
unminimizedWindow = NULL;
connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*)));
connect(effects, SIGNAL(windowActivated(EffectWindow*)), this, SLOT(slotWindowActivated(EffectWindow*)));
}
static inline bool windowsShareDesktop(EffectWindow *w1, EffectWindow *w2)
@ -41,7 +42,7 @@ static inline bool windowsShareDesktop(EffectWindow *w1, EffectWindow *w2)
return w1->isOnAllDesktops() || w2->isOnAllDesktops() || w1->desktop() == w2->desktop();
}
void SlideBackEffect::windowActivated(EffectWindow* w)
void SlideBackEffect::slotWindowActivated(EffectWindow* w)
{
if (w == NULL || w->keepAbove()) { // plasma popups, yakuake etc...
return;
@ -194,7 +195,7 @@ void SlideBackEffect::paintWindow(EffectWindow *w, int mask, QRegion region, Win
}
}
// Finally call windowActivated in case a already active window is raised.
windowActivated(w);
slotWindowActivated(w);
}
if (motionManager.isManaging(w)) {
motionManager.apply(w, data);

View file

@ -34,8 +34,6 @@ class SlideBackEffect
public:
SlideBackEffect();
virtual void windowActivated(EffectWindow* c);
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);
@ -51,6 +49,7 @@ public:
public Q_SLOTS:
void slotWindowAdded(EffectWindow *w);
void slotWindowActivated(EffectWindow *w);
private:

View file

@ -34,6 +34,7 @@ TranslucencyEffect::TranslucencyEffect()
{
reconfigure(ReconfigureAll);
active = effects->activeWindow();
connect(effects, SIGNAL(windowActivated(EffectWindow*)), this, SLOT(slotWindowActivated(EffectWindow*)));
}
void TranslucencyEffect::reconfigure(ReconfigureFlags)
@ -183,7 +184,7 @@ void TranslucencyEffect::windowUserMovedResized(EffectWindow* w, bool first, boo
}
}
void TranslucencyEffect::windowActivated(EffectWindow* w)
void TranslucencyEffect::slotWindowActivated(EffectWindow* w)
{
if (inactive != 1.0) {
activeinactive_timeline.setProgress(0.0);

View file

@ -29,13 +29,17 @@ namespace KWin
class TranslucencyEffect
: public Effect
{
Q_OBJECT
public:
TranslucencyEffect();
virtual void reconfigure(ReconfigureFlags);
virtual void windowUserMovedResized(EffectWindow* c, bool first, bool last);
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
virtual void windowActivated(EffectWindow* w);
public Q_SLOTS:
void slotWindowActivated(EffectWindow* w);
private:
bool isInactive(const EffectWindow *w) const;
bool individualmenuconfig;

View file

@ -135,10 +135,6 @@ void Effect::windowDeleted(EffectWindow*)
{
}
void Effect::windowActivated(EffectWindow*)
{
}
void Effect::windowMinimized(EffectWindow*)
{
}

View file

@ -446,7 +446,6 @@ public:
virtual void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry);
virtual void windowOpacityChanged(EffectWindow* c, double old_opacity);
virtual void windowDeleted(EffectWindow* c);
virtual void windowActivated(EffectWindow* c);
virtual void windowMinimized(EffectWindow* c);
virtual void windowUnminimized(EffectWindow* c);
virtual void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to);
@ -852,6 +851,12 @@ Q_SIGNALS:
* @since 4.7
**/
void windowClosed(EffectWindow *w);
/**
* Signal emitted when a window get's activated.
* @param w The new active window, or @c NULL if there is no active window.
* @since 4.7
**/
void windowActivated(EffectWindow *w);
protected:
QVector< EffectPair > loaded_effects;