2007-04-29 17:35:43 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 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 "demo_showpicture.h"
|
|
|
|
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
#include <qimage.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KWIN_EFFECT(demo_showpicture, ShowPictureEffect)
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
ShowPictureEffect::ShowPictureEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
: init(true)
|
|
|
|
, picture(NULL)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
ShowPictureEffect::~ShowPictureEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
delete picture;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void ShowPictureEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
|
|
|
{
|
|
|
|
effects->paintScreen(mask, region, data);
|
|
|
|
if (init) {
|
2007-04-29 17:35:43 +00:00
|
|
|
loadPicture();
|
|
|
|
init = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (picture && region.intersects(pictureRect)) {
|
|
|
|
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
|
2007-04-29 17:35:43 +00:00
|
|
|
picture->bind();
|
2011-01-30 14:34:42 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
picture->render(region, pictureRect);
|
2007-04-29 17:35:43 +00:00
|
|
|
picture->unbind();
|
|
|
|
glPopAttrib();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void ShowPictureEffect::loadPicture()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
QString file = KGlobal::dirs()->findResource("appdata", "showpicture.png");
|
|
|
|
if (file.isEmpty())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
QImage im(file);
|
|
|
|
QRect area = effects->clientArea(PlacementArea, effects->activeScreen(), effects->currentDesktop());
|
|
|
|
picture = new GLTexture(im);
|
|
|
|
pictureRect = QRect(area.x() + (area.width() - im.width()) / 2,
|
|
|
|
area.y() + (area.height() - im.height()) / 2, im.width(), im.height());
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
} // namespace
|