From 012222037ecceb09329da7363bf141703e6fb85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 6 Mar 2011 10:55:27 +0100 Subject: [PATCH] WindowMinimized becomes a signal --- client.cpp | 4 ++-- client.h | 1 + effects.cpp | 10 +++++++--- effects.h | 2 +- effects/magiclamp/magiclamp.cpp | 3 ++- effects/magiclamp/magiclamp.h | 2 +- effects/minimizeanimation/minimizeanimation.cpp | 3 ++- effects/minimizeanimation/minimizeanimation.h | 2 +- libkwineffects/kwineffects.cpp | 4 ---- libkwineffects/kwineffects.h | 7 ++++++- 10 files changed, 23 insertions(+), 15 deletions(-) diff --git a/client.cpp b/client.cpp index ee5c1088e9..4fbcd1f203 100644 --- a/client.cpp +++ b/client.cpp @@ -898,8 +898,8 @@ void Client::minimize(bool avoid_animation) workspace()->updateMinimizedOfTransients(this); updateWindowRules(); workspace()->updateFocusChains(this, Workspace::FocusChainMakeLast); - if (effects && !avoid_animation) // TODO: Shouldn't it tell effects at least about the change? - static_cast(effects)->windowMinimized(effectWindow()); + // TODO: merge signal with s_minimized + emit clientMinimized(this, !avoid_animation); // when tiling, request a rearrangement workspace()->notifyTilingWindowMinimizeToggled(this); diff --git a/client.h b/client.h index 9ec6d7e411..32914d055e 100644 --- a/client.h +++ b/client.h @@ -496,6 +496,7 @@ signals: void s_fullScreenSet(bool, bool); void clientClosed(KWin::Client*); void clientMaximizedStateChanged(KWin::Client*, KDecorationDefines::MaximizeMode); + void clientMinimized(KWin::Client* client, bool animate); // To make workspace-client calls, a few slots are also // required diff --git a/effects.cpp b/effects.cpp index b0dfdd0421..f816fc81bd 100644 --- a/effects.cpp +++ b/effects.cpp @@ -106,6 +106,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type) connect(c, SIGNAL(clientClosed(KWin::Client*)), this, SLOT(slotClientClosed(KWin::Client*))); connect(c, SIGNAL(clientMaximizedStateChanged(KWin::Client*,KDecorationDefines::MaximizeMode)), this, SLOT(slotClientMaximized(KWin::Client*,KDecorationDefines::MaximizeMode))); connect(c, SIGNAL(opacityChanged(KWin::Toplevel*,qreal)), this, SLOT(slotOpacityChanged(KWin::Toplevel*,qreal))); + connect(c, SIGNAL(clientMinimized(KWin::Client*,bool)), this, SLOT(slotClientMinimized(KWin::Client*,bool))); } foreach (Unmanaged *u, ws->unmanagedList()) { connect(u, SIGNAL(unmanagedClosed(KWin::Unmanaged*)), this, SLOT(slotUnmanagedClosed(KWin::Unmanaged*))); @@ -302,6 +303,7 @@ void EffectsHandlerImpl::slotClientAdded(Client *c) connect(c, SIGNAL(clientClosed(KWin::Client*)), this, SLOT(slotClientClosed(KWin::Client*))); connect(c, SIGNAL(clientMaximizedStateChanged(KWin::Client*,KDecorationDefines::MaximizeMode)), this, SLOT(slotClientMaximized(KWin::Client*,KDecorationDefines::MaximizeMode))); connect(c, SIGNAL(opacityChanged(KWin::Toplevel*,qreal)), this, SLOT(slotOpacityChanged(KWin::Toplevel*,qreal))); + connect(c, SIGNAL(clientMinimized(KWin::Client*,bool)), this, SLOT(slotClientMinimized(KWin::Client*,bool))); emit windowAdded(c->effectWindow()); } @@ -333,10 +335,12 @@ void EffectsHandlerImpl::slotClientActivated(KWin::Client *c) emit windowActivated(c ? c->effectWindow() : NULL); } -void EffectsHandlerImpl::windowMinimized(EffectWindow* c) +void EffectsHandlerImpl::slotClientMinimized(Client *c, bool animate) { - foreach (const EffectPair & ep, loaded_effects) - ep.second->windowMinimized(c); + // TODO: notify effects even if it should not animate? + if (animate) { + emit windowMinimized(c->effectWindow()); + } } void EffectsHandlerImpl::windowUnminimized(EffectWindow* c) diff --git a/effects.h b/effects.h index bcca72788d..36ee9e9605 100644 --- a/effects.h +++ b/effects.h @@ -159,7 +159,6 @@ public: // internal (used by kwin core or compositing code) void startPaint(); void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); - void windowMinimized(EffectWindow* c); void windowUnminimized(EffectWindow* c); void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to); void clientGroupItemAdded(EffectWindow* from, EffectWindow* to); @@ -202,6 +201,7 @@ protected Q_SLOTS: void slotDeletedRemoved(KWin::Deleted *d); void slotClientMaximized(KWin::Client *c, KDecorationDefines::MaximizeMode maxMode); void slotOpacityChanged(KWin::Toplevel *t, qreal oldOpacity); + void slotClientMinimized(KWin::Client *c, bool animate); protected: KLibrary* findEffectLibrary(KService* service); diff --git a/effects/magiclamp/magiclamp.cpp b/effects/magiclamp/magiclamp.cpp index 1631071c29..bb912d2333 100644 --- a/effects/magiclamp/magiclamp.cpp +++ b/effects/magiclamp/magiclamp.cpp @@ -35,6 +35,7 @@ MagicLampEffect::MagicLampEffect() mActiveAnimations = 0; reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowDeleted(EffectWindow*)), this, SLOT(slotWindowDeleted(EffectWindow*))); + connect(effects, SIGNAL(windowMinimized(EffectWindow*)), this, SLOT(slotWindowMinimized(EffectWindow*))); } bool MagicLampEffect::supported() @@ -327,7 +328,7 @@ void MagicLampEffect::slotWindowDeleted(EffectWindow* w) mTimeLineWindows.remove(w); } -void MagicLampEffect::windowMinimized(EffectWindow* w) +void MagicLampEffect::slotWindowMinimized(EffectWindow* w) { if (effects->activeFullScreenEffect()) return; diff --git a/effects/magiclamp/magiclamp.h b/effects/magiclamp/magiclamp.h index db2bd36c26..ab7ad5df78 100644 --- a/effects/magiclamp/magiclamp.h +++ b/effects/magiclamp/magiclamp.h @@ -39,13 +39,13 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); - virtual void windowMinimized(EffectWindow* c); virtual void windowUnminimized(EffectWindow* c); static bool supported(); public Q_SLOTS: void slotWindowDeleted(EffectWindow *w); + void slotWindowMinimized(EffectWindow *w); private: QHash< EffectWindow*, TimeLine > mTimeLineWindows; diff --git a/effects/minimizeanimation/minimizeanimation.cpp b/effects/minimizeanimation/minimizeanimation.cpp index 6d50d1ea36..db30d5e4b5 100644 --- a/effects/minimizeanimation/minimizeanimation.cpp +++ b/effects/minimizeanimation/minimizeanimation.cpp @@ -29,6 +29,7 @@ MinimizeAnimationEffect::MinimizeAnimationEffect() { mActiveAnimations = 0; connect(effects, SIGNAL(windowDeleted(EffectWindow*)), this, SLOT(slotWindowDeleted(EffectWindow*))); + connect(effects, SIGNAL(windowMinimized(EffectWindow*)), this, SLOT(slotWindowMinimized(EffectWindow*))); } @@ -114,7 +115,7 @@ void MinimizeAnimationEffect::slotWindowDeleted(EffectWindow* w) mTimeLineWindows.remove(w); } -void MinimizeAnimationEffect::windowMinimized(EffectWindow* w) +void MinimizeAnimationEffect::slotWindowMinimized(EffectWindow* w) { if (effects->activeFullScreenEffect()) return; diff --git a/effects/minimizeanimation/minimizeanimation.h b/effects/minimizeanimation/minimizeanimation.h index aeb2d0800d..ad30f3b7d1 100644 --- a/effects/minimizeanimation/minimizeanimation.h +++ b/effects/minimizeanimation/minimizeanimation.h @@ -43,11 +43,11 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); - virtual void windowMinimized(EffectWindow* c); virtual void windowUnminimized(EffectWindow* c); public Q_SLOTS: void slotWindowDeleted(EffectWindow *w); + void slotWindowMinimized(EffectWindow *w); private: QHash< EffectWindow*, TimeLine > mTimeLineWindows; diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index 7e980b6da8..43d48e1511 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -123,10 +123,6 @@ void Effect::windowMoveResizeGeometryUpdate(EffectWindow* , const QRect&) { } -void Effect::windowMinimized(EffectWindow*) -{ -} - void Effect::windowUnminimized(EffectWindow*) { } diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 4ec9555f0a..c245a4f23a 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -442,7 +442,6 @@ public: /** called when the geometry changed during moving/resizing. */ virtual void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); - virtual void windowMinimized(EffectWindow* c); virtual void windowUnminimized(EffectWindow* c); virtual void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to); virtual void clientGroupItemAdded(EffectWindow* from, EffectWindow* to); // from merged with to @@ -881,6 +880,12 @@ Q_SIGNALS: * @since 4.7 **/ void windowOpacityChanged(EffectWindow *w, qreal oldOpacity, qreal newOpacity); + /** + * Signal emitted when a window got minimized. + * @param w The window which was minimized + * @since 4.7 + **/ + void windowMinimized(EffectWindow *w); protected: QVector< EffectPair > loaded_effects;