From 0b85768ec5cfffa6ee8d0c0970e5a57efd1c6ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 27 Feb 2011 09:25:45 +0100 Subject: [PATCH] EffectsHandler emits windowClosed signal Client and Unmanaged use a signal to notify that they are about to be closed. The EffectsHandlerImpl is connected to those signals and emits the appropriate windowClosed signal to which the effects are connected. --- client.cpp | 8 ++++---- client.h | 1 + effects.cpp | 19 ++++++++++++++++--- effects.h | 3 ++- effects/boxswitch/boxswitch.cpp | 3 ++- effects/boxswitch/boxswitch.h | 6 +++++- effects/coverswitch/coverswitch.cpp | 3 ++- effects/coverswitch/coverswitch.h | 6 +++++- effects/dashboard/dashboard.cpp | 3 ++- effects/dashboard/dashboard.h | 2 +- effects/desktopgrid/desktopgrid.cpp | 3 ++- effects/desktopgrid/desktopgrid.h | 2 +- effects/dialogparent/dialogparent.cpp | 3 ++- effects/dialogparent/dialogparent.h | 4 +++- effects/explosion/explosion.cpp | 3 ++- effects/explosion/explosion.h | 4 +++- effects/fade/fade.cpp | 3 ++- effects/fade/fade.h | 2 +- effects/fallapart/fallapart.cpp | 3 ++- effects/fallapart/fallapart.h | 6 +++++- effects/flipswitch/flipswitch.cpp | 3 ++- effects/flipswitch/flipswitch.h | 2 +- effects/glide/glide.cpp | 3 ++- effects/glide/glide.h | 2 +- effects/highlightwindow/highlightwindow.cpp | 3 ++- effects/highlightwindow/highlightwindow.h | 2 +- effects/invert/invert.cpp | 3 ++- effects/invert/invert.h | 2 +- effects/login/login.cpp | 3 ++- effects/login/login.h | 6 +++++- effects/logout/logout.cpp | 3 ++- effects/logout/logout.h | 2 +- effects/presentwindows/presentwindows.cpp | 3 ++- effects/presentwindows/presentwindows.h | 2 +- effects/scalein/scalein.cpp | 3 ++- effects/scalein/scalein.h | 2 +- effects/sheet/sheet.cpp | 3 ++- effects/sheet/sheet.h | 2 +- effects/slidingpopups/slidingpopups.cpp | 3 ++- effects/slidingpopups/slidingpopups.h | 2 +- effects/snaphelper/snaphelper.cpp | 3 ++- effects/snaphelper/snaphelper.h | 5 ++++- effects/thumbnailaside/thumbnailaside.cpp | 3 ++- effects/thumbnailaside/thumbnailaside.h | 2 +- effects/wobblywindows/wobblywindows.cpp | 3 ++- effects/wobblywindows/wobblywindows.h | 2 +- libkwineffects/kwineffects.cpp | 4 ---- libkwineffects/kwineffects.h | 10 +++++++++- unmanaged.cpp | 4 ++-- unmanaged.h | 2 ++ workspace.h | 13 +++++++++++++ 51 files changed, 135 insertions(+), 57 deletions(-) diff --git a/client.cpp b/client.cpp index 027e41b23..ee5c1088e 100644 --- a/client.cpp +++ b/client.cpp @@ -234,8 +234,8 @@ void Client::releaseWindow(bool on_shutdown) assert(!deleting); deleting = true; Deleted* del = Deleted::create(this); - if (effects) { - static_cast(effects)->windowClosed(effectWindow()); + emit clientClosed(this); + if (scene) { scene->windowClosed(this, del); } finishCompositing(); @@ -302,8 +302,8 @@ void Client::destroyClient() assert(!deleting); deleting = true; Deleted* del = Deleted::create(this); - if (effects) { - static_cast(effects)->windowClosed(effectWindow()); + emit clientClosed(this); + if (scene) { scene->windowClosed(this, del); } finishCompositing(); diff --git a/client.h b/client.h index e6f2ef4d4..74e98473b 100644 --- a/client.h +++ b/client.h @@ -494,6 +494,7 @@ signals: void maximizeSet(QPair); void s_activated(); void s_fullScreenSet(bool, bool); + void clientClosed(KWin::Client*); // To make workspace-client calls, a few slots are also // required diff --git a/effects.cpp b/effects.cpp index 209fc8e66..d3f0631a0 100644 --- a/effects.cpp +++ b/effects.cpp @@ -99,6 +99,13 @@ 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 all clients + foreach (Client *c, ws->clientList()) { + connect(c, SIGNAL(clientClosed(KWin::Client*)), this, SLOT(slotClientClosed(KWin::Client*))); + } + foreach (Unmanaged *u, ws->unmanagedList()) { + connect(u, SIGNAL(unmanagedClosed(KWin::Unmanaged*)), this, SLOT(slotUnmanagedClosed(KWin::Unmanaged*))); + } reconfigure(); } @@ -285,11 +292,13 @@ void EffectsHandlerImpl::windowOpacityChanged(EffectWindow* c, double old_opacit void EffectsHandlerImpl::slotClientAdded(Client *c) { + connect(c, SIGNAL(clientClosed(KWin::Client*)), this, SLOT(slotClientClosed(KWin::Client*))); emit windowAdded(c->effectWindow()); } void EffectsHandlerImpl::slotUnmanagedAdded(Unmanaged *u) { + connect(u, SIGNAL(unmanagedClosed(KWin::Unmanaged*)), this, SLOT(slotUnmanagedClosed(KWin::Unmanaged*))); emit windowAdded(u->effectWindow()); } @@ -300,10 +309,14 @@ void EffectsHandlerImpl::windowDeleted(EffectWindow* c) elevated_windows.removeAll(c); } -void EffectsHandlerImpl::windowClosed(EffectWindow* c) +void EffectsHandlerImpl::slotClientClosed(Client *c) { - foreach (const EffectPair & ep, loaded_effects) - ep.second->windowClosed(c); + emit windowClosed(c->effectWindow()); +} + +void EffectsHandlerImpl::slotUnmanagedClosed(Unmanaged* u) +{ + emit windowClosed(u->effectWindow()); } void EffectsHandlerImpl::windowActivated(EffectWindow* c) diff --git a/effects.h b/effects.h index c294ff17c..51822ec68 100644 --- a/effects.h +++ b/effects.h @@ -160,7 +160,6 @@ public: void windowUserMovedResized(EffectWindow* c, bool first, bool last); void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); void windowOpacityChanged(EffectWindow* c, double old_opacity); - void windowClosed(EffectWindow* c); void windowDeleted(EffectWindow* c); void windowActivated(EffectWindow* c); void windowMinimized(EffectWindow* c); @@ -197,6 +196,8 @@ protected Q_SLOTS: void slotDesktopChanged(int old); void slotClientAdded(KWin::Client *c); void slotUnmanagedAdded(KWin::Unmanaged *u); + void slotClientClosed(KWin::Client *c); + void slotUnmanagedClosed(KWin::Unmanaged *u); protected: KLibrary* findEffectLibrary(KService* service); diff --git a/effects/boxswitch/boxswitch.cpp b/effects/boxswitch/boxswitch.cpp index 07c00b36d..7bef1a408 100644 --- a/effects/boxswitch/boxswitch.cpp +++ b/effects/boxswitch/boxswitch.cpp @@ -57,6 +57,7 @@ BoxSwitchEffect::BoxSwitchEffect() highlight_margin = 10; reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } BoxSwitchEffect::~BoxSwitchEffect() @@ -475,7 +476,7 @@ void BoxSwitchEffect::setSelectedWindow(EffectWindow* w) } } -void BoxSwitchEffect::windowClosed(EffectWindow* w) +void BoxSwitchEffect::slotWindowClosed(EffectWindow* w) { if (w == selected_window) { setSelectedWindow(0); diff --git a/effects/boxswitch/boxswitch.h b/effects/boxswitch/boxswitch.h index 303a7bf41..c7695974a 100644 --- a/effects/boxswitch/boxswitch.h +++ b/effects/boxswitch/boxswitch.h @@ -41,6 +41,7 @@ namespace KWin class BoxSwitchEffect : public Effect { + Q_OBJECT public: BoxSwitchEffect(); ~BoxSwitchEffect(); @@ -57,10 +58,13 @@ public: virtual void tabBoxAdded(int mode); virtual void tabBoxClosed(); virtual void tabBoxUpdated(); - virtual void windowClosed(EffectWindow* w); virtual void* proxy(); void activateFromProxy(int mode, bool animate, bool showText, float positioningFactor); void paintWindowsBox(const QRegion& region); + +public Q_SLOTS: + void slotWindowClosed(EffectWindow* w); + private: class ItemInfo; void setActive(); diff --git a/effects/coverswitch/coverswitch.cpp b/effects/coverswitch/coverswitch.cpp index 94b612f28..f94582c04 100644 --- a/effects/coverswitch/coverswitch.cpp +++ b/effects/coverswitch/coverswitch.cpp @@ -70,6 +70,7 @@ CoverSwitchEffect::CoverSwitchEffect() const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/coverswitch-reflection.glsl"); m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } CoverSwitchEffect::~CoverSwitchEffect() @@ -981,7 +982,7 @@ void CoverSwitchEffect::abort() captionFrame->free(); } -void CoverSwitchEffect::windowClosed(EffectWindow* c) +void CoverSwitchEffect::slotWindowClosed(EffectWindow* c) { // if the list is not empty, the effect is active if (!currentWindowList.isEmpty()) { diff --git a/effects/coverswitch/coverswitch.h b/effects/coverswitch/coverswitch.h index f820d3201..9d1cb8e5e 100644 --- a/effects/coverswitch/coverswitch.h +++ b/effects/coverswitch/coverswitch.h @@ -36,6 +36,7 @@ namespace KWin class CoverSwitchEffect : public Effect { + Q_OBJECT public: CoverSwitchEffect(); ~CoverSwitchEffect(); @@ -49,9 +50,12 @@ public: virtual void tabBoxClosed(); virtual void tabBoxUpdated(); virtual void windowInputMouseEvent(Window w, QEvent* e); - virtual void windowClosed(EffectWindow* c); static bool supported(); + +public Q_SLOTS: + void slotWindowClosed(EffectWindow *c); + private: void paintScene(EffectWindow* frontWindow, const EffectWindowList& leftWindows, const EffectWindowList& rightWindows, bool reflectedWindows = false); diff --git a/effects/dashboard/dashboard.cpp b/effects/dashboard/dashboard.cpp index 6bb2c294e..33f6cb02b 100644 --- a/effects/dashboard/dashboard.cpp +++ b/effects/dashboard/dashboard.cpp @@ -36,6 +36,7 @@ DashboardEffect::DashboardEffect() // read settings reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } DashboardEffect::~DashboardEffect() @@ -188,7 +189,7 @@ void DashboardEffect::slotWindowAdded(EffectWindow* w) } } -void DashboardEffect::windowClosed(EffectWindow* w) +void DashboardEffect::slotWindowClosed(EffectWindow* w) { propertyNotify(w, atom); diff --git a/effects/dashboard/dashboard.h b/effects/dashboard/dashboard.h index b3c6c6708..04c21b890 100644 --- a/effects/dashboard/dashboard.h +++ b/effects/dashboard/dashboard.h @@ -43,10 +43,10 @@ public: virtual void reconfigure(ReconfigureFlags); virtual void unpropagate(); virtual void windowActivated(EffectWindow *w); - virtual void windowClosed(EffectWindow* c); public Q_SLOTS: void slotWindowAdded(EffectWindow* c); + void slotWindowClosed(EffectWindow *c); private: bool blur; bool isDashboard(EffectWindow* w); diff --git a/effects/desktopgrid/desktopgrid.cpp b/effects/desktopgrid/desktopgrid.cpp index 3e9dc0266..2d8d82d52 100644 --- a/effects/desktopgrid/desktopgrid.cpp +++ b/effects/desktopgrid/desktopgrid.cpp @@ -74,6 +74,7 @@ DesktopGridEffect::DesktopGridEffect() connect(a, SIGNAL(triggered(bool)), this, SLOT(toggle())); connect(a, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(globalShortcutChanged(QKeySequence))); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); // Load all other configuration details reconfigure(ReconfigureAll); @@ -391,7 +392,7 @@ void DesktopGridEffect::slotWindowAdded(EffectWindow* w) effects->addRepaintFull(); } -void DesktopGridEffect::windowClosed(EffectWindow* w) +void DesktopGridEffect::slotWindowClosed(EffectWindow* w) { if (!activated && timeline.value() == 0) return; diff --git a/effects/desktopgrid/desktopgrid.h b/effects/desktopgrid/desktopgrid.h index 6374d9725..6fc66dce0 100644 --- a/effects/desktopgrid/desktopgrid.h +++ b/effects/desktopgrid/desktopgrid.h @@ -71,7 +71,6 @@ 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 windowClosed(EffectWindow* w); virtual void windowDeleted(EffectWindow* w); virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old); virtual void windowInputMouseEvent(Window w, QEvent* e); @@ -89,6 +88,7 @@ private slots: void slotAddDesktop(); void slotRemoveDesktop(); void slotWindowAdded(EffectWindow* w); + void slotWindowClosed(EffectWindow *w); private: QPointF scalePos(const QPoint& pos, int desktop, int screen = -1) const; diff --git a/effects/dialogparent/dialogparent.cpp b/effects/dialogparent/dialogparent.cpp index dc6e978bb..7b24ca74b 100644 --- a/effects/dialogparent/dialogparent.cpp +++ b/effects/dialogparent/dialogparent.cpp @@ -28,6 +28,7 @@ KWIN_EFFECT(dialogparent, DialogParentEffect) DialogParentEffect::DialogParentEffect() { reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } void DialogParentEffect::reconfigure(ReconfigureFlags) @@ -92,7 +93,7 @@ void DialogParentEffect::windowActivated(EffectWindow* w) } } -void DialogParentEffect::windowClosed(EffectWindow* w) +void DialogParentEffect::slotWindowClosed(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 6a78e47a7..3eb4c4a8b 100644 --- a/effects/dialogparent/dialogparent.h +++ b/effects/dialogparent/dialogparent.h @@ -37,6 +37,7 @@ namespace KWin class DialogParentEffect : public Effect { + Q_OBJECT public: DialogParentEffect(); virtual void reconfigure(ReconfigureFlags); @@ -45,9 +46,10 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); - virtual void windowClosed(EffectWindow* c); virtual void windowActivated(EffectWindow* c); +public Q_SLOTS: + void slotWindowClosed(EffectWindow *c); protected: bool hasModalWindow(EffectWindow* t); private: diff --git a/effects/explosion/explosion.cpp b/effects/explosion/explosion.cpp index 8945da164..679dd6c74 100644 --- a/effects/explosion/explosion.cpp +++ b/effects/explosion/explosion.cpp @@ -46,6 +46,7 @@ ExplosionEffect::ExplosionEffect() : Effect() mActiveAnimations = 0; mValid = true; mInited = false; + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } ExplosionEffect::~ExplosionEffect() @@ -180,7 +181,7 @@ void ExplosionEffect::postPaintScreen() effects->postPaintScreen(); } -void ExplosionEffect::windowClosed(EffectWindow* c) +void ExplosionEffect::slotWindowClosed(EffectWindow* c) { const void* e = c->data(WindowClosedGrabRole).value(); if (e && e != this) diff --git a/effects/explosion/explosion.h b/effects/explosion/explosion.h index bdda28b4c..5eb9e7f12 100644 --- a/effects/explosion/explosion.h +++ b/effects/explosion/explosion.h @@ -38,6 +38,7 @@ class GLTexture; class ExplosionEffect : public Effect { + Q_OBJECT public: ExplosionEffect(); ~ExplosionEffect(); @@ -47,11 +48,12 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); - virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); static bool supported(); +public Q_SLOTS: + void slotWindowClosed(EffectWindow *c); protected: bool loadData(); diff --git a/effects/fade/fade.cpp b/effects/fade/fade.cpp index 2ef8a9de7..330aa2fdf 100644 --- a/effects/fade/fade.cpp +++ b/effects/fade/fade.cpp @@ -31,6 +31,7 @@ FadeEffect::FadeEffect() { reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } void FadeEffect::reconfigure(ReconfigureFlags) @@ -162,7 +163,7 @@ void FadeEffect::slotWindowAdded(EffectWindow* w) w->addRepaintFull(); } -void FadeEffect::windowClosed(EffectWindow* w) +void FadeEffect::slotWindowClosed(EffectWindow* w) { if (!fadeWindows || !isFadeWindow(w)) return; diff --git a/effects/fade/fade.h b/effects/fade/fade.h index ebd9a55b2..c4285110e 100644 --- a/effects/fade/fade.h +++ b/effects/fade/fade.h @@ -39,13 +39,13 @@ public: // TODO react also on virtual desktop changes virtual void windowOpacityChanged(EffectWindow* c, double old_opacity); - virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); bool isFadeWindow(EffectWindow* w); public Q_SLOTS: void slotWindowAdded(EffectWindow* c); + void slotWindowClosed(EffectWindow *c); private: class WindowInfo; QHash< const EffectWindow*, WindowInfo > windows; diff --git a/effects/fallapart/fallapart.cpp b/effects/fallapart/fallapart.cpp index e9f545ad2..ac16fc8d9 100644 --- a/effects/fallapart/fallapart.cpp +++ b/effects/fallapart/fallapart.cpp @@ -32,6 +32,7 @@ KWIN_EFFECT(fallapart, FallApartEffect) FallApartEffect::FallApartEffect() { reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } void FallApartEffect::reconfigure(ReconfigureFlags) @@ -142,7 +143,7 @@ bool FallApartEffect::isRealWindow(EffectWindow* w) return true; } -void FallApartEffect::windowClosed(EffectWindow* c) +void FallApartEffect::slotWindowClosed(EffectWindow* c) { if (!isRealWindow(c)) return; diff --git a/effects/fallapart/fallapart.h b/effects/fallapart/fallapart.h index f159e180a..11c1762db 100644 --- a/effects/fallapart/fallapart.h +++ b/effects/fallapart/fallapart.h @@ -29,6 +29,7 @@ namespace KWin class FallApartEffect : public Effect { + Q_OBJECT public: FallApartEffect(); virtual void reconfigure(ReconfigureFlags); @@ -36,8 +37,11 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); - virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); + +public Q_SLOTS: + void slotWindowClosed(EffectWindow *c); + private: QHash< const EffectWindow*, double > windows; bool isRealWindow(EffectWindow* w); diff --git a/effects/flipswitch/flipswitch.cpp b/effects/flipswitch/flipswitch.cpp index d66507ea8..ecf3883c3 100644 --- a/effects/flipswitch/flipswitch.cpp +++ b/effects/flipswitch/flipswitch.cpp @@ -70,6 +70,7 @@ FlipSwitchEffect::FlipSwitchEffect() connect(b, SIGNAL(triggered(bool)), this, SLOT(toggleActiveAllDesktops())); connect(b, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(globalShortcutChangedAll(QKeySequence))); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } FlipSwitchEffect::~FlipSwitchEffect() @@ -584,7 +585,7 @@ void FlipSwitchEffect::slotWindowAdded(EffectWindow* w) } } -void FlipSwitchEffect::windowClosed(EffectWindow* w) +void FlipSwitchEffect::slotWindowClosed(EffectWindow* w) { if (m_active && m_windows.contains(w)) { m_windows.remove(w); diff --git a/effects/flipswitch/flipswitch.h b/effects/flipswitch/flipswitch.h index d1d009e88..75eed010c 100644 --- a/effects/flipswitch/flipswitch.h +++ b/effects/flipswitch/flipswitch.h @@ -47,7 +47,6 @@ public: virtual void tabBoxAdded(int mode); virtual void tabBoxClosed(); virtual void tabBoxUpdated(); - virtual void windowClosed(EffectWindow* w); virtual bool borderActivated(ElectricBorder border); virtual void grabbedKeyboardEvent(QKeyEvent* e); @@ -58,6 +57,7 @@ private Q_SLOTS: void globalShortcutChangedCurrent(QKeySequence shortcut); void globalShortcutChangedAll(QKeySequence shortcut); void slotWindowAdded(EffectWindow* w); + void slotWindowClosed(EffectWindow *w); private: class ItemInfo; diff --git a/effects/glide/glide.cpp b/effects/glide/glide.cpp index bce0d5bd1..12f974ec2 100644 --- a/effects/glide/glide.cpp +++ b/effects/glide/glide.cpp @@ -38,6 +38,7 @@ GlideEffect::GlideEffect() { reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } bool GlideEffect::supported() @@ -180,7 +181,7 @@ void GlideEffect::slotWindowAdded(EffectWindow* w) w->addRepaintFull(); } -void GlideEffect::windowClosed(EffectWindow* w) +void GlideEffect::slotWindowClosed(EffectWindow* w) { if (!isGlideWindow(w)) return; diff --git a/effects/glide/glide.h b/effects/glide/glide.h index c8d8f58f6..9e61bfe10 100644 --- a/effects/glide/glide.h +++ b/effects/glide/glide.h @@ -40,12 +40,12 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); - virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); static bool supported(); public Q_SLOTS: void slotWindowAdded(EffectWindow* c); + void slotWindowClosed(EffectWindow *c); private: class WindowInfo; diff --git a/effects/highlightwindow/highlightwindow.cpp b/effects/highlightwindow/highlightwindow.cpp index e70ad8547..779669ebc 100644 --- a/effects/highlightwindow/highlightwindow.cpp +++ b/effects/highlightwindow/highlightwindow.cpp @@ -39,6 +39,7 @@ HighlightWindowEffect::HighlightWindowEffect() unsigned char dummy = 0; XChangeProperty(display(), rootWindow(), m_atom, m_atom, 8, PropModeReplace, &dummy, 1); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } HighlightWindowEffect::~HighlightWindowEffect() @@ -116,7 +117,7 @@ void HighlightWindowEffect::slotWindowAdded(EffectWindow* w) propertyNotify(w, m_atom); // Check initial value } -void HighlightWindowEffect::windowClosed(EffectWindow* w) +void HighlightWindowEffect::slotWindowClosed(EffectWindow* w) { if (m_monitorWindow == w) // The monitoring window was destroyed finishHighlighting(); diff --git a/effects/highlightwindow/highlightwindow.h b/effects/highlightwindow/highlightwindow.h index 1c3781b9b..bbedea55e 100644 --- a/effects/highlightwindow/highlightwindow.h +++ b/effects/highlightwindow/highlightwindow.h @@ -37,13 +37,13 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void windowClosed(EffectWindow* w); virtual void windowDeleted(EffectWindow* w); virtual void propertyNotify(EffectWindow* w, long atom); public Q_SLOTS: void slotWindowAdded(EffectWindow* w); + void slotWindowClosed(EffectWindow *w); private: void prepareHighlighting(); diff --git a/effects/invert/invert.cpp b/effects/invert/invert.cpp index f7f431549..69298807b 100644 --- a/effects/invert/invert.cpp +++ b/effects/invert/invert.cpp @@ -54,6 +54,7 @@ InvertEffect::InvertEffect() b->setText(i18n("Toggle Invert Effect on Window")); b->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_U)); connect(b, SIGNAL(triggered(bool)), this, SLOT(toggleWindow())); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } InvertEffect::~InvertEffect() @@ -140,7 +141,7 @@ void InvertEffect::paintEffectFrame(KWin::EffectFrame* frame, QRegion region, do } } -void InvertEffect::windowClosed(EffectWindow* w) +void InvertEffect::slotWindowClosed(EffectWindow* w) { m_windows.removeOne(w); } diff --git a/effects/invert/invert.h b/effects/invert/invert.h index 8bd84e063..0d79ba4eb 100644 --- a/effects/invert/invert.h +++ b/effects/invert/invert.h @@ -44,13 +44,13 @@ public: virtual void prePaintScreen(ScreenPrePaintData &data, int time); virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time); virtual void paintEffectFrame(KWin::EffectFrame* frame, QRegion region, double opacity, double frameOpacity); - virtual void windowClosed(EffectWindow* w); static bool supported(); public slots: void toggle(); void toggleWindow(); + void slotWindowClosed(EffectWindow *w); protected: bool loadData(); diff --git a/effects/login/login.cpp b/effects/login/login.cpp index 94f07d9aa..e1d934e23 100644 --- a/effects/login/login.cpp +++ b/effects/login/login.cpp @@ -31,6 +31,7 @@ LoginEffect::LoginEffect() : progress(1.0) , login_window(NULL) { + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } void LoginEffect::prePaintScreen(ScreenPrePaintData& data, int time) @@ -72,7 +73,7 @@ void LoginEffect::postPaintScreen() effects->postPaintScreen(); } -void LoginEffect::windowClosed(EffectWindow* w) +void LoginEffect::slotWindowClosed(EffectWindow* w) { if (isLoginSplash(w)) { if (login_window) diff --git a/effects/login/login.h b/effects/login/login.h index c61f3d1a1..b1735a328 100644 --- a/effects/login/login.h +++ b/effects/login/login.h @@ -30,13 +30,17 @@ namespace KWin class LoginEffect : public Effect { + Q_OBJECT public: LoginEffect(); virtual void prePaintScreen(ScreenPrePaintData& data, int time); 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 windowClosed(EffectWindow* w); + +public Q_SLOTS: + void slotWindowClosed(EffectWindow *w); + private: bool isLoginSplash(EffectWindow* w); double progress; // 0-1 diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index fc6961162..862a594aa 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -61,6 +61,7 @@ LogoutEffect::LogoutEffect() #endif reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } LogoutEffect::~LogoutEffect() @@ -307,7 +308,7 @@ void LogoutEffect::slotWindowAdded(EffectWindow* w) ignoredWindows.append(w); } -void LogoutEffect::windowClosed(EffectWindow* w) +void LogoutEffect::slotWindowClosed(EffectWindow* w) { if (w == logoutWindow) { logoutWindowClosed = true; diff --git a/effects/logout/logout.h b/effects/logout/logout.h index 7dc770068..f641c47cd 100644 --- a/effects/logout/logout.h +++ b/effects/logout/logout.h @@ -44,11 +44,11 @@ public: virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); virtual void postPaintScreen(); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void windowClosed(EffectWindow* w); virtual void windowDeleted(EffectWindow* w); virtual void propertyNotify(EffectWindow* w, long a); public Q_SLOTS: void slotWindowAdded(EffectWindow* w); + void slotWindowClosed(EffectWindow *w); private: bool isLogoutDialog(EffectWindow* w); double progress; // 0-1 diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp index 17da9834a..deed866b3 100644 --- a/effects/presentwindows/presentwindows.cpp +++ b/effects/presentwindows/presentwindows.cpp @@ -99,6 +99,7 @@ PresentWindowsEffect::PresentWindowsEffect() shortcutClass = c->globalShortcut(); reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } PresentWindowsEffect::~PresentWindowsEffect() @@ -385,7 +386,7 @@ void PresentWindowsEffect::slotWindowAdded(EffectWindow *w) } } -void PresentWindowsEffect::windowClosed(EffectWindow *w) +void PresentWindowsEffect::slotWindowClosed(EffectWindow *w) { if (m_managerWindow == w) m_managerWindow = NULL; diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h index 68cb1a41b..1ed4e4b78 100644 --- a/effects/presentwindows/presentwindows.h +++ b/effects/presentwindows/presentwindows.h @@ -102,7 +102,6 @@ public: virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data); // User interaction - virtual void windowClosed(EffectWindow *w); virtual void windowDeleted(EffectWindow *w); virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old); virtual bool borderActivated(ElectricBorder border); @@ -161,6 +160,7 @@ public slots: void globalShortcutChangedClass(const QKeySequence& seq); // EffectsHandler void slotWindowAdded(EffectWindow *w); + void slotWindowClosed(EffectWindow *w); private slots: void closeWindow(); diff --git a/effects/scalein/scalein.cpp b/effects/scalein/scalein.cpp index 7de73aab7..379c4363a 100644 --- a/effects/scalein/scalein.cpp +++ b/effects/scalein/scalein.cpp @@ -29,6 +29,7 @@ ScaleInEffect::ScaleInEffect() : Effect() { connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } void ScaleInEffect::prePaintScreen(ScreenPrePaintData& data, int time) @@ -88,7 +89,7 @@ void ScaleInEffect::slotWindowAdded(EffectWindow* c) } } -void ScaleInEffect::windowClosed(EffectWindow* c) +void ScaleInEffect::slotWindowClosed(EffectWindow* c) { mTimeLineWindows.remove(c); } diff --git a/effects/scalein/scalein.h b/effects/scalein/scalein.h index d894d30f1..e88d67bcf 100644 --- a/effects/scalein/scalein.h +++ b/effects/scalein/scalein.h @@ -37,9 +37,9 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); // TODO react also on virtual desktop changes - virtual void windowClosed(EffectWindow* c); public Q_SLOTS: void slotWindowAdded(EffectWindow* c); + void slotWindowClosed(EffectWindow *c); private: bool isScaleWindow(EffectWindow* w); QHash< const EffectWindow*, TimeLine > mTimeLineWindows; diff --git a/effects/sheet/sheet.cpp b/effects/sheet/sheet.cpp index 58ec71f60..9da6d11b4 100644 --- a/effects/sheet/sheet.cpp +++ b/effects/sheet/sheet.cpp @@ -37,6 +37,7 @@ SheetEffect::SheetEffect() { reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } bool SheetEffect::supported() @@ -141,7 +142,7 @@ void SheetEffect::slotWindowAdded(EffectWindow* w) w->addRepaintFull(); } -void SheetEffect::windowClosed(EffectWindow* w) +void SheetEffect::slotWindowClosed(EffectWindow* w) { if (!isSheetWindow(w)) return; diff --git a/effects/sheet/sheet.h b/effects/sheet/sheet.h index 2bec947cd..a687fc30b 100644 --- a/effects/sheet/sheet.h +++ b/effects/sheet/sheet.h @@ -39,13 +39,13 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); - virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); static bool supported(); public Q_SLOTS: void slotWindowAdded(EffectWindow* c); + void slotWindowClosed(EffectWindow *c); private: class WindowInfo; typedef QMap< const EffectWindow*, WindowInfo > InfoMap; diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 23fdd7b19..3677d5286 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -39,6 +39,7 @@ SlidingPopupsEffect::SlidingPopupsEffect() unsigned char dummy = 0; XChangeProperty(display(), rootWindow(), mAtom, mAtom, 8, PropModeReplace, &dummy, 1); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } SlidingPopupsEffect::~SlidingPopupsEffect() @@ -147,7 +148,7 @@ void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w) } } -void SlidingPopupsEffect::windowClosed(EffectWindow* w) +void SlidingPopupsEffect::slotWindowClosed(EffectWindow* w) { propertyNotify(w, mAtom); if (w->isOnCurrentDesktop() && !w->isMinimized() && mWindowsData.contains(w)) { diff --git a/effects/slidingpopups/slidingpopups.h b/effects/slidingpopups/slidingpopups.h index eb35ec692..2c2755f05 100644 --- a/effects/slidingpopups/slidingpopups.h +++ b/effects/slidingpopups/slidingpopups.h @@ -39,12 +39,12 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); // TODO react also on virtual desktop changes - virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); virtual void propertyNotify(EffectWindow* w, long a); public Q_SLOTS: void slotWindowAdded(EffectWindow *c); + void slotWindowClosed(EffectWindow *c); private: enum Position { West = 0, diff --git a/effects/snaphelper/snaphelper.cpp b/effects/snaphelper/snaphelper.cpp index 8337d1435..7e75c4653 100644 --- a/effects/snaphelper/snaphelper.cpp +++ b/effects/snaphelper/snaphelper.cpp @@ -35,6 +35,7 @@ SnapHelperEffect::SnapHelperEffect() { m_timeline.setCurveShape(TimeLine::LinearCurve); reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); /*if ( effects->compositingType() == XRenderCompositing ) { @@ -187,7 +188,7 @@ void SnapHelperEffect::postPaintScreen() } } -void SnapHelperEffect::windowClosed(EffectWindow* w) +void SnapHelperEffect::slotWindowClosed(EffectWindow* w) { if (m_window == w) { m_window->refWindow(); diff --git a/effects/snaphelper/snaphelper.h b/effects/snaphelper/snaphelper.h index 1b1566f28..771c4e4e6 100644 --- a/effects/snaphelper/snaphelper.h +++ b/effects/snaphelper/snaphelper.h @@ -29,6 +29,7 @@ namespace KWin class SnapHelperEffect : public Effect { + Q_OBJECT public: SnapHelperEffect(); ~SnapHelperEffect(); @@ -37,11 +38,13 @@ public: virtual void prePaintScreen(ScreenPrePaintData &data, int time); virtual void postPaintScreen(); - virtual void windowClosed(EffectWindow* w); virtual void windowUserMovedResized(EffectWindow* w, bool first, bool last); static bool supported(); +public Q_SLOTS: + void slotWindowClosed(EffectWindow *w); + private: bool m_active; EffectWindow* m_window; diff --git a/effects/thumbnailaside/thumbnailaside.cpp b/effects/thumbnailaside/thumbnailaside.cpp index 32276ffde..51ea8834a 100644 --- a/effects/thumbnailaside/thumbnailaside.cpp +++ b/effects/thumbnailaside/thumbnailaside.cpp @@ -38,6 +38,7 @@ ThumbnailAsideEffect::ThumbnailAsideEffect() a->setText(i18n("Toggle Thumbnail for Current Window")); a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_T)); connect(a, SIGNAL(triggered(bool)), this, SLOT(toggleCurrentThumbnail())); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); reconfigure(ReconfigureAll); } @@ -87,7 +88,7 @@ void ThumbnailAsideEffect::windowGeometryShapeChanged(EffectWindow* w, const QRe } } -void ThumbnailAsideEffect::windowClosed(EffectWindow* w) +void ThumbnailAsideEffect::slotWindowClosed(EffectWindow* w) { removeThumbnail(w); } diff --git a/effects/thumbnailaside/thumbnailaside.h b/effects/thumbnailaside/thumbnailaside.h index 02741887a..a27b9b57d 100644 --- a/effects/thumbnailaside/thumbnailaside.h +++ b/effects/thumbnailaside/thumbnailaside.h @@ -45,9 +45,9 @@ public: virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); virtual void windowDamaged(EffectWindow* w, const QRect& damage); virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old); - virtual void windowClosed(EffectWindow* w); private slots: void toggleCurrentThumbnail(); + void slotWindowClosed(EffectWindow *w); private: void addThumbnail(EffectWindow* w); void removeThumbnail(EffectWindow* w); diff --git a/effects/wobblywindows/wobblywindows.cpp b/effects/wobblywindows/wobblywindows.cpp index b04f95faa..27594b882 100644 --- a/effects/wobblywindows/wobblywindows.cpp +++ b/effects/wobblywindows/wobblywindows.cpp @@ -166,6 +166,7 @@ WobblyWindowsEffect::WobblyWindowsEffect() { reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); } WobblyWindowsEffect::~WobblyWindowsEffect() @@ -477,7 +478,7 @@ void WobblyWindowsEffect::slotWindowAdded(EffectWindow* w) } } -void WobblyWindowsEffect::windowClosed(EffectWindow* w) +void WobblyWindowsEffect::slotWindowClosed(EffectWindow* w) { if (windows.contains(w)) { WindowWobblyInfos& wwi = windows[w]; diff --git a/effects/wobblywindows/wobblywindows.h b/effects/wobblywindows/wobblywindows.h index 4c91d4cc3..ff1698029 100644 --- a/effects/wobblywindows/wobblywindows.h +++ b/effects/wobblywindows/wobblywindows.h @@ -36,7 +36,6 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); virtual void windowUserMovedResized(EffectWindow* c, bool first, bool last); - virtual void windowClosed(EffectWindow* w); // Wobbly model parameters void setStiffness(qreal stiffness); @@ -60,6 +59,7 @@ public: public Q_SLOTS: void slotWindowAdded(EffectWindow *w); + void slotWindowClosed(EffectWindow *w); private: diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index 2f4eb4707..4ff80cbc4 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -131,10 +131,6 @@ void Effect::windowOpacityChanged(EffectWindow*, double) { } -void Effect::windowClosed(EffectWindow*) -{ -} - void Effect::windowDeleted(EffectWindow*) { } diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 5767c5e46..9c5fc0d7c 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -445,7 +445,6 @@ public: /** called when the geometry changed during moving/resizing. */ virtual void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); virtual void windowOpacityChanged(EffectWindow* c, double old_opacity); - virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); virtual void windowActivated(EffectWindow* c); virtual void windowMinimized(EffectWindow* c); @@ -844,6 +843,15 @@ Q_SIGNALS: * @since 4.7 **/ void windowAdded(EffectWindow *w); + /** + * Signal emitted when a window is being removed from the Workspace. + * An effect which wants to animate the window closing should connect + * to this signal and reference the window by using + * @link EffectWindow::refWindow + * @param w The window which is being closed + * @since 4.7 + **/ + void windowClosed(EffectWindow *w); protected: QVector< EffectPair > loaded_effects; diff --git a/unmanaged.cpp b/unmanaged.cpp index 0571dddc5..e717bf89f 100644 --- a/unmanaged.cpp +++ b/unmanaged.cpp @@ -81,8 +81,8 @@ bool Unmanaged::track(Window w) void Unmanaged::release() { Deleted* del = Deleted::create(this); - if (effects) { - static_cast(effects)->windowClosed(effectWindow()); + emit unmanagedClosed(this); + if (scene) { scene->windowClosed(this, del); } finishCompositing(); diff --git a/unmanaged.h b/unmanaged.h index f915b1288..c801c4b3d 100644 --- a/unmanaged.h +++ b/unmanaged.h @@ -46,6 +46,8 @@ public: protected: virtual void debug(QDebug& stream) const; virtual bool shouldUnredirect() const; +Q_SIGNALS: + void unmanagedClosed(KWin::Unmanaged*); private: virtual ~Unmanaged(); // use release() // handlers for X11 events diff --git a/workspace.h b/workspace.h index 623a0520f..6e04182b4 100644 --- a/workspace.h +++ b/workspace.h @@ -180,6 +180,19 @@ public: void reserveElectricBorderActions(bool reserve); void reserveElectricBorderSwitching(bool reserve); + /** + * @return List of clients currently managed by Workspace + **/ + const ClientList &clientList() const { + return clients; + } + /** + * @return List of unmanaged "clients" currently registered in Workspace + **/ + const UnmanagedList &unmanagedList() const { + return unmanaged; + } + //------------------------------------------------- // Tiling public: