add more spacing
[personal-kdebase.git] / workspace / kwin / deleted.cpp
blob4e97a76d20c55cb4b3591f1fc2c4eee0521f99ec
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
21 #include "deleted.h"
23 #include "workspace.h"
24 #include "client.h"
25 #include "effects.h"
27 namespace KWin
30 Deleted::Deleted( Workspace* ws )
31 : Toplevel( ws )
32 , delete_refcount( 1 )
36 Deleted::~Deleted()
38 assert( delete_refcount == 0 );
39 workspace()->removeDeleted( this, Allowed );
40 deleteEffectWindow();
43 Deleted* Deleted::create( Toplevel* c )
45 Deleted* d = new Deleted( c->workspace());
46 d->copyToDeleted( c );
47 d->workspace()->addDeleted( d, Allowed );
48 return d;
51 // to be used only from Workspace::finishCompositing()
52 void Deleted::discard( allowed_t )
54 delete_refcount = 0;
55 delete this;
58 void Deleted::copyToDeleted( Toplevel* c )
60 assert( dynamic_cast< Deleted* >( c ) == NULL );
61 Toplevel::copyToDeleted( c );
62 desk = c->desktop();
63 contentsRect = QRect( c->clientPos(), c->clientSize());
64 if( WinInfo* cinfo = dynamic_cast< WinInfo* >( info ))
65 cinfo->disable();
68 void Deleted::unrefWindow( bool delay )
70 if( --delete_refcount > 0 )
71 return;
72 // needs to be delayed when calling from effects, otherwise it'd be rather
73 // complicated to handle the case of the window going away during a painting pass
74 if( delay )
75 deleteLater();
76 else
77 delete this;
80 int Deleted::desktop() const
82 return desk;
85 QPoint Deleted::clientPos() const
87 return contentsRect.topLeft();
90 QSize Deleted::clientSize() const
92 return contentsRect.size();
95 void Deleted::debug( kdbgstream& stream ) const
97 stream << "\'ID:" << window() << "\' (deleted)";
100 } // namespace
102 #include "deleted.moc"