A silly effect that just shows a picture. Using

picture of Konqi is recommended :).


svn path=/branches/work/kwin_composite/; revision=654703
remotes/origin/Plasma/5.0
Luboš Luňák 19 years ago
parent 408cb3b28f
commit 743c5da956
  1. 2
      effects/CMakeLists.txt
  2. 4
      effects/demo_shiftworkspaceup.h
  3. 92
      effects/demo_showpicture.cpp
  4. 5
      effects/demo_showpicture.desktop
  5. 36
      effects/demo_showpicture.h
  6. 4
      effects/demo_taskbarthumbnail.h

@ -31,6 +31,7 @@ SET(kwin4_effect_builtins_sources
SET(kwin4_effect_tests_sources
demo_shiftworkspaceup.cpp
demo_showpicture.cpp
demo_taskbarthumbnail.cpp
howto.cpp
test_input.cpp
@ -89,6 +90,7 @@ install( FILES
thumbnailaside.desktop
zoom.desktop
demo_shiftworkspaceup.desktop
demo_showpicture.desktop
demo_taskbarthumbnail.desktop
test_input.desktop
test_thumbnail.desktop

@ -8,8 +8,8 @@ You can Freely distribute this program under the GNU General Public
License. See the file "COPYING" for the exact licensing terms.
******************************************************************/
#ifndef KWIN_TEST_SHIFTWORKSPACEUP_H
#define KWIN_TEST_SHIFTWORKSPACEUP_H
#ifndef KWIN_DEMO_SHIFTWORKSPACEUP_H
#define KWIN_DEMO_SHIFTWORKSPACEUP_H
#include <qtimer.h>

@ -0,0 +1,92 @@
/*****************************************************************
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
{
KWIN_EFFECT( Demo_ShowPicture, ShowPictureEffect )
ShowPictureEffect::ShowPictureEffect()
: init( true )
, picture( NULL )
{
}
ShowPictureEffect::~ShowPictureEffect()
{
delete picture;
}
void ShowPictureEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
{
effects->paintScreen( mask, region, data );
#ifdef HAVE_OPENGL
if( init )
{
loadPicture();
init = false;
}
if( picture && region.intersects( pictureRect ))
{
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
picture->bind();
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glEnableClientState( GL_VERTEX_ARRAY );
int x = pictureRect.x();
int y = pictureRect.y();
int width = pictureRect.width();
int height = pictureRect.height();
int verts[ 4 * 2 ] =
{
x, y,
x, y + height,
x + width, y + height,
x + width, y
};
glVertexPointer( 2, GL_INT, 0, verts );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
int texcoords[ 4 * 2 ] =
{
0, 1,
0, 0,
1, 0,
1, 1
};
glTexCoordPointer( 2, GL_INT, 0, texcoords );
glDrawArrays( GL_QUADS, 0, 4 );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
picture->unbind();
glPopAttrib();
}
#endif
}
void ShowPictureEffect::loadPicture()
{
#ifdef HAVE_OPENGL
QString file = KGlobal::dirs()->findResource( "appdata", "showpicture.png" );
if( file.isEmpty())
return;
QImage im( file );
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), 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());
#endif
}
} // namespace

@ -0,0 +1,5 @@
[Desktop Entry]
Encoding=UTF-8
Name=Demo_ShowPicture
X-KDE-Library=kwin4_effect_tests

@ -0,0 +1,36 @@
/*****************************************************************
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.
******************************************************************/
#ifndef KWIN_DEMO_SHOWPICTURE_H
#define KWIN_DEMO_SHOWPICTURE_H
#include <kwineffects.h>
#include <kwinglutils.h>
namespace KWin
{
class ShowPictureEffect
: public Effect
{
public:
ShowPictureEffect();
virtual ~ShowPictureEffect();
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
private:
void loadPicture();
bool init;
GLTexture* picture;
QRect pictureRect;
};
} // namespace
#endif

@ -8,8 +8,8 @@ You can Freely distribute this program under the GNU General Public
License. See the file "COPYING" for the exact licensing terms.
******************************************************************/
#ifndef KWIN_TASKBARTHUMBNAIL_H
#define KWIN_TASKBARTHUMBNAIL_H
#ifndef KWIN_DEMO_TASKBARTHUMBNAIL_H
#define KWIN_DEMO_TASKBARTHUMBNAIL_H
// Include with base class for effects.
#include <kwineffects.h>

Loading…
Cancel
Save