From a4ec610d23f30cef6998e4516072392bda228ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 3 Jun 2013 15:08:05 +0200 Subject: [PATCH] Copy modal state and mainWindows from Client to Deleted Otherwise it's not possible to access them in the windowClosed handler. That the dialog parent effect worked at all was pure chance. --- deleted.cpp | 11 +++++++++++ deleted.h | 11 +++++++++++ effects.cpp | 21 +++++++++++++++------ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/deleted.cpp b/deleted.cpp index 4ea146c0d4..5f505b62c5 100644 --- a/deleted.cpp +++ b/deleted.cpp @@ -39,6 +39,7 @@ Deleted::Deleted() , padding_bottom(0) , m_layer(UnknownLayer) , m_minimized(false) + , m_modal(false) , m_paintRedirector(NULL) { } @@ -98,6 +99,11 @@ void Deleted::copyToDeleted(Toplevel* c) } } m_minimized = client->isMinimized(); + m_modal = client->isModal(); + m_mainClients = client->mainClients(); + foreach (Client *c, m_mainClients) { + connect(c, SIGNAL(windowClosed(KWin::Toplevel*,KWin::Deleted*)), SLOT(mainClientClosed(KWin::Toplevel*))); + } } } @@ -171,6 +177,11 @@ NET::WindowType Deleted::windowType(bool direct, int supportedTypes) const return info->windowType(supportedTypes); } +void Deleted::mainClientClosed(Toplevel *client) +{ + m_mainClients.removeAll(static_cast(client)); +} + } // namespace #include "deleted.moc" diff --git a/deleted.h b/deleted.h index 3a729ba171..53b45bb97d 100644 --- a/deleted.h +++ b/deleted.h @@ -32,6 +32,7 @@ class Deleted { Q_OBJECT Q_PROPERTY(bool minimized READ isMinimized) + Q_PROPERTY(bool modal READ isModal) public: static Deleted* create(Toplevel* c); // used by effects to keep the window around for e.g. fadeout effects when it's destroyed @@ -55,6 +56,12 @@ public: bool isMinimized() const { return m_minimized; } + bool isModal() const { + return m_modal; + } + ClientList mainClients() const { + return m_mainClients; + } NET::WindowType windowType(bool direct = false, int supported_types = 0) const; PaintRedirector *decorationPaintRedirector() { return m_paintRedirector; @@ -62,6 +69,8 @@ public: protected: virtual void debug(QDebug& stream) const; virtual bool shouldUnredirect() const; +private Q_SLOTS: + void mainClientClosed(KWin::Toplevel *client); private: Deleted(); // use create() void copyToDeleted(Toplevel* c); @@ -81,6 +90,8 @@ private: int padding_left, padding_top, padding_right, padding_bottom; Layer m_layer; bool m_minimized; + bool m_modal; + ClientList m_mainClients; PaintRedirector *m_paintRedirector; }; diff --git a/effects.cpp b/effects.cpp index be0eb548b8..6d6510da10 100644 --- a/effects.cpp +++ b/effects.cpp @@ -1707,14 +1707,23 @@ EffectWindow* EffectWindowImpl::findModal() return NULL; } +template +EffectWindowList getMainWindows(Toplevel *toplevel) +{ + T *c = static_cast(toplevel); + EffectWindowList ret; + ClientList mainclients = c->mainClients(); + foreach (Client * tmp, mainclients) + ret.append(tmp->effectWindow()); + return ret; +} + EffectWindowList EffectWindowImpl::mainWindows() const { - if (Client* c = dynamic_cast< Client* >(toplevel)) { - EffectWindowList ret; - ClientList mainclients = c->mainClients(); - foreach (Client * tmp, mainclients) - ret.append(tmp->effectWindow()); - return ret; + if (toplevel->isClient()) { + return getMainWindows(toplevel); + } else if (toplevel->isDeleted()) { + return getMainWindows(toplevel); } return EffectWindowList(); }