2007-03-08 16:54:50 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Philip Falkner <philip.falkner@gmail.com>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
2007-04-12 13:12:11 +00:00
|
|
|
#include <config.h>
|
2007-03-08 16:54:50 +00:00
|
|
|
|
2007-04-12 13:12:11 +00:00
|
|
|
#include "boxswitch.h"
|
2007-03-28 20:29:45 +00:00
|
|
|
|
2007-04-12 14:12:34 +00:00
|
|
|
#include <QCursor>
|
|
|
|
#include <QMouseEvent>
|
2007-03-08 16:54:50 +00:00
|
|
|
#include <QSize>
|
|
|
|
|
2007-04-12 14:12:34 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
2007-03-08 16:54:50 +00:00
|
|
|
#ifdef HAVE_OPENGL
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#endif
|
|
|
|
|
2007-04-05 12:07:35 +00:00
|
|
|
namespace KWin
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
|
2007-04-12 13:12:11 +00:00
|
|
|
KWIN_EFFECT( BoxSwitch, BoxSwitchEffect )
|
|
|
|
|
2007-03-08 16:54:50 +00:00
|
|
|
BoxSwitchEffect::BoxSwitchEffect()
|
|
|
|
: mActivated( 0 )
|
|
|
|
, mMode( 0 )
|
|
|
|
, painting_desktop( 0 )
|
|
|
|
{
|
|
|
|
frame_margin = 10;
|
|
|
|
highlight_margin = 5;
|
2007-03-08 22:12:41 +00:00
|
|
|
#ifdef HAVE_XRENDER
|
|
|
|
alphaFormat = XRenderFindStandardFormat( display(), PictStandardARGB32 );
|
|
|
|
#endif
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BoxSwitchEffect::~BoxSwitchEffect()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::prePaintScreen( int* mask, QRegion* region, int time )
|
|
|
|
{
|
|
|
|
effects->prePaintScreen( mask, region, time );
|
|
|
|
}
|
|
|
|
|
2007-03-25 10:48:07 +00:00
|
|
|
void BoxSwitchEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, int time )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
if( mActivated )
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
if( windows.contains( w ) && w != selected_window )
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
*mask |= PAINT_WINDOW_TRANSLUCENT;
|
|
|
|
*mask &= ~PAINT_WINDOW_OPAQUE;
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( painting_desktop )
|
|
|
|
{
|
|
|
|
if( w->isOnDesktop( painting_desktop ))
|
2007-04-12 14:12:34 +00:00
|
|
|
w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP );
|
2007-03-08 16:54:50 +00:00
|
|
|
else
|
2007-04-12 14:12:34 +00:00
|
|
|
w->disablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-03-25 10:48:07 +00:00
|
|
|
effects->prePaintWindow( w, mask, paint, clip, time );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
|
|
|
{
|
|
|
|
effects->paintScreen( mask, region, data );
|
|
|
|
if( mActivated )
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
paintFrame();
|
|
|
|
|
|
|
|
foreach( EffectWindow* w, windows.keys())
|
|
|
|
{
|
|
|
|
if( w == selected_window )
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
paintHighlight( windows[ w ]->area, w->caption());
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
paintWindowThumbnail( w );
|
2007-03-08 22:12:41 +00:00
|
|
|
paintWindowIcon( w );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !painting_desktop )
|
|
|
|
{
|
|
|
|
paintFrame();
|
|
|
|
|
2007-03-28 20:29:45 +00:00
|
|
|
foreach( painting_desktop, desktops.keys())
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
if( painting_desktop == selected_desktop )
|
|
|
|
{
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
paintHighlight( desktops[ painting_desktop ]->area,
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->desktopName( painting_desktop ));
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
paintDesktopThumbnail( painting_desktop );
|
|
|
|
}
|
|
|
|
painting_desktop = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
|
|
|
{
|
|
|
|
if( mActivated )
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
if( windows.contains( w ) && w != selected_window )
|
|
|
|
{
|
2007-03-28 20:29:45 +00:00
|
|
|
data.opacity *= 0.2;
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
effects->paintWindow( w, mask, region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::windowInputMouseEvent( Window w, QEvent* e )
|
|
|
|
{
|
|
|
|
assert( w == mInput );
|
|
|
|
if( e->type() != QEvent::MouseButtonPress )
|
|
|
|
return;
|
|
|
|
QPoint pos = static_cast< QMouseEvent* >( e )->pos();
|
|
|
|
pos += frame_area.topLeft();
|
|
|
|
|
|
|
|
// determine which item was clicked
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
foreach( EffectWindow* w, windows.keys())
|
|
|
|
{
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
if( windows[ w ]->clickable.contains( pos ))
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->setTabBoxWindow( w );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-28 20:29:45 +00:00
|
|
|
foreach( int i, desktops.keys())
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
if( desktops[ i ]->clickable.contains( pos ))
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->setTabBoxDesktop( i );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::windowDamaged( EffectWindow* w, const QRect& damage )
|
|
|
|
{
|
|
|
|
if( mActivated )
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
if( windows.contains( w ))
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( windows[ w ]->area );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( w->isOnAllDesktops())
|
|
|
|
{
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
foreach( ItemInfo* info, desktops )
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( info->area );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( desktops[ w->desktop() ]->area );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::windowGeometryShapeChanged( EffectWindow* w, const QRect& old )
|
|
|
|
{
|
|
|
|
if( mActivated )
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
if( windows.contains( w ) && w->size() != old.size())
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( windows[ w ]->area );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( w->isOnAllDesktops())
|
|
|
|
{
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
foreach( ItemInfo* info, desktops )
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( info->area );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( desktops[ w->desktop() ]->area );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::tabBoxAdded( int mode )
|
|
|
|
{
|
|
|
|
if( !mActivated )
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->currentTabBoxWindowList().count() > 0 )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
mMode = mode;
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->refTabBox();
|
2007-03-08 16:54:50 +00:00
|
|
|
setActive();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-03-28 20:29:45 +00:00
|
|
|
{ // DesktopMode
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->currentTabBoxDesktopList().count() > 0 )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
mMode = mode;
|
|
|
|
painting_desktop = 0;
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->refTabBox();
|
2007-03-08 16:54:50 +00:00
|
|
|
setActive();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::tabBoxClosed()
|
|
|
|
{
|
|
|
|
if( mActivated )
|
|
|
|
setInactive();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::tabBoxUpdated()
|
|
|
|
{
|
|
|
|
if( mActivated )
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
if( selected_window != NULL )
|
|
|
|
{
|
|
|
|
if( windows.contains( selected_window ))
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( windows.value( selected_window )->area );
|
|
|
|
selected_window->addRepaintFull();
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
2007-04-12 14:12:34 +00:00
|
|
|
selected_window = effects->currentTabBoxWindow();
|
2007-03-08 16:54:50 +00:00
|
|
|
if( windows.contains( selected_window ))
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( windows.value( selected_window )->area );
|
|
|
|
selected_window->addRepaintFull();
|
|
|
|
if( effects->currentTabBoxWindowList() == original_windows )
|
2007-03-08 16:54:50 +00:00
|
|
|
return;
|
2007-04-12 14:12:34 +00:00
|
|
|
original_windows = effects->currentTabBoxWindowList();
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
else
|
2007-03-28 20:29:45 +00:00
|
|
|
{ // DesktopMode
|
2007-03-08 16:54:50 +00:00
|
|
|
if( desktops.contains( selected_desktop ))
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( desktops.value( selected_desktop )->area );
|
|
|
|
selected_desktop = effects->currentTabBoxDesktop();
|
2007-03-08 16:54:50 +00:00
|
|
|
if( desktops.contains( selected_desktop ))
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( desktops.value( selected_desktop )->area );
|
|
|
|
if( effects->currentTabBoxDesktopList() == original_desktops )
|
2007-03-08 16:54:50 +00:00
|
|
|
return;
|
2007-04-12 14:12:34 +00:00
|
|
|
original_desktops = effects->currentTabBoxDesktopList();
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( frame_area );
|
2007-03-08 16:54:50 +00:00
|
|
|
calculateFrameSize();
|
|
|
|
calculateItemSizes();
|
|
|
|
moveResizeInputWindow( frame_area.x(), frame_area.y(), frame_area.width(), frame_area.height());
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( frame_area );
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::setActive()
|
|
|
|
{
|
|
|
|
mActivated = true;
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
original_windows = effects->currentTabBoxWindowList();
|
|
|
|
selected_window = effects->currentTabBoxWindow();
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
original_desktops = effects->currentTabBoxDesktopList();
|
|
|
|
selected_desktop = effects->currentTabBoxDesktop();
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
calculateFrameSize();
|
|
|
|
calculateItemSizes();
|
|
|
|
mInput = effects->createInputWindow( this, frame_area.x(), frame_area.y(),
|
|
|
|
frame_area.width(), frame_area.height(), Qt::ArrowCursor );
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( frame_area );
|
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
foreach( EffectWindow* w, windows.keys())
|
|
|
|
{
|
|
|
|
if( w != selected_window )
|
2007-04-12 14:12:34 +00:00
|
|
|
w->addRepaintFull();
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::setInactive()
|
|
|
|
{
|
|
|
|
mActivated = false;
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->unrefTabBox();
|
2007-03-08 16:54:50 +00:00
|
|
|
if( mInput != None )
|
|
|
|
{
|
|
|
|
effects->destroyInputWindow( mInput );
|
|
|
|
mInput = None;
|
|
|
|
}
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
foreach( EffectWindow* w, windows.keys())
|
|
|
|
{
|
|
|
|
if( w != selected_window )
|
2007-04-12 14:12:34 +00:00
|
|
|
w->addRepaintFull();
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
}
|
|
|
|
foreach( ItemInfo* i, windows )
|
|
|
|
{
|
|
|
|
#ifdef HAVE_XRENDER
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->compositingType() == XRenderCompositing )
|
2007-03-08 22:12:41 +00:00
|
|
|
{
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
if( i->iconPicture != None )
|
|
|
|
XRenderFreePicture( display(), i->iconPicture );
|
|
|
|
i->iconPicture = None;
|
2007-03-08 22:12:41 +00:00
|
|
|
}
|
|
|
|
#endif
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
delete i;
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
windows.clear();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // DesktopMode
|
|
|
|
foreach( ItemInfo* i, desktops )
|
|
|
|
delete i;
|
|
|
|
desktops.clear();
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->addRepaint( frame_area );
|
2007-03-08 16:54:50 +00:00
|
|
|
frame_area = QRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::moveResizeInputWindow( int x, int y, int width, int height )
|
|
|
|
{
|
|
|
|
XMoveWindow( display(), mInput, x, y );
|
|
|
|
XResizeWindow( display(), mInput, width, height );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::calculateFrameSize()
|
|
|
|
{
|
|
|
|
int itemcount;
|
|
|
|
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
2007-03-28 20:29:45 +00:00
|
|
|
itemcount = original_windows.count();
|
2007-03-08 16:54:50 +00:00
|
|
|
item_max_size.setWidth( 200 );
|
|
|
|
item_max_size.setHeight( 200 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-28 20:29:45 +00:00
|
|
|
itemcount = original_desktops.count();
|
2007-03-08 16:54:50 +00:00
|
|
|
item_max_size.setWidth( 200 );
|
|
|
|
item_max_size.setHeight( 200 );
|
|
|
|
}
|
|
|
|
// Shrink the size until all windows/desktops can fit onscreen
|
|
|
|
frame_area.setWidth( frame_margin * 2 + itemcount * item_max_size.width());
|
|
|
|
while( frame_area.width() > displayWidth())
|
|
|
|
{
|
|
|
|
item_max_size /= 2;
|
|
|
|
frame_area.setWidth( frame_margin * 2 + itemcount * item_max_size.width());
|
|
|
|
}
|
|
|
|
frame_area.setHeight( frame_margin * 2 + item_max_size.height() + 15 );
|
|
|
|
frame_area.moveTo( ( displayWidth() - frame_area.width()) / 2, ( displayHeight() - frame_area.height()) / 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::calculateItemSizes()
|
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
if( mMode == TabBoxWindowsMode )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
|
|
|
windows.clear();
|
2007-03-28 20:29:45 +00:00
|
|
|
for( int i = 0; i < original_windows.count(); i++ )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
2007-04-12 14:12:34 +00:00
|
|
|
EffectWindow* w = original_windows.at( i );
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
windows[ w ] = new ItemInfo();
|
2007-03-08 16:54:50 +00:00
|
|
|
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
windows[ w ]->area = QRect( frame_area.x() + frame_margin
|
2007-03-08 16:54:50 +00:00
|
|
|
+ i * item_max_size.width(),
|
|
|
|
frame_area.y() + frame_margin,
|
|
|
|
item_max_size.width(), item_max_size.height());
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
windows[ w ]->clickable = windows[ w ]->area;
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
desktops.clear();
|
2007-03-28 20:29:45 +00:00
|
|
|
for( int i = 0; i < original_desktops.count(); i++ )
|
2007-03-08 16:54:50 +00:00
|
|
|
{
|
2007-03-28 20:29:45 +00:00
|
|
|
int it = original_desktops.at( i );
|
|
|
|
desktops[ it ] = new ItemInfo();
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
|
2007-03-28 20:29:45 +00:00
|
|
|
desktops[ it ]->area = QRect( frame_area.x() + frame_margin
|
|
|
|
+ i * item_max_size.width(),
|
2007-03-08 16:54:50 +00:00
|
|
|
frame_area.y() + frame_margin,
|
|
|
|
item_max_size.width(), item_max_size.height());
|
2007-03-28 20:29:45 +00:00
|
|
|
desktops[ it ]->clickable = desktops[ it ]->area;
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::paintFrame()
|
|
|
|
{
|
2007-03-08 22:12:41 +00:00
|
|
|
double alpha = 0.75;
|
2007-03-08 16:54:50 +00:00
|
|
|
#ifdef HAVE_OPENGL
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->compositingType() == OpenGLCompositing )
|
2007-03-08 22:12:41 +00:00
|
|
|
{
|
|
|
|
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glColor4f( 0, 0, 0, alpha );
|
2007-04-21 16:02:19 +00:00
|
|
|
const float verts[ 4 * 2 ] =
|
2007-03-28 20:29:45 +00:00
|
|
|
{
|
|
|
|
frame_area.x(), frame_area.y(),
|
|
|
|
frame_area.x(), frame_area.y() + frame_area.height(),
|
|
|
|
frame_area.x() + frame_area.width(), frame_area.y() + frame_area.height(),
|
|
|
|
frame_area.x() + frame_area.width(), frame_area.y()
|
|
|
|
};
|
2007-04-21 16:02:19 +00:00
|
|
|
renderGLGeometry( verts, NULL, 4 );
|
2007-03-08 22:12:41 +00:00
|
|
|
glPopAttrib();
|
|
|
|
}
|
2007-03-08 16:54:50 +00:00
|
|
|
#endif
|
2007-03-08 22:12:41 +00:00
|
|
|
#ifdef HAVE_XRENDER
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->compositingType() == XRenderCompositing )
|
|
|
|
{
|
2007-03-08 22:12:41 +00:00
|
|
|
Pixmap pixmap = XCreatePixmap( display(), rootWindow(),
|
|
|
|
frame_area.width(), frame_area.height(), 32 );
|
|
|
|
Picture pic = XRenderCreatePicture( display(), pixmap, alphaFormat, 0, NULL );
|
|
|
|
XFreePixmap( display(), pixmap );
|
|
|
|
XRenderColor col;
|
|
|
|
col.alpha = int( alpha * 0xffff );
|
|
|
|
col.red = 0;
|
|
|
|
col.green = 0;
|
|
|
|
col.blue = 0;
|
|
|
|
XRenderFillRectangle( display(), PictOpSrc, pic, &col, 0, 0,
|
|
|
|
frame_area.width(), frame_area.height());
|
|
|
|
XRenderComposite( display(), alpha != 1.0 ? PictOpOver : PictOpSrc,
|
2007-04-12 14:12:34 +00:00
|
|
|
pic, None, effects->xrenderBufferPicture(),
|
2007-03-08 22:12:41 +00:00
|
|
|
0, 0, 0, 0, frame_area.x(), frame_area.y(), frame_area.width(), frame_area.height());
|
|
|
|
XRenderFreePicture( display(), pic );
|
|
|
|
}
|
2007-04-12 14:12:34 +00:00
|
|
|
#endif
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::paintHighlight( QRect area, QString text )
|
|
|
|
{
|
2007-03-08 22:12:41 +00:00
|
|
|
double alpha = 0.75;
|
2007-03-08 16:54:50 +00:00
|
|
|
#ifdef HAVE_OPENGL
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->compositingType() == OpenGLCompositing )
|
2007-03-08 22:12:41 +00:00
|
|
|
{
|
|
|
|
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glColor4f( 1, 1, 1, alpha );
|
2007-04-21 16:02:19 +00:00
|
|
|
const float verts[ 4 * 2 ] =
|
2007-03-28 20:29:45 +00:00
|
|
|
{
|
|
|
|
area.x(), area.y(),
|
|
|
|
area.x(), area.y() + area.height(),
|
|
|
|
area.x() + area.width(), area.y() + area.height(),
|
|
|
|
area.x() + area.width(), area.y()
|
|
|
|
};
|
2007-04-21 16:02:19 +00:00
|
|
|
renderGLGeometry( verts, NULL, 4 );
|
2007-03-08 22:12:41 +00:00
|
|
|
glPopAttrib();
|
|
|
|
}
|
2007-03-08 16:54:50 +00:00
|
|
|
#endif
|
2007-03-08 22:12:41 +00:00
|
|
|
#ifdef HAVE_XRENDER
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->compositingType() == XRenderCompositing )
|
|
|
|
{
|
2007-03-08 22:12:41 +00:00
|
|
|
Pixmap pixmap = XCreatePixmap( display(), rootWindow(),
|
|
|
|
area.width(), area.height(), 32 );
|
|
|
|
Picture pic = XRenderCreatePicture( display(), pixmap, alphaFormat, 0, NULL );
|
|
|
|
XFreePixmap( display(), pixmap );
|
|
|
|
XRenderColor col;
|
|
|
|
col.alpha = int( alpha * 0xffff );
|
|
|
|
col.red = int( alpha * 0xffff );
|
|
|
|
col.green = int( alpha * 0xffff );
|
|
|
|
col.blue = int( alpha * 0xffff );
|
|
|
|
XRenderFillRectangle( display(), PictOpSrc, pic, &col, 0, 0,
|
|
|
|
area.width(), area.height());
|
|
|
|
XRenderComposite( display(), alpha != 1.0 ? PictOpOver : PictOpSrc,
|
2007-04-12 14:12:34 +00:00
|
|
|
pic, None, effects->xrenderBufferPicture(),
|
2007-03-08 22:12:41 +00:00
|
|
|
0, 0, 0, 0, area.x(), area.y(), area.width(), area.height());
|
|
|
|
XRenderFreePicture( display(), pic );
|
|
|
|
}
|
2007-04-12 14:12:34 +00:00
|
|
|
#endif
|
2007-03-08 16:54:50 +00:00
|
|
|
// kDebug() << text << endl; // TODO draw this nicely on screen
|
|
|
|
}
|
|
|
|
|
2007-03-28 20:29:45 +00:00
|
|
|
void BoxSwitchEffect::paintWindowThumbnail( EffectWindow* w )
|
|
|
|
{
|
|
|
|
if( !windows.contains( w ))
|
|
|
|
return;
|
|
|
|
WindowPaintData data;
|
|
|
|
|
|
|
|
setPositionTransformations( data,
|
|
|
|
windows[ w ]->thumbnail, w,
|
|
|
|
windows[ w ]->area.adjusted( highlight_margin, highlight_margin, -highlight_margin, -highlight_margin ),
|
|
|
|
Qt::KeepAspectRatio );
|
|
|
|
|
|
|
|
effects->drawWindow( w,
|
2007-04-12 14:12:34 +00:00
|
|
|
PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSFORMED,
|
2007-03-28 20:29:45 +00:00
|
|
|
windows[ w ]->thumbnail, data );
|
|
|
|
}
|
|
|
|
|
2007-03-08 16:54:50 +00:00
|
|
|
void BoxSwitchEffect::paintDesktopThumbnail( int iDesktop )
|
|
|
|
{
|
|
|
|
if( !desktops.contains( iDesktop ))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ScreenPaintData data;
|
|
|
|
QRect region;
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
QRect r = desktops[ iDesktop ]->area.adjusted( highlight_margin, highlight_margin,
|
2007-03-08 16:54:50 +00:00
|
|
|
-highlight_margin, -highlight_margin );
|
|
|
|
QSize size = QSize( displayWidth(), displayHeight());
|
|
|
|
|
|
|
|
size.scale( r.size(), Qt::KeepAspectRatio );
|
|
|
|
data.xScale = size.width() / double( displayWidth());
|
|
|
|
data.yScale = size.height() / double( displayHeight());
|
|
|
|
int width = int( displayWidth() * data.xScale );
|
|
|
|
int height = int( displayHeight() * data.yScale );
|
|
|
|
int x = r.x() + ( r.width() - width ) / 2;
|
|
|
|
int y = r.y() + ( r.height() - height ) / 2;
|
|
|
|
region = QRect( x, y, width, height );
|
|
|
|
data.xTranslate = x;
|
|
|
|
data.yTranslate = y;
|
|
|
|
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->paintScreen( PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST,
|
2007-03-08 16:54:50 +00:00
|
|
|
region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxSwitchEffect::paintWindowIcon( EffectWindow* w )
|
|
|
|
{
|
|
|
|
if( !windows.contains( w ))
|
|
|
|
return;
|
2007-04-12 14:12:34 +00:00
|
|
|
if( windows[ w ]->icon.serialNumber() != w->icon().serialNumber())
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
{ // make sure windows[ w ]->icon is the right QPixmap, and rebind
|
2007-04-12 14:12:34 +00:00
|
|
|
windows[ w ]->icon = w->icon();
|
2007-03-08 16:54:50 +00:00
|
|
|
#ifdef HAVE_OPENGL
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->compositingType() == OpenGLCompositing )
|
2007-03-08 22:12:41 +00:00
|
|
|
{
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
windows[ w ]->iconTexture.load( windows[ w ]->icon );
|
|
|
|
windows[ w ]->iconTexture.setFilter( GL_LINEAR );
|
2007-03-08 22:12:41 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_XRENDER
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->compositingType() == XRenderCompositing )
|
|
|
|
{
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
if( windows[ w ]->iconPicture != None )
|
|
|
|
XRenderFreePicture( display(), windows[ w ]->iconPicture );
|
|
|
|
windows[ w ]->iconPicture = XRenderCreatePicture( display(),
|
|
|
|
windows[ w ]->icon.handle(), alphaFormat, 0, NULL );
|
2007-03-08 22:12:41 +00:00
|
|
|
}
|
2007-04-12 14:12:34 +00:00
|
|
|
#endif
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
int width = windows[ w ]->icon.width();
|
|
|
|
int height = windows[ w ]->icon.height();
|
|
|
|
int x = windows[ w ]->area.x() + windows[ w ]->area.width() - width - highlight_margin;
|
|
|
|
int y = windows[ w ]->area.y() + windows[ w ]->area.height() - height - highlight_margin;
|
2007-03-08 16:54:50 +00:00
|
|
|
#ifdef HAVE_OPENGL
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->compositingType() == OpenGLCompositing )
|
2007-03-08 22:12:41 +00:00
|
|
|
{
|
2007-03-28 20:29:45 +00:00
|
|
|
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
glEnable( GL_BLEND );
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
windows[ w ]->iconTexture.bind();
|
2007-04-21 16:02:19 +00:00
|
|
|
const float verts[ 4 * 2 ] =
|
2007-03-28 20:29:45 +00:00
|
|
|
{
|
|
|
|
x, y,
|
|
|
|
x, y + height,
|
|
|
|
x + width, y + height,
|
|
|
|
x + width, y
|
|
|
|
};
|
2007-04-21 16:02:19 +00:00
|
|
|
const float texcoords[ 4 * 2 ] =
|
2007-03-28 20:29:45 +00:00
|
|
|
{
|
|
|
|
0, 1,
|
|
|
|
0, 0,
|
|
|
|
1, 0,
|
|
|
|
1, 1
|
|
|
|
};
|
2007-04-21 16:02:19 +00:00
|
|
|
renderGLGeometry( verts, texcoords, 4 );
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
windows[ w ]->iconTexture.unbind();
|
|
|
|
glPopAttrib();
|
2007-03-08 22:12:41 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_XRENDER
|
2007-04-12 14:12:34 +00:00
|
|
|
if( effects->compositingType() == XRenderCompositing )
|
|
|
|
{
|
2007-03-08 22:12:41 +00:00
|
|
|
XRenderComposite( display(),
|
Add GLTexture class. This is a convenient wrapper around managing an OpenGL texture, as well as loading an image into it. Includes support for loading from QImage, QPixmap, and a file. Defaults to a GL_TEXTURE_2D target, and will scale image if necessary.
Also add SceneOpenGL::Texture class, based on GLTexture. Optimised for SceneOpenGL::Window, this adds support for loading from an X Pixmap, as well as taking advantage of texture_from_pixmap/shm when available. Automatically detects what texture target should be used, so be sure to enableUnnormalizedTexCoords() before painting.
Make SceneOpenGL::Window, BoxSwitchEffect, and ExplosionEffect use the new classes.
svn path=/branches/work/kwin_composite/; revision=645125
2007-03-21 18:14:09 +00:00
|
|
|
windows[ w ]->icon.depth() == 32 ? PictOpOver : PictOpSrc,
|
|
|
|
windows[ w ]->iconPicture, None,
|
2007-04-12 14:12:34 +00:00
|
|
|
effects->xrenderBufferPicture(),
|
2007-03-08 22:12:41 +00:00
|
|
|
0, 0, 0, 0, x, y, width, height );
|
|
|
|
}
|
2007-04-12 14:12:34 +00:00
|
|
|
#endif
|
2007-03-08 16:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|