~arjunak234-deactivatedaccount/kde-workspace/fix125114

« back to all changes in this revision

Viewing changes to kwin/deleted.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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
*********************************************************************/
 
20
 
 
21
#include "deleted.h"
 
22
 
 
23
#include "workspace.h"
 
24
#include "client.h"
 
25
 
 
26
namespace KWin
 
27
{
 
28
 
 
29
Deleted::Deleted(Workspace* ws)
 
30
    : Toplevel(ws)
 
31
    , delete_refcount(1)
 
32
    , no_border(true)
 
33
    , padding_left(0)
 
34
    , padding_top(0)
 
35
    , padding_right(0)
 
36
    , padding_bottom(0)
 
37
{
 
38
}
 
39
 
 
40
Deleted::~Deleted()
 
41
{
 
42
    if (delete_refcount != 0)
 
43
        kError(1212) << "Deleted client has non-zero reference count (" << delete_refcount << ")";
 
44
    assert(delete_refcount == 0);
 
45
    workspace()->removeDeleted(this, Allowed);
 
46
    deleteEffectWindow();
 
47
}
 
48
 
 
49
Deleted* Deleted::create(Toplevel* c)
 
50
{
 
51
    Deleted* d = new Deleted(c->workspace());
 
52
    d->copyToDeleted(c);
 
53
    d->workspace()->addDeleted(d, Allowed);
 
54
    return d;
 
55
}
 
56
 
 
57
// to be used only from Workspace::finishCompositing()
 
58
void Deleted::discard(allowed_t)
 
59
{
 
60
    delete_refcount = 0;
 
61
    delete this;
 
62
}
 
63
 
 
64
void Deleted::copyToDeleted(Toplevel* c)
 
65
{
 
66
    assert(dynamic_cast< Deleted* >(c) == NULL);
 
67
    Toplevel::copyToDeleted(c);
 
68
    desk = c->desktop();
 
69
    activityList = c->activities();
 
70
    contentsRect = QRect(c->clientPos(), c->clientSize());
 
71
    transparent_rect = c->transparentRect();
 
72
    if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info))
 
73
        cinfo->disable();
 
74
    Client* client = dynamic_cast<Client*>(c);
 
75
    if (client) {
 
76
        no_border = client->noBorder();
 
77
        padding_left = client->paddingLeft();
 
78
        padding_right = client->paddingRight();
 
79
        padding_bottom = client->paddingBottom();
 
80
        padding_top = client->paddingTop();
 
81
        if (!no_border) {
 
82
            client->layoutDecorationRects(decoration_left,
 
83
                                          decoration_top,
 
84
                                          decoration_right,
 
85
                                          decoration_bottom,
 
86
                                          Client::WindowRelative);
 
87
            decorationPixmapLeft = *client->leftDecoPixmap();
 
88
            decorationPixmapRight = *client->rightDecoPixmap();
 
89
            decorationPixmapTop = *client->topDecoPixmap();
 
90
            decorationPixmapBottom = *client->bottomDecoPixmap();
 
91
        }
 
92
    }
 
93
}
 
94
 
 
95
void Deleted::unrefWindow(bool delay)
 
96
{
 
97
    if (--delete_refcount > 0)
 
98
        return;
 
99
    // needs to be delayed when calling from effects, otherwise it'd be rather
 
100
    // complicated to handle the case of the window going away during a painting pass
 
101
    if (delay)
 
102
        deleteLater();
 
103
    else
 
104
        delete this;
 
105
}
 
106
 
 
107
int Deleted::desktop() const
 
108
{
 
109
    return desk;
 
110
}
 
111
 
 
112
QStringList Deleted::activities() const
 
113
{
 
114
    return activityList;
 
115
}
 
116
 
 
117
QPoint Deleted::clientPos() const
 
118
{
 
119
    return contentsRect.topLeft();
 
120
}
 
121
 
 
122
QSize Deleted::clientSize() const
 
123
{
 
124
    return contentsRect.size();
 
125
}
 
126
 
 
127
void Deleted::debug(QDebug& stream) const
 
128
{
 
129
    stream << "\'ID:" << window() << "\' (deleted)";
 
130
}
 
131
 
 
132
void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect& bottom) const
 
133
{
 
134
    left = decoration_left;
 
135
    top = decoration_top;
 
136
    right = decoration_right;
 
137
    bottom = decoration_bottom;
 
138
}
 
139
 
 
140
QRect Deleted::decorationRect() const
 
141
{
 
142
    return rect().adjusted(-padding_left, -padding_top, padding_top, padding_bottom);
 
143
}
 
144
 
 
145
QRect Deleted::transparentRect() const
 
146
{
 
147
    return transparent_rect;
 
148
}
 
149
 
 
150
} // namespace
 
151
 
 
152
#include "deleted.moc"