From 0795ae89aceba3f3e22e77dbe082c79e4bbeaa31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 27 Feb 2011 10:05:04 +0100 Subject: [PATCH] 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. --- activation.cpp | 12 +++++------- effects.cpp | 6 +++--- effects.h | 2 +- effects/dashboard/dashboard.cpp | 3 ++- effects/dashboard/dashboard.h | 2 +- effects/dialogparent/dialogparent.cpp | 3 ++- effects/dialogparent/dialogparent.h | 3 +-- effects/diminactive/diminactive.cpp | 3 ++- effects/diminactive/diminactive.h | 6 +++++- effects/dimscreen/dimscreen.cpp | 3 ++- effects/dimscreen/dimscreen.h | 5 ++++- effects/slideback/slideback.cpp | 5 +++-- effects/slideback/slideback.h | 3 +-- effects/translucency/translucency.cpp | 3 ++- effects/translucency/translucency.h | 6 +++++- libkwineffects/kwineffects.cpp | 4 ---- libkwineffects/kwineffects.h | 7 ++++++- 17 files changed, 45 insertions(+), 31 deletions(-) diff --git a/activation.cpp b/activation.cpp index fd67c552b6..67bb89368d 100644 --- a/activation.cpp +++ b/activation.cpp @@ -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(effects)->windowActivated(active_client ? active_client->effectWindow() : NULL); + + emit clientActivated(active_client); + if (active_client) { + active_client->sl_activated(); + } if (tilingEnabled()) notifyTilingWindowActivated(active_client); diff --git a/effects.cpp b/effects.cpp index d3f0631a02..4e5df12091 100644 --- a/effects.cpp +++ b/effects.cpp @@ -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) diff --git a/effects.h b/effects.h index 51822ec689..4e51e6de8a 100644 --- a/effects.h +++ b/effects.h @@ -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); diff --git a/effects/dashboard/dashboard.cpp b/effects/dashboard/dashboard.cpp index 33f6cb02be..0784ca1607 100644 --- a/effects/dashboard/dashboard.cpp +++ b/effects/dashboard/dashboard.cpp @@ -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; diff --git a/effects/dashboard/dashboard.h b/effects/dashboard/dashboard.h index 04c21b8901..3ef68d1427 100644 --- a/effects/dashboard/dashboard.h +++ b/effects/dashboard/dashboard.h @@ -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); diff --git a/effects/dialogparent/dialogparent.cpp b/effects/dialogparent/dialogparent.cpp index 7b24ca74bd..ea79641b2f 100644 --- a/effects/dialogparent/dialogparent.cpp +++ b/effects/dialogparent/dialogparent.cpp @@ -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 diff --git a/effects/dialogparent/dialogparent.h b/effects/dialogparent/dialogparent.h index 3eb4c4a8be..1514e7ae6a 100644 --- a/effects/dialogparent/dialogparent.h +++ b/effects/dialogparent/dialogparent.h @@ -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: diff --git a/effects/diminactive/diminactive.cpp b/effects/diminactive/diminactive.cpp index b2e9108c32..aa80389508 100644 --- a/effects/diminactive/diminactive.cpp +++ b/effects/diminactive/diminactive.cpp @@ -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; diff --git a/effects/diminactive/diminactive.h b/effects/diminactive/diminactive.h index 5fd1178a8a..e1bfd8f180 100644 --- a/effects/diminactive/diminactive.h +++ b/effects/diminactive/diminactive.h @@ -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; diff --git a/effects/dimscreen/dimscreen.cpp b/effects/dimscreen/dimscreen.cpp index 1f42cb11bd..7f2c87c651 100644 --- a/effects/dimscreen/dimscreen.cpp +++ b/effects/dimscreen/dimscreen.cpp @@ -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; diff --git a/effects/dimscreen/dimscreen.h b/effects/dimscreen/dimscreen.h index 8023022e3b..04df571132 100644 --- a/effects/dimscreen/dimscreen.h +++ b/effects/dimscreen/dimscreen.h @@ -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; diff --git a/effects/slideback/slideback.cpp b/effects/slideback/slideback.cpp index d869f42cae..31dae80a2a 100644 --- a/effects/slideback/slideback.cpp +++ b/effects/slideback/slideback.cpp @@ -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); diff --git a/effects/slideback/slideback.h b/effects/slideback/slideback.h index 2fe3cb4404..eddc38e277 100644 --- a/effects/slideback/slideback.h +++ b/effects/slideback/slideback.h @@ -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: diff --git a/effects/translucency/translucency.cpp b/effects/translucency/translucency.cpp index bb685c0af6..a46d3f2edf 100644 --- a/effects/translucency/translucency.cpp +++ b/effects/translucency/translucency.cpp @@ -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); diff --git a/effects/translucency/translucency.h b/effects/translucency/translucency.h index 2196794522..b782dc2c7d 100644 --- a/effects/translucency/translucency.h +++ b/effects/translucency/translucency.h @@ -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; diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index 4ff80cbc4a..4e4ebdbde7 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -135,10 +135,6 @@ void Effect::windowDeleted(EffectWindow*) { } -void Effect::windowActivated(EffectWindow*) -{ -} - void Effect::windowMinimized(EffectWindow*) { } diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 9c5fc0d7c1..588fd4a4c3 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -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;