1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
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 "previewhandlerimpl.h"
22
#include <kephal/screens.h>
23
#include <klocalizedstring.h>
24
#include <kwindowsystem.h>
32
PreviewClientImpl::PreviewClientImpl(WId id)
37
PreviewClientImpl::~PreviewClientImpl()
41
QString PreviewClientImpl::caption() const
43
KWindowInfo info = KWindowSystem::windowInfo(m_id, NET::WMVisibleName);
44
return info.visibleName();
47
QPixmap PreviewClientImpl::icon(const QSize& size) const
49
return KWindowSystem::icon(m_id, size.width(), size.height(), true);
52
bool PreviewClientImpl::isMinimized() const
54
KWindowInfo info = KWindowSystem::windowInfo(m_id, NET::WMState | NET::XAWMState);
55
return info.isMinimized();
58
int PreviewClientImpl::width() const
60
return 0; // only needed for the outline - not needed in preview
63
int PreviewClientImpl::height() const
65
return 0; // only needed for the outline - not needed in preview
68
WId PreviewClientImpl::window() const
73
int PreviewClientImpl::x() const
75
return 0; // only needed for the outline - not needed in preview
78
int PreviewClientImpl::y() const
80
return 0; // only needed for the outline - not needed in preview
83
/*******************************************************
85
*******************************************************/
86
PreviewHandlerImpl::PreviewHandlerImpl()
88
QList< WId > windows = KWindowSystem::stackingOrder();
89
foreach (WId w, windows) {
90
m_stackingOrder.append(new PreviewClientImpl(w));
91
kDebug(1212) << "Window " << w;
95
PreviewHandlerImpl::~PreviewHandlerImpl()
97
qDeleteAll(m_stackingOrder.begin(), m_stackingOrder.end());
98
m_stackingOrder.clear();
101
TabBoxClient* PreviewHandlerImpl::clientToAddToList(TabBoxClient* client, int desktop, bool allDesktops) const
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);
112
if (wType != NET::Normal && wType != NET::Override && wType != NET::Unknown &&
113
wType != NET::Dialog && wType != NET::Utility) {
119
TabBoxClientList PreviewHandlerImpl::stackingOrder() const
121
return m_stackingOrder;
124
int PreviewHandlerImpl::nextDesktopFocusChain(int desktop) const
126
int ret = desktop + 1;
127
if (ret > numberOfDesktops())
132
int PreviewHandlerImpl::numberOfDesktops() const
134
return KWindowSystem::numberOfDesktops();
137
int PreviewHandlerImpl::currentDesktop() const
139
return KWindowSystem::currentDesktop();
142
QString PreviewHandlerImpl::desktopName(int desktop) const
144
return KWindowSystem::desktopName(desktop);
147
QString PreviewHandlerImpl::desktopName(TabBoxClient* client) const
150
return desktopName(1);
153
TabBoxClient* PreviewHandlerImpl::nextClientFocusChain(TabBoxClient* client) const
155
if (m_stackingOrder.isEmpty())
157
int index = m_stackingOrder.indexOf(client);
159
if (index >= m_stackingOrder.count())
161
return m_stackingOrder[ index ];
164
KWin::TabBox::TabBoxClient* PreviewHandlerImpl::activeClient() const
166
if (m_stackingOrder.isEmpty())
168
return m_stackingOrder[ 0 ];
171
int PreviewHandlerImpl::activeScreen() const
176
TabBoxClient* PreviewHandlerImpl::desktopClient() const
182
} // namespace TabBox