kwin/kcmkwin/kwintabbox/previewhandlerimpl.cpp

184 lines
4.7 KiB
C++
Raw Normal View History

/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
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/>.
*********************************************************************/
#include "previewhandlerimpl.h"
#include <kephal/screens.h>
#include <klocalizedstring.h>
#include <kwindowsystem.h>
#include <KDebug>
namespace KWin
{
namespace TabBox
{
PreviewClientImpl::PreviewClientImpl(WId id)
2011-01-30 14:34:42 +00:00
: m_id(id)
{
}
PreviewClientImpl::~PreviewClientImpl()
2011-01-30 14:34:42 +00:00
{
}
QString PreviewClientImpl::caption() const
2011-01-30 14:34:42 +00:00
{
KWindowInfo info = KWindowSystem::windowInfo(m_id, NET::WMVisibleName);
return info.visibleName();
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
QPixmap PreviewClientImpl::icon(const QSize& size) const
{
return KWindowSystem::icon(m_id, size.width(), size.height(), true);
}
bool PreviewClientImpl::isMinimized() const
2011-01-30 14:34:42 +00:00
{
KWindowInfo info = KWindowSystem::windowInfo(m_id, NET::WMState | NET::XAWMState);
return info.isMinimized();
2011-01-30 14:34:42 +00:00
}
int PreviewClientImpl::width() const
2011-01-30 14:34:42 +00:00
{
return 0; // only needed for the outline - not needed in preview
2011-01-30 14:34:42 +00:00
}
int PreviewClientImpl::height() const
2011-01-30 14:34:42 +00:00
{
return 0; // only needed for the outline - not needed in preview
2011-01-30 14:34:42 +00:00
}
WId PreviewClientImpl::window() const
2011-01-30 14:34:42 +00:00
{
return m_id;
2011-01-30 14:34:42 +00:00
}
int PreviewClientImpl::x() const
2011-01-30 14:34:42 +00:00
{
return 0; // only needed for the outline - not needed in preview
2011-01-30 14:34:42 +00:00
}
int PreviewClientImpl::y() const
2011-01-30 14:34:42 +00:00
{
return 0; // only needed for the outline - not needed in preview
2011-01-30 14:34:42 +00:00
}
/*******************************************************
* PreviewHandlerImpl
*******************************************************/
PreviewHandlerImpl::PreviewHandlerImpl()
2011-01-30 14:34:42 +00:00
{
QList< WId > windows = KWindowSystem::stackingOrder();
2011-01-30 14:34:42 +00:00
foreach (WId w, windows) {
m_stackingOrder.append(new PreviewClientImpl(w));
kDebug(1212) << "Window " << w;
}
2011-01-30 14:34:42 +00:00
}
PreviewHandlerImpl::~PreviewHandlerImpl()
2011-01-30 14:34:42 +00:00
{
qDeleteAll(m_stackingOrder.begin(), m_stackingOrder.end());
m_stackingOrder.clear();
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
TabBoxClient* PreviewHandlerImpl::clientToAddToList(TabBoxClient* client, int desktop, bool allDesktops) const
{
Q_UNUSED(desktop)
Q_UNUSED(allDesktops)
// don't include desktops and panels
2011-01-30 14:34:42 +00:00
KWindowInfo info = KWindowSystem::windowInfo(client->window(), NET::WMWindowType);
NET::WindowType wType = info.windowType(NET::NormalMask | NET::DesktopMask | NET::DockMask |
NET::ToolbarMask | NET::MenuMask | NET::DialogMask |
NET::OverrideMask | NET::TopMenuMask |
NET::UtilityMask | NET::SplashMask);
if (wType != NET::Normal && wType != NET::Override && wType != NET::Unknown &&
2011-01-30 14:34:42 +00:00
wType != NET::Dialog && wType != NET::Utility) {
return NULL;
}
2011-01-30 14:34:42 +00:00
return client;
}
TabBoxClientList PreviewHandlerImpl::stackingOrder() const
2011-01-30 14:34:42 +00:00
{
return m_stackingOrder;
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
int PreviewHandlerImpl::nextDesktopFocusChain(int desktop) const
{
int ret = desktop + 1;
2011-01-30 14:34:42 +00:00
if (ret > numberOfDesktops())
ret = 1;
return ret;
2011-01-30 14:34:42 +00:00
}
int PreviewHandlerImpl::numberOfDesktops() const
2011-01-30 14:34:42 +00:00
{
return KWindowSystem::numberOfDesktops();
2011-01-30 14:34:42 +00:00
}
int PreviewHandlerImpl::currentDesktop() const
2011-01-30 14:34:42 +00:00
{
return KWindowSystem::currentDesktop();
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
QString PreviewHandlerImpl::desktopName(int desktop) const
{
return KWindowSystem::desktopName(desktop);
}
2011-01-30 14:34:42 +00:00
QString PreviewHandlerImpl::desktopName(TabBoxClient* client) const
{
Q_UNUSED(client)
return desktopName(1);
}
2011-01-30 14:34:42 +00:00
TabBoxClient* PreviewHandlerImpl::nextClientFocusChain(TabBoxClient* client) const
{
if (m_stackingOrder.isEmpty())
return NULL;
2011-01-30 14:34:42 +00:00
int index = m_stackingOrder.indexOf(client);
index++;
2011-01-30 14:34:42 +00:00
if (index >= m_stackingOrder.count())
index = 0;
return m_stackingOrder[ index ];
2011-01-30 14:34:42 +00:00
}
KWin::TabBox::TabBoxClient* PreviewHandlerImpl::activeClient() const
2011-01-30 14:34:42 +00:00
{
if (m_stackingOrder.isEmpty())
return NULL;
return m_stackingOrder[ 0 ];
2011-01-30 14:34:42 +00:00
}
int PreviewHandlerImpl::activeScreen() const
2011-01-30 14:34:42 +00:00
{
return 0;
2011-01-30 14:34:42 +00:00
}
TabBoxClient* PreviewHandlerImpl::desktopClient() const
2011-01-30 14:34:42 +00:00
{
return 0;
2011-01-30 14:34:42 +00:00
}
} // namespace TabBox
} // namespace KWin