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.
This commit is contained in:
Martin Gräßlin 2013-06-03 15:08:05 +02:00
parent 4b4646973b
commit a4ec610d23
3 changed files with 37 additions and 6 deletions

View file

@ -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*>(client));
}
} // namespace
#include "deleted.moc"

View file

@ -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;
};

View file

@ -1707,14 +1707,23 @@ EffectWindow* EffectWindowImpl::findModal()
return NULL;
}
template <typename T>
EffectWindowList getMainWindows(Toplevel *toplevel)
{
T *c = static_cast<T*>(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<Client>(toplevel);
} else if (toplevel->isDeleted()) {
return getMainWindows<Deleted>(toplevel);
}
return EffectWindowList();
}