2007-11-27 22:40:25 +03:00
|
|
|
/********************************************************************
|
2007-04-29 21:35:43 +04:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
2007-11-27 22:40:25 +03:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
#include "deleted.h"
|
|
|
|
|
|
|
|
#include "workspace.h"
|
|
|
|
#include "client.h"
|
2013-04-26 12:41:24 +04:00
|
|
|
#include "netinfo.h"
|
2011-07-14 00:50:31 +04:00
|
|
|
#include "shadow.h"
|
2014-07-23 11:20:28 +04:00
|
|
|
#include "decorations/decoratedclient.h"
|
|
|
|
#include "decorations/decorationrenderer.h"
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-09-02 15:14:39 +04:00
|
|
|
#include <QDebug>
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2013-05-08 15:39:06 +04:00
|
|
|
Deleted::Deleted()
|
|
|
|
: Toplevel()
|
2011-01-30 17:34:42 +03:00
|
|
|
, delete_refcount(1)
|
2013-09-10 10:13:33 +04:00
|
|
|
, m_frame(XCB_WINDOW_NONE)
|
2011-01-30 17:34:42 +03:00
|
|
|
, no_border(true)
|
2012-04-07 18:43:27 +04:00
|
|
|
, m_layer(UnknownLayer)
|
2012-07-21 20:09:58 +04:00
|
|
|
, m_minimized(false)
|
2013-06-03 17:08:05 +04:00
|
|
|
, m_modal(false)
|
2013-06-24 02:13:08 +04:00
|
|
|
, m_wasClient(false)
|
2014-07-23 11:20:28 +04:00
|
|
|
, m_decorationRenderer(nullptr)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
Deleted::~Deleted()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (delete_refcount != 0)
|
2014-12-05 13:42:15 +03:00
|
|
|
qCCritical(KWIN_CORE) << "Deleted client has non-zero reference count (" << delete_refcount << ")";
|
2011-01-30 17:34:42 +03:00
|
|
|
assert(delete_refcount == 0);
|
2013-04-26 11:47:45 +04:00
|
|
|
workspace()->removeDeleted(this);
|
2008-05-21 02:01:49 +04:00
|
|
|
deleteEffectWindow();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
Deleted* Deleted::create(Toplevel* c)
|
|
|
|
{
|
2013-05-08 15:39:06 +04:00
|
|
|
Deleted* d = new Deleted();
|
2011-01-30 17:34:42 +03:00
|
|
|
d->copyToDeleted(c);
|
2013-05-08 15:39:06 +04:00
|
|
|
workspace()->addDeleted(d, c);
|
2007-04-29 21:35:43 +04:00
|
|
|
return d;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2008-07-28 15:49:43 +04:00
|
|
|
|
|
|
|
// to be used only from Workspace::finishCompositing()
|
2013-04-26 11:47:45 +04:00
|
|
|
void Deleted::discard()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2008-07-28 15:49:43 +04:00
|
|
|
delete_refcount = 0;
|
|
|
|
delete this;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void Deleted::copyToDeleted(Toplevel* c)
|
|
|
|
{
|
|
|
|
assert(dynamic_cast< Deleted* >(c) == NULL);
|
|
|
|
Toplevel::copyToDeleted(c);
|
2007-04-29 21:35:43 +04:00
|
|
|
desk = c->desktop();
|
2010-05-12 00:30:20 +04:00
|
|
|
activityList = c->activities();
|
2011-01-30 17:34:42 +03:00
|
|
|
contentsRect = QRect(c->clientPos(), c->clientSize());
|
2009-11-26 02:32:35 +03:00
|
|
|
transparent_rect = c->transparentRect();
|
2012-04-07 18:43:27 +04:00
|
|
|
m_layer = c->layer();
|
2013-09-10 10:13:33 +04:00
|
|
|
m_frame = c->frameId();
|
2015-03-04 09:56:51 +03:00
|
|
|
m_opacity = c->opacity();
|
2015-03-04 10:26:57 +03:00
|
|
|
m_type = c->windowType(true);
|
2015-03-04 10:53:51 +03:00
|
|
|
m_windowRole = c->windowRole();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info))
|
2007-04-29 21:35:43 +04:00
|
|
|
cinfo->disable();
|
2009-07-29 15:07:28 +04:00
|
|
|
Client* client = dynamic_cast<Client*>(c);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (client) {
|
2009-07-29 15:07:28 +04:00
|
|
|
no_border = client->noBorder();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!no_border) {
|
2009-07-29 15:07:28 +04:00
|
|
|
client->layoutDecorationRects(decoration_left,
|
|
|
|
decoration_top,
|
|
|
|
decoration_right,
|
2014-07-25 14:55:28 +04:00
|
|
|
decoration_bottom);
|
2014-10-21 09:46:44 +04:00
|
|
|
if (client->isDecorated()) {
|
|
|
|
if (Decoration::Renderer *renderer = client->decoratedClient()->renderer()) {
|
2014-07-23 11:20:28 +04:00
|
|
|
m_decorationRenderer = renderer;
|
|
|
|
m_decorationRenderer->reparent(this);
|
|
|
|
}
|
|
|
|
}
|
2009-07-29 15:07:28 +04:00
|
|
|
}
|
2015-09-11 16:55:23 +03:00
|
|
|
}
|
|
|
|
if (AbstractClient *client = dynamic_cast<AbstractClient*>(c)) {
|
2015-09-14 10:06:41 +03:00
|
|
|
m_wasClient = true;
|
|
|
|
m_minimized = client->isMinimized();
|
|
|
|
m_modal = client->isModal();
|
2013-06-03 17:08:05 +04:00
|
|
|
m_mainClients = client->mainClients();
|
2015-09-11 16:55:23 +03:00
|
|
|
foreach (AbstractClient *c, m_mainClients) {
|
|
|
|
connect(c, &AbstractClient::windowClosed, this, &Deleted::mainClientClosed);
|
2013-06-03 17:08:05 +04:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-05-31 21:15:51 +04:00
|
|
|
void Deleted::unrefWindow()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (--delete_refcount > 0)
|
2007-04-29 21:35:43 +04:00
|
|
|
return;
|
2013-05-31 21:15:51 +04:00
|
|
|
// needs to be delayed
|
|
|
|
// a) when calling from effects, otherwise it'd be rather complicated to handle the case of the
|
|
|
|
// window going away during a painting pass
|
|
|
|
// b) to prevent dangeling pointers in the stacking order, see bug #317765
|
|
|
|
deleteLater();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
int Deleted::desktop() const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2007-04-29 21:35:43 +04:00
|
|
|
return desk;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2010-05-12 00:30:20 +04:00
|
|
|
QStringList Deleted::activities() const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2010-05-12 00:30:20 +04:00
|
|
|
return activityList;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2010-05-12 00:30:20 +04:00
|
|
|
|
2007-07-18 19:01:59 +04:00
|
|
|
QPoint Deleted::clientPos() const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2007-07-18 19:01:59 +04:00
|
|
|
return contentsRect.topLeft();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-07-18 19:01:59 +04:00
|
|
|
|
|
|
|
QSize Deleted::clientSize() const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2007-07-18 19:01:59 +04:00
|
|
|
return contentsRect.size();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-07-18 19:01:59 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void Deleted::debug(QDebug& stream) const
|
|
|
|
{
|
2007-04-29 21:35:43 +04:00
|
|
|
stream << "\'ID:" << window() << "\' (deleted)";
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2014-07-25 14:55:28 +04:00
|
|
|
void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect& bottom) const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2009-07-29 15:07:28 +04:00
|
|
|
left = decoration_left;
|
|
|
|
top = decoration_top;
|
|
|
|
right = decoration_right;
|
|
|
|
bottom = decoration_bottom;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-07-29 15:07:28 +04:00
|
|
|
|
|
|
|
QRect Deleted::decorationRect() const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2014-07-23 11:20:28 +04:00
|
|
|
return rect();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-07-29 15:07:28 +04:00
|
|
|
|
2009-11-26 02:32:35 +03:00
|
|
|
QRect Deleted::transparentRect() const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2009-11-26 02:32:35 +03:00
|
|
|
return transparent_rect;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-11-26 02:32:35 +03:00
|
|
|
|
2012-01-15 13:51:09 +04:00
|
|
|
bool Deleted::isDeleted() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-06 11:09:31 +04:00
|
|
|
NET::WindowType Deleted::windowType(bool direct, int supportedTypes) const
|
|
|
|
{
|
|
|
|
Q_UNUSED(direct)
|
2015-03-04 10:26:57 +03:00
|
|
|
Q_UNUSED(supportedTypes)
|
|
|
|
return m_type;
|
2012-09-06 11:09:31 +04:00
|
|
|
}
|
|
|
|
|
2013-06-03 17:08:05 +04:00
|
|
|
void Deleted::mainClientClosed(Toplevel *client)
|
|
|
|
{
|
2015-09-14 14:53:46 +03:00
|
|
|
if (AbstractClient *c = dynamic_cast<AbstractClient*>(client))
|
|
|
|
m_mainClients.removeAll(c);
|
2013-06-03 17:08:05 +04:00
|
|
|
}
|
|
|
|
|
2013-09-10 10:13:33 +04:00
|
|
|
xcb_window_t Deleted::frameId() const
|
|
|
|
{
|
|
|
|
return m_frame;
|
|
|
|
}
|
|
|
|
|
2015-03-04 09:56:51 +03:00
|
|
|
double Deleted::opacity() const
|
|
|
|
{
|
|
|
|
return m_opacity;
|
|
|
|
}
|
|
|
|
|
2015-03-04 10:53:51 +03:00
|
|
|
QByteArray Deleted::windowRole() const
|
|
|
|
{
|
|
|
|
return m_windowRole;
|
|
|
|
}
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "deleted.moc"
|