2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00: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 19:40:25 +00: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 17:35:43 +00:00
|
|
|
|
|
|
|
#include "deleted.h"
|
|
|
|
|
|
|
|
#include "workspace.h"
|
|
|
|
#include "client.h"
|
2013-04-26 08:41:24 +00:00
|
|
|
#include "netinfo.h"
|
2012-09-28 09:59:42 +00:00
|
|
|
#include "paintredirector.h"
|
2011-07-13 20:50:31 +00:00
|
|
|
#include "shadow.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Deleted::Deleted(Workspace* ws)
|
|
|
|
: Toplevel(ws)
|
|
|
|
, delete_refcount(1)
|
|
|
|
, no_border(true)
|
|
|
|
, padding_left(0)
|
|
|
|
, padding_top(0)
|
|
|
|
, padding_right(0)
|
|
|
|
, padding_bottom(0)
|
2012-04-07 14:43:27 +00:00
|
|
|
, m_layer(UnknownLayer)
|
2012-07-21 16:09:58 +00:00
|
|
|
, m_minimized(false)
|
2012-09-28 09:59:42 +00:00
|
|
|
, m_paintRedirector(NULL)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Deleted::~Deleted()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (delete_refcount != 0)
|
2009-10-19 04:52:40 +00:00
|
|
|
kError(1212) << "Deleted client has non-zero reference count (" << delete_refcount << ")";
|
2011-01-30 14:34:42 +00:00
|
|
|
assert(delete_refcount == 0);
|
2013-04-26 07:47:45 +00:00
|
|
|
workspace()->removeDeleted(this);
|
2008-05-20 22:01:49 +00:00
|
|
|
deleteEffectWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Deleted* Deleted::create(Toplevel* c)
|
|
|
|
{
|
|
|
|
Deleted* d = new Deleted(c->workspace());
|
|
|
|
d->copyToDeleted(c);
|
2013-04-26 07:47:45 +00:00
|
|
|
d->workspace()->addDeleted(d, c);
|
2007-04-29 17:35:43 +00:00
|
|
|
return d;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-07-28 11:49:43 +00:00
|
|
|
|
|
|
|
// to be used only from Workspace::finishCompositing()
|
2013-04-26 07:47:45 +00:00
|
|
|
void Deleted::discard()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-07-28 11:49:43 +00:00
|
|
|
delete_refcount = 0;
|
|
|
|
delete this;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Deleted::copyToDeleted(Toplevel* c)
|
|
|
|
{
|
|
|
|
assert(dynamic_cast< Deleted* >(c) == NULL);
|
|
|
|
Toplevel::copyToDeleted(c);
|
2007-04-29 17:35:43 +00:00
|
|
|
desk = c->desktop();
|
2010-05-11 20:30:20 +00:00
|
|
|
activityList = c->activities();
|
2011-01-30 14:34:42 +00:00
|
|
|
contentsRect = QRect(c->clientPos(), c->clientSize());
|
2009-11-25 23:32:35 +00:00
|
|
|
transparent_rect = c->transparentRect();
|
2012-04-07 14:43:27 +00:00
|
|
|
m_layer = c->layer();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info))
|
2007-04-29 17:35:43 +00:00
|
|
|
cinfo->disable();
|
2009-07-29 11:07:28 +00:00
|
|
|
Client* client = dynamic_cast<Client*>(c);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (client) {
|
2009-07-29 11:07:28 +00:00
|
|
|
no_border = client->noBorder();
|
|
|
|
padding_left = client->paddingLeft();
|
|
|
|
padding_right = client->paddingRight();
|
|
|
|
padding_bottom = client->paddingBottom();
|
|
|
|
padding_top = client->paddingTop();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!no_border) {
|
2009-07-29 11:07:28 +00:00
|
|
|
client->layoutDecorationRects(decoration_left,
|
|
|
|
decoration_top,
|
|
|
|
decoration_right,
|
|
|
|
decoration_bottom,
|
|
|
|
Client::WindowRelative);
|
2012-09-28 09:59:42 +00:00
|
|
|
if (PaintRedirector *redirector = client->decorationPaintRedirector()) {
|
|
|
|
redirector->ensurePixmapsPainted();
|
|
|
|
redirector->reparent(this);
|
|
|
|
m_paintRedirector = redirector;
|
|
|
|
}
|
2009-07-29 11:07:28 +00:00
|
|
|
}
|
2012-07-21 16:09:58 +00:00
|
|
|
m_minimized = client->isMinimized();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Deleted::unrefWindow(bool delay)
|
|
|
|
{
|
|
|
|
if (--delete_refcount > 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2007-05-09 16:10:49 +00:00
|
|
|
// needs to be delayed when calling from effects, otherwise it'd be rather
|
|
|
|
// complicated to handle the case of the window going away during a painting pass
|
2011-01-30 14:34:42 +00:00
|
|
|
if (delay)
|
2007-05-09 16:10:49 +00:00
|
|
|
deleteLater();
|
|
|
|
else
|
|
|
|
delete this;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int Deleted::desktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return desk;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-05-11 20:30:20 +00:00
|
|
|
QStringList Deleted::activities() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-05-11 20:30:20 +00:00
|
|
|
return activityList;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-05-11 20:30:20 +00:00
|
|
|
|
2007-07-18 15:01:59 +00:00
|
|
|
QPoint Deleted::clientPos() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-07-18 15:01:59 +00:00
|
|
|
return contentsRect.topLeft();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-07-18 15:01:59 +00:00
|
|
|
|
|
|
|
QSize Deleted::clientSize() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-07-18 15:01:59 +00:00
|
|
|
return contentsRect.size();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-07-18 15:01:59 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Deleted::debug(QDebug& stream) const
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
stream << "\'ID:" << window() << "\' (deleted)";
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-09-06 10:55:15 +00:00
|
|
|
void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect& bottom, int) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-07-29 11:07:28 +00:00
|
|
|
left = decoration_left;
|
|
|
|
top = decoration_top;
|
|
|
|
right = decoration_right;
|
|
|
|
bottom = decoration_bottom;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-07-29 11:07:28 +00:00
|
|
|
|
|
|
|
QRect Deleted::decorationRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-03-10 10:34:56 +00:00
|
|
|
return rect().adjusted(-padding_left, -padding_top, padding_top, padding_bottom);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-07-29 11:07:28 +00:00
|
|
|
|
2009-11-25 23:32:35 +00:00
|
|
|
QRect Deleted::transparentRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-25 23:32:35 +00:00
|
|
|
return transparent_rect;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-25 23:32:35 +00:00
|
|
|
|
2012-01-15 09:51:09 +00:00
|
|
|
bool Deleted::isDeleted() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-06 07:09:31 +00:00
|
|
|
NET::WindowType Deleted::windowType(bool direct, int supportedTypes) const
|
|
|
|
{
|
|
|
|
Q_UNUSED(direct)
|
|
|
|
// TODO: maybe retrieve the actual window type when copying to deleted?
|
|
|
|
if (supportedTypes == 0) {
|
|
|
|
supportedTypes = SUPPORTED_UNMANAGED_WINDOW_TYPES_MASK;
|
|
|
|
}
|
|
|
|
return info->windowType(supportedTypes);
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "deleted.moc"
|