d547cf8cd4
svn path=/branches/work/kwin_composite/; revision=595639
104 lines
2.4 KiB
C++
104 lines
2.4 KiB
C++
/*****************************************************************
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
******************************************************************/
|
|
|
|
#include "scene_basic.h"
|
|
#include "client.h"
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
namespace KWinInternal
|
|
{
|
|
|
|
//****************************************
|
|
// Scene
|
|
//****************************************
|
|
|
|
Scene* scene;
|
|
|
|
Scene::Scene( Workspace* ws )
|
|
: wspace( ws )
|
|
{
|
|
}
|
|
|
|
Scene::~Scene()
|
|
{
|
|
}
|
|
|
|
void Scene::windowGeometryShapeChanged( Toplevel* )
|
|
{
|
|
}
|
|
|
|
void Scene::windowOpacityChanged( Toplevel* )
|
|
{
|
|
}
|
|
|
|
void Scene::windowAdded( Toplevel* )
|
|
{
|
|
}
|
|
|
|
void Scene::windowDeleted( Toplevel* )
|
|
{
|
|
}
|
|
|
|
Scene::Window::Window( Toplevel * c )
|
|
: toplevel( c )
|
|
, shape_valid( false )
|
|
{
|
|
}
|
|
|
|
void Scene::Window::discardShape()
|
|
{
|
|
shape_valid = false;
|
|
}
|
|
|
|
QRegion Scene::Window::shape() const
|
|
{
|
|
if( !shape_valid )
|
|
{
|
|
Client* c = dynamic_cast< Client* >( toplevel );
|
|
if( toplevel->shape() || ( c != NULL && !c->mask().isEmpty()))
|
|
{
|
|
int count, order;
|
|
XRectangle* rects = XShapeGetRectangles( display(), toplevel->handle(),
|
|
ShapeBounding, &count, &order );
|
|
if(rects)
|
|
{
|
|
shape_region = QRegion();
|
|
for( int i = 0;
|
|
i < count;
|
|
++i )
|
|
shape_region += QRegion( rects[ i ].x, rects[ i ].y,
|
|
rects[ i ].width, rects[ i ].height );
|
|
XFree(rects);
|
|
}
|
|
else
|
|
shape_region = QRegion( 0, 0, width(), height());
|
|
}
|
|
else
|
|
shape_region = QRegion( 0, 0, width(), height());
|
|
shape_valid = true;
|
|
}
|
|
return shape_region;
|
|
}
|
|
|
|
bool Scene::Window::isVisible() const
|
|
{
|
|
// TODO mapping state?
|
|
return !toplevel->geometry()
|
|
.intersect( QRect( 0, 0, displayWidth(), displayHeight()))
|
|
.isEmpty();
|
|
}
|
|
|
|
bool Scene::Window::isOpaque() const
|
|
{
|
|
return toplevel->opacity() == 1.0 && !toplevel->hasAlpha();
|
|
}
|
|
|
|
} // namespace
|