~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/kcmkwin/kwintabbox/previewhandlerimpl.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) 2009 Martin Gräßlin <kde@martin-graesslin.com>
 
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 "previewhandlerimpl.h"
 
22
#include <kephal/screens.h>
 
23
#include <klocalizedstring.h>
 
24
#include <kwindowsystem.h>
 
25
#include <KDebug>
 
26
 
 
27
namespace KWin
 
28
{
 
29
namespace TabBox
 
30
{
 
31
 
 
32
PreviewClientImpl::PreviewClientImpl(WId id)
 
33
    : m_id(id)
 
34
{
 
35
}
 
36
 
 
37
PreviewClientImpl::~PreviewClientImpl()
 
38
{
 
39
}
 
40
 
 
41
QString PreviewClientImpl::caption() const
 
42
{
 
43
    KWindowInfo info = KWindowSystem::windowInfo(m_id, NET::WMVisibleName);
 
44
    return info.visibleName();
 
45
}
 
46
 
 
47
QPixmap PreviewClientImpl::icon(const QSize& size) const
 
48
{
 
49
    return KWindowSystem::icon(m_id, size.width(), size.height(), true);
 
50
}
 
51
 
 
52
bool PreviewClientImpl::isMinimized() const
 
53
{
 
54
    KWindowInfo info = KWindowSystem::windowInfo(m_id, NET::WMState | NET::XAWMState);
 
55
    return info.isMinimized();
 
56
}
 
57
 
 
58
int PreviewClientImpl::width() const
 
59
{
 
60
    return 0; // only needed for the outline - not needed in preview
 
61
}
 
62
 
 
63
int PreviewClientImpl::height() const
 
64
{
 
65
    return 0; // only needed for the outline - not needed in preview
 
66
}
 
67
 
 
68
WId PreviewClientImpl::window() const
 
69
{
 
70
    return m_id;
 
71
}
 
72
 
 
73
int PreviewClientImpl::x() const
 
74
{
 
75
    return 0; // only needed for the outline - not needed in preview
 
76
}
 
77
 
 
78
int PreviewClientImpl::y() const
 
79
{
 
80
    return 0; // only needed for the outline - not needed in preview
 
81
}
 
82
 
 
83
/*******************************************************
 
84
* PreviewHandlerImpl
 
85
*******************************************************/
 
86
PreviewHandlerImpl::PreviewHandlerImpl()
 
87
{
 
88
    QList< WId > windows = KWindowSystem::stackingOrder();
 
89
    foreach (WId w, windows) {
 
90
        m_stackingOrder.append(new PreviewClientImpl(w));
 
91
        kDebug(1212) << "Window " << w;
 
92
    }
 
93
}
 
94
 
 
95
PreviewHandlerImpl::~PreviewHandlerImpl()
 
96
{
 
97
    qDeleteAll(m_stackingOrder.begin(), m_stackingOrder.end());
 
98
    m_stackingOrder.clear();
 
99
}
 
100
 
 
101
TabBoxClient* PreviewHandlerImpl::clientToAddToList(TabBoxClient* client, int desktop, bool allDesktops) const
 
102
{
 
103
    Q_UNUSED(desktop)
 
104
    Q_UNUSED(allDesktops)
 
105
    // don't include desktops and panels
 
106
    KWindowInfo info = KWindowSystem::windowInfo(client->window(), NET::WMWindowType);
 
107
    NET::WindowType wType = info.windowType(NET::NormalMask | NET::DesktopMask | NET::DockMask |
 
108
                                            NET::ToolbarMask | NET::MenuMask | NET::DialogMask |
 
109
                                            NET::OverrideMask | NET::TopMenuMask |
 
110
                                            NET::UtilityMask | NET::SplashMask);
 
111
 
 
112
    if (wType != NET::Normal && wType != NET::Override && wType != NET::Unknown &&
 
113
            wType != NET::Dialog && wType != NET::Utility) {
 
114
        return NULL;
 
115
    }
 
116
    return client;
 
117
}
 
118
 
 
119
TabBoxClientList PreviewHandlerImpl::stackingOrder() const
 
120
{
 
121
    return m_stackingOrder;
 
122
}
 
123
 
 
124
int PreviewHandlerImpl::nextDesktopFocusChain(int desktop) const
 
125
{
 
126
    int ret = desktop + 1;
 
127
    if (ret > numberOfDesktops())
 
128
        ret = 1;
 
129
    return ret;
 
130
}
 
131
 
 
132
int PreviewHandlerImpl::numberOfDesktops() const
 
133
{
 
134
    return KWindowSystem::numberOfDesktops();
 
135
}
 
136
 
 
137
int PreviewHandlerImpl::currentDesktop() const
 
138
{
 
139
    return KWindowSystem::currentDesktop();
 
140
}
 
141
 
 
142
QString PreviewHandlerImpl::desktopName(int desktop) const
 
143
{
 
144
    return KWindowSystem::desktopName(desktop);
 
145
}
 
146
 
 
147
QString PreviewHandlerImpl::desktopName(TabBoxClient* client) const
 
148
{
 
149
    Q_UNUSED(client)
 
150
    return desktopName(1);
 
151
}
 
152
 
 
153
TabBoxClient* PreviewHandlerImpl::nextClientFocusChain(TabBoxClient* client) const
 
154
{
 
155
    if (m_stackingOrder.isEmpty())
 
156
        return NULL;
 
157
    int index = m_stackingOrder.indexOf(client);
 
158
    index++;
 
159
    if (index >= m_stackingOrder.count())
 
160
        index = 0;
 
161
    return m_stackingOrder[ index ];
 
162
}
 
163
 
 
164
KWin::TabBox::TabBoxClient* PreviewHandlerImpl::activeClient() const
 
165
{
 
166
    if (m_stackingOrder.isEmpty())
 
167
        return NULL;
 
168
    return m_stackingOrder[ 0 ];
 
169
}
 
170
 
 
171
int PreviewHandlerImpl::activeScreen() const
 
172
{
 
173
    return 0;
 
174
}
 
175
 
 
176
TabBoxClient* PreviewHandlerImpl::desktopClient() const
 
177
{
 
178
    return 0;
 
179
}
 
180
 
 
181
 
 
182
} // namespace TabBox
 
183
} // namespace KWin