2006-07-04 20:51:01 +00:00
|
|
|
/*****************************************************************
|
|
|
|
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 "effects.h"
|
|
|
|
|
2006-07-06 13:17:44 +00:00
|
|
|
#include "toplevel.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "scene.h"
|
2007-02-04 22:19:17 +00:00
|
|
|
#include "options.h"
|
2006-07-06 13:17:44 +00:00
|
|
|
|
2007-03-08 16:52:09 +00:00
|
|
|
#include "effects/boxswitch.h"
|
2007-02-01 17:20:48 +00:00
|
|
|
#include "effects/desktopchangeslide.h"
|
2006-11-08 19:10:07 +00:00
|
|
|
#include "effects/dialogparent.h"
|
2007-03-14 18:21:11 +00:00
|
|
|
#include "effects/drunken.h"
|
2007-03-16 13:02:47 +00:00
|
|
|
#include "effects/explosioneffect.h"
|
2007-02-11 17:41:21 +00:00
|
|
|
#include "effects/fade.h"
|
2006-10-30 22:49:59 +00:00
|
|
|
#include "effects/howto.h"
|
2006-10-29 19:08:09 +00:00
|
|
|
#include "effects/maketransparent.h"
|
2007-01-25 11:48:07 +00:00
|
|
|
#include "effects/minimizeanimation.h"
|
2007-01-14 17:05:25 +00:00
|
|
|
#include "effects/presentwindows.h"
|
2006-10-29 19:08:09 +00:00
|
|
|
#include "effects/scalein.h"
|
|
|
|
#include "effects/shakymove.h"
|
|
|
|
#include "effects/shiftworkspaceup.h"
|
2006-11-16 22:46:14 +00:00
|
|
|
#include "effects/showfps.h"
|
2007-02-23 16:20:22 +00:00
|
|
|
#ifdef HAVE_CAPTURY
|
|
|
|
#include "effects/videorecord.h"
|
|
|
|
#endif
|
2007-02-13 23:28:36 +00:00
|
|
|
#ifdef HAVE_OPENGL
|
2007-03-21 17:35:48 +00:00
|
|
|
#include "effects/flame.h"
|
2007-03-13 13:42:01 +00:00
|
|
|
#include "effects/fallapart.h"
|
2007-01-24 21:46:43 +00:00
|
|
|
#include "effects/wavywindows.h"
|
2007-02-13 23:28:36 +00:00
|
|
|
#endif
|
2006-12-03 13:36:40 +00:00
|
|
|
#include "effects/zoom.h"
|
2006-10-29 19:08:09 +00:00
|
|
|
|
2007-01-05 16:45:56 +00:00
|
|
|
#include "effects/test_input.h"
|
2007-03-07 17:50:33 +00:00
|
|
|
#include "effects/test_thumbnail.h"
|
2007-01-05 16:45:56 +00:00
|
|
|
|
2006-07-04 20:51:01 +00:00
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// Effect
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
Effect::~Effect()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void Effect::windowUserMovedResized( EffectWindow* , bool, bool )
|
2006-07-04 20:51:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-02-12 23:14:50 +00:00
|
|
|
void Effect::windowOpacityChanged( EffectWindow*, double )
|
2007-02-11 17:38:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void Effect::windowAdded( EffectWindow* )
|
2006-07-04 20:51:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void Effect::windowClosed( EffectWindow* )
|
2007-01-15 18:03:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void Effect::windowDeleted( EffectWindow* )
|
2006-07-04 20:51:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void Effect::windowActivated( EffectWindow* )
|
2006-10-30 22:49:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void Effect::windowMinimized( EffectWindow* )
|
2007-01-12 23:23:41 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void Effect::windowUnminimized( EffectWindow* )
|
2007-01-12 23:23:41 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-05 16:45:56 +00:00
|
|
|
void Effect::windowInputMouseEvent( Window, QEvent* )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-02-01 17:20:48 +00:00
|
|
|
void Effect::desktopChanged( int )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-03-07 17:50:33 +00:00
|
|
|
void Effect::windowDamaged( EffectWindow*, const QRect& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Effect::windowGeometryShapeChanged( EffectWindow*, const QRect& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-03-08 16:49:44 +00:00
|
|
|
void Effect::tabBoxAdded( int )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Effect::tabBoxClosed()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Effect::tabBoxUpdated()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-10-24 19:17:48 +00:00
|
|
|
void Effect::prePaintScreen( int* mask, QRegion* region, int time )
|
2006-07-04 20:51:01 +00:00
|
|
|
{
|
2006-10-29 19:06:32 +00:00
|
|
|
effects->prePaintScreen( mask, region, time );
|
2006-07-04 20:51:01 +00:00
|
|
|
}
|
|
|
|
|
2006-10-16 10:12:48 +00:00
|
|
|
void Effect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
|
|
|
{
|
2006-10-29 19:06:32 +00:00
|
|
|
effects->paintScreen( mask, region, data );
|
2006-10-16 10:12:48 +00:00
|
|
|
}
|
2006-10-29 19:07:10 +00:00
|
|
|
|
|
|
|
void Effect::postPaintScreen()
|
|
|
|
{
|
|
|
|
effects->postPaintScreen();
|
|
|
|
}
|
2006-10-16 10:12:48 +00:00
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void Effect::prePaintWindow( EffectWindow* w, int* mask, QRegion* region, int time )
|
2006-10-16 18:46:07 +00:00
|
|
|
{
|
2006-10-29 19:06:32 +00:00
|
|
|
effects->prePaintWindow( w, mask, region, time );
|
2006-10-16 18:46:07 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void Effect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
2006-10-16 18:46:07 +00:00
|
|
|
{
|
2006-10-29 19:06:32 +00:00
|
|
|
effects->paintWindow( w, mask, region, data );
|
2006-10-16 18:46:07 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void Effect::postPaintWindow( EffectWindow* w )
|
2006-10-29 19:07:10 +00:00
|
|
|
{
|
|
|
|
effects->postPaintWindow( w );
|
|
|
|
}
|
|
|
|
|
2007-03-07 17:50:33 +00:00
|
|
|
void Effect::drawWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
|
|
|
{
|
|
|
|
effects->drawWindow( w, mask, region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Effect::setPositionTransformations( WindowPaintData& data, QRect& region, EffectWindow* w,
|
|
|
|
const QRect& r, Qt::AspectRatioMode aspect )
|
|
|
|
{
|
|
|
|
QSize size = w->size();
|
|
|
|
size.scale( r.size(), aspect );
|
|
|
|
data.xScale = size.width() / double( w->width());
|
|
|
|
data.yScale = size.height() / double( w->height());
|
|
|
|
int width = int( w->width() * data.xScale );
|
|
|
|
int height = int( w->height() * 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 - w->x();
|
|
|
|
data.yTranslate = y - w->y();
|
|
|
|
}
|
|
|
|
|
2006-07-06 13:17:44 +00:00
|
|
|
//****************************************
|
|
|
|
// EffectsHandler
|
|
|
|
//****************************************
|
|
|
|
|
2007-02-04 22:19:17 +00:00
|
|
|
EffectsHandler::EffectsHandler()
|
2007-03-07 17:50:33 +00:00
|
|
|
: current_paint_screen( 0 )
|
|
|
|
, current_paint_window( 0 )
|
|
|
|
, current_draw_window( 0 )
|
2006-07-06 09:55:10 +00:00
|
|
|
{
|
2006-07-10 18:34:57 +00:00
|
|
|
if( !compositing())
|
|
|
|
return;
|
2007-01-05 16:45:56 +00:00
|
|
|
KWinInternal::effects = this;
|
|
|
|
|
2007-02-23 16:20:22 +00:00
|
|
|
#ifdef HAVE_CAPTURY
|
|
|
|
registerEffect("VideoRecord", new GenericEffectFactory<VideoRecordEffect>);
|
|
|
|
#endif
|
2007-02-04 22:19:17 +00:00
|
|
|
registerEffect("ShowFps", new GenericEffectFactory<ShowFpsEffect>);
|
|
|
|
registerEffect("Zoom", new GenericEffectFactory<ZoomEffect>);
|
|
|
|
registerEffect("PresentWindows", new GenericEffectFactory<PresentWindowsEffect>);
|
2007-02-13 23:28:36 +00:00
|
|
|
#ifdef HAVE_OPENGL
|
2007-02-04 22:19:17 +00:00
|
|
|
registerEffect("WavyWindows", new GenericEffectFactory<WavyWindowsEffect>);
|
2007-03-16 13:02:47 +00:00
|
|
|
registerEffect("Explosion", new GenericEffectFactory<ExplosionEffect>);
|
2007-02-13 23:28:36 +00:00
|
|
|
#endif
|
2007-02-04 22:19:17 +00:00
|
|
|
registerEffect("MinimizeAnimation", new GenericEffectFactory<MinimizeAnimationEffect>);
|
|
|
|
registerEffect("Howto", new GenericEffectFactory<HowtoEffect>);
|
|
|
|
registerEffect("MakeTransparent", new GenericEffectFactory<MakeTransparentEffect>);
|
|
|
|
registerEffect("ShakyMove", new GenericEffectFactory<ShakyMoveEffect>);
|
|
|
|
registerEffect("ShiftWorkspaceUp", new GenericEffectFactory<ShiftWorkspaceUpEffect>);
|
2007-02-11 17:41:21 +00:00
|
|
|
registerEffect("Fade", new GenericEffectFactory<FadeEffect>);
|
2007-02-04 22:19:17 +00:00
|
|
|
registerEffect("ScaleIn", new GenericEffectFactory<ScaleInEffect>);
|
2007-03-13 13:42:01 +00:00
|
|
|
registerEffect("FallApart", new GenericEffectFactory<FallApartEffect>);
|
2007-03-21 17:35:48 +00:00
|
|
|
registerEffect("Flame", new GenericEffectFactory<FlameEffect>);
|
2007-02-04 22:19:17 +00:00
|
|
|
registerEffect("DialogParent", new GenericEffectFactory<DialogParentEffect>);
|
2007-02-07 19:21:33 +00:00
|
|
|
registerEffect("DesktopChangeSlide", new GenericEffectFactory<DesktopChangeSlideEffect>);
|
2007-03-08 16:52:09 +00:00
|
|
|
registerEffect("BoxSwitch", new GenericEffectFactory<BoxSwitchEffect>);
|
2007-03-14 18:21:11 +00:00
|
|
|
registerEffect("Drunken", new GenericEffectFactory<DrunkenEffect>);
|
2007-03-07 17:50:33 +00:00
|
|
|
|
2007-02-04 22:19:17 +00:00
|
|
|
registerEffect("TestInput", new GenericEffectFactory<TestInputEffect>);
|
2007-03-07 17:50:33 +00:00
|
|
|
registerEffect("TestThumbnail", new GenericEffectFactory<TestThumbnailEffect>);
|
2007-02-04 22:19:17 +00:00
|
|
|
|
|
|
|
QStringList::const_iterator effectsIterator;
|
|
|
|
for( effectsIterator = options->defaultEffects.constBegin();
|
|
|
|
effectsIterator != options->defaultEffects.constEnd();
|
|
|
|
++effectsIterator)
|
|
|
|
{
|
|
|
|
loadEffect(*effectsIterator);
|
|
|
|
}
|
2006-07-06 09:55:10 +00:00
|
|
|
}
|
2006-10-21 18:07:00 +00:00
|
|
|
|
2006-07-10 18:34:57 +00:00
|
|
|
EffectsHandler::~EffectsHandler()
|
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
delete ep.second;
|
|
|
|
foreach( EffectFactory* ef, effect_factories )
|
|
|
|
delete ef;
|
2007-01-05 16:45:56 +00:00
|
|
|
foreach( InputWindowPair pos, input_windows )
|
|
|
|
XDestroyWindow( display(), pos.second );
|
2006-07-10 18:34:57 +00:00
|
|
|
}
|
2006-07-06 09:55:10 +00:00
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::windowUserMovedResized( EffectWindow* c, bool first, bool last )
|
2006-07-04 20:51:01 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowUserMovedResized( c, first, last );
|
2006-07-04 20:51:01 +00:00
|
|
|
}
|
|
|
|
|
2007-02-12 23:14:50 +00:00
|
|
|
void EffectsHandler::windowOpacityChanged( EffectWindow* c, double old_opacity )
|
2007-02-11 17:38:56 +00:00
|
|
|
{
|
2007-02-12 23:14:50 +00:00
|
|
|
if( c->window()->opacity() == old_opacity )
|
|
|
|
return;
|
2007-02-11 17:38:56 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
2007-02-12 23:14:50 +00:00
|
|
|
ep.second->windowOpacityChanged( c, old_opacity );
|
2007-02-11 17:38:56 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::windowAdded( EffectWindow* c )
|
2006-07-04 20:51:01 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowAdded( c );
|
2006-07-04 20:51:01 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::windowDeleted( EffectWindow* c )
|
2006-07-04 20:51:01 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowDeleted( c );
|
2006-07-04 20:51:01 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::windowClosed( EffectWindow* c )
|
2007-01-15 18:03:04 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowClosed( c );
|
2007-01-15 18:03:04 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::windowActivated( EffectWindow* c )
|
2006-10-30 22:49:59 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowActivated( c );
|
2006-10-30 22:49:59 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::windowMinimized( EffectWindow* c )
|
2007-01-12 23:23:41 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowMinimized( c );
|
2007-01-12 23:23:41 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::windowUnminimized( EffectWindow* c )
|
2007-01-12 23:23:41 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowUnminimized( c );
|
2007-01-12 23:23:41 +00:00
|
|
|
}
|
|
|
|
|
2007-02-01 17:20:48 +00:00
|
|
|
void EffectsHandler::desktopChanged( int old )
|
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->desktopChanged( old );
|
2007-02-01 17:20:48 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 17:50:33 +00:00
|
|
|
void EffectsHandler::windowDamaged( EffectWindow* w, const QRect& r )
|
|
|
|
{
|
2007-03-08 16:49:44 +00:00
|
|
|
if( w == NULL )
|
|
|
|
return;
|
2007-03-07 17:50:33 +00:00
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowDamaged( w, r );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandler::windowGeometryShapeChanged( EffectWindow* w, const QRect& old )
|
|
|
|
{
|
|
|
|
if( w == NULL ) // during late cleanup effectWindow() may be already NULL
|
|
|
|
return; // in some functions that may still call this
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowGeometryShapeChanged( w, old );
|
|
|
|
}
|
|
|
|
|
2007-03-08 16:49:44 +00:00
|
|
|
void EffectsHandler::tabBoxAdded( int mode )
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->tabBoxAdded( mode );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandler::tabBoxClosed()
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->tabBoxClosed();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandler::tabBoxUpdated()
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->tabBoxUpdated();
|
|
|
|
}
|
|
|
|
|
2006-10-29 19:06:32 +00:00
|
|
|
// start another painting pass
|
|
|
|
void EffectsHandler::startPaint()
|
2006-10-16 10:12:48 +00:00
|
|
|
{
|
2006-10-16 18:46:07 +00:00
|
|
|
assert( current_paint_screen == 0 );
|
|
|
|
assert( current_paint_window == 0 );
|
2007-03-07 17:50:33 +00:00
|
|
|
assert( current_draw_window == 0 );
|
2006-10-16 18:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// the idea is that effects call this function again which calls the next one
|
2006-10-29 19:06:32 +00:00
|
|
|
void EffectsHandler::prePaintScreen( int* mask, QRegion* region, int time )
|
2006-10-16 18:46:07 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
if( current_paint_screen < loaded_effects.size())
|
2006-10-29 19:06:32 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
loaded_effects[current_paint_screen++].second->prePaintScreen( mask, region, time );
|
2006-10-29 19:06:32 +00:00
|
|
|
--current_paint_screen;
|
|
|
|
}
|
|
|
|
// no special final code
|
2006-10-16 10:12:48 +00:00
|
|
|
}
|
|
|
|
|
2006-10-29 19:06:32 +00:00
|
|
|
void EffectsHandler::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
2006-07-04 20:51:01 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
if( current_paint_screen < loaded_effects.size())
|
2006-10-29 19:06:32 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
loaded_effects[current_paint_screen++].second->paintScreen( mask, region, data );
|
2006-10-29 19:06:32 +00:00
|
|
|
--current_paint_screen;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scene->finalPaintScreen( mask, region, data );
|
2006-07-04 20:51:01 +00:00
|
|
|
}
|
|
|
|
|
2006-10-29 19:07:10 +00:00
|
|
|
void EffectsHandler::postPaintScreen()
|
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
if( current_paint_screen < loaded_effects.size())
|
2006-10-29 19:07:10 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
loaded_effects[current_paint_screen++].second->postPaintScreen();
|
2006-10-29 19:07:10 +00:00
|
|
|
--current_paint_screen;
|
|
|
|
}
|
|
|
|
// no special final code
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::prePaintWindow( EffectWindow* w, int* mask, QRegion* region, int time )
|
2006-10-16 18:46:07 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
if( current_paint_window < loaded_effects.size())
|
2006-10-29 19:06:32 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
loaded_effects[current_paint_window++].second->prePaintWindow( w, mask, region, time );
|
2006-10-29 19:06:32 +00:00
|
|
|
--current_paint_window;
|
|
|
|
}
|
|
|
|
// no special final code
|
2006-10-16 18:46:07 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
2006-10-16 18:46:07 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
if( current_paint_window < loaded_effects.size())
|
2006-10-29 19:06:32 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
loaded_effects[current_paint_window++].second->paintWindow( w, mask, region, data );
|
2006-10-29 19:06:32 +00:00
|
|
|
--current_paint_window;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scene->finalPaintWindow( w, mask, region, data );
|
2006-10-16 18:46:07 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::postPaintWindow( EffectWindow* w )
|
2006-10-29 19:07:10 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
if( current_paint_window < loaded_effects.size())
|
2006-10-29 19:07:10 +00:00
|
|
|
{
|
2007-02-04 22:19:17 +00:00
|
|
|
loaded_effects[current_paint_window++].second->postPaintWindow( w );
|
2006-10-29 19:07:10 +00:00
|
|
|
--current_paint_window;
|
|
|
|
}
|
|
|
|
// no special final code
|
|
|
|
}
|
|
|
|
|
2007-03-07 17:50:33 +00:00
|
|
|
void EffectsHandler::drawWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
|
|
|
{
|
|
|
|
if( current_draw_window < loaded_effects.size())
|
|
|
|
{
|
|
|
|
loaded_effects[current_draw_window++].second->drawWindow( w, mask, region, data );
|
|
|
|
--current_draw_window;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scene->finalDrawWindow( w, mask, region, data );
|
|
|
|
}
|
|
|
|
|
2007-01-05 16:45:56 +00:00
|
|
|
Window EffectsHandler::createInputWindow( Effect* e, int x, int y, int w, int h, const QCursor& cursor )
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attrs;
|
|
|
|
attrs.override_redirect = True;
|
|
|
|
Window win = XCreateWindow( display(), rootWindow(), x, y, w, h, 0, 0, InputOnly, CopyFromParent,
|
|
|
|
CWOverrideRedirect, &attrs );
|
|
|
|
// TODO keeping on top?
|
|
|
|
// TODO enter/leave notify?
|
|
|
|
XSelectInput( display(), win, ButtonPressMask | ButtonReleaseMask | PointerMotionMask );
|
|
|
|
XDefineCursor( display(), win, cursor.handle());
|
|
|
|
XMapWindow( display(), win );
|
|
|
|
input_windows.append( qMakePair( e, win ));
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
Window EffectsHandler::createInputWindow( Effect* e, const QRect& r, const QCursor& cursor )
|
|
|
|
{
|
|
|
|
return createInputWindow( e, r.x(), r.y(), r.width(), r.height(), cursor );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandler::destroyInputWindow( Window w )
|
|
|
|
{
|
|
|
|
foreach( InputWindowPair pos, input_windows )
|
|
|
|
{
|
|
|
|
if( pos.second == w )
|
|
|
|
{
|
|
|
|
input_windows.removeAll( pos );
|
|
|
|
XDestroyWindow( display(), w );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandler::checkInputWindowEvent( XEvent* e )
|
|
|
|
{
|
|
|
|
if( e->type != ButtonPress && e->type != ButtonRelease && e->type != MotionNotify )
|
|
|
|
return false;
|
|
|
|
foreach( InputWindowPair pos, input_windows )
|
|
|
|
{
|
|
|
|
if( pos.second == e->xany.window )
|
|
|
|
{
|
|
|
|
switch( e->type )
|
|
|
|
{
|
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
|
|
|
{
|
|
|
|
XButtonEvent* e2 = &e->xbutton;
|
|
|
|
QMouseEvent ev( e->type == ButtonPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease,
|
|
|
|
QPoint( e2->x, e2->y ), QPoint( e2->x_root, e2->y_root ), x11ToQtMouseButton( e2->button ),
|
|
|
|
x11ToQtMouseButtons( e2->state ), x11ToQtKeyboardModifiers( e2->state ));
|
|
|
|
pos.first->windowInputMouseEvent( pos.second, &ev );
|
|
|
|
break; // --->
|
|
|
|
}
|
|
|
|
case MotionNotify:
|
|
|
|
{
|
|
|
|
XMotionEvent* e2 = &e->xmotion;
|
|
|
|
QMouseEvent ev( QEvent::MouseMove, QPoint( e2->x, e2->y ), QPoint( e2->x_root, e2->y_root ),
|
|
|
|
Qt::NoButton, x11ToQtMouseButtons( e2->state ), x11ToQtKeyboardModifiers( e2->state ));
|
|
|
|
pos.first->windowInputMouseEvent( pos.second, &ev );
|
|
|
|
break; // --->
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true; // eat event
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandler::checkInputWindowStacking()
|
|
|
|
{
|
|
|
|
if( input_windows.count() == 0 )
|
|
|
|
return;
|
|
|
|
Window* wins = new Window[ input_windows.count() ];
|
|
|
|
int pos = 0;
|
|
|
|
foreach( InputWindowPair it, input_windows )
|
|
|
|
wins[ pos++ ] = it.second;
|
|
|
|
XRaiseWindow( display(), wins[ 0 ] );
|
|
|
|
XRestackWindows( display(), wins, pos );
|
|
|
|
delete[] wins;
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void EffectsHandler::activateWindow( EffectWindow* c )
|
2007-01-05 16:45:56 +00:00
|
|
|
{
|
2007-01-22 22:57:22 +00:00
|
|
|
if( Client* cl = dynamic_cast< Client* >( c->window()))
|
|
|
|
Workspace::self()->activateClient( cl, true );
|
2007-01-05 16:45:56 +00:00
|
|
|
}
|
|
|
|
|
2007-02-04 22:19:17 +00:00
|
|
|
void EffectsHandler::registerEffect( const QString& name, EffectFactory* factory )
|
|
|
|
{
|
2007-03-14 16:50:19 +00:00
|
|
|
QHash<QString, EffectFactory*>::const_iterator factories_iterator = effect_factories.find(name);
|
2007-02-04 22:19:17 +00:00
|
|
|
if( factories_iterator != effect_factories.end() )
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "EffectsHandler::registerEffect : Effect name already registered : " << name << endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "EffectsHandler::registerEffect : Register effect : " << name << endl;
|
|
|
|
effect_factories[name] = factory;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandler::loadEffect( const QString& name )
|
|
|
|
{
|
|
|
|
assert( current_paint_screen == 0 );
|
|
|
|
assert( current_paint_window == 0 );
|
2007-03-07 17:50:33 +00:00
|
|
|
assert( current_draw_window == 0 );
|
2007-02-04 22:19:17 +00:00
|
|
|
|
|
|
|
for(QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); it++)
|
|
|
|
{
|
|
|
|
if( (*it).first == name )
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "EffectsHandler::loadEffect : Effect already loaded : " << name << endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-14 16:50:19 +00:00
|
|
|
QHash<QString, EffectFactory*>::const_iterator factories_iterator = effect_factories.find(name);
|
2007-02-04 22:19:17 +00:00
|
|
|
if( factories_iterator != effect_factories.end() )
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "EffectsHandler::loadEffect : Loading effect : " << name << endl;
|
|
|
|
loaded_effects.append( EffectPair( name, factories_iterator.value()->create() ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "EffectsHandler::loadEffect : Unknown effect : " << name << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandler::unloadEffect( const QString& name )
|
|
|
|
{
|
|
|
|
assert( current_paint_screen == 0 );
|
|
|
|
assert( current_paint_window == 0 );
|
2007-03-07 17:50:33 +00:00
|
|
|
assert( current_draw_window == 0 );
|
2007-02-04 22:19:17 +00:00
|
|
|
|
|
|
|
for( QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); it++)
|
|
|
|
{
|
|
|
|
if ( (*it).first == name )
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "EffectsHandler::unloadEffect : Unloading Effect : " << name << endl;
|
|
|
|
delete (*it).second;
|
|
|
|
loaded_effects.erase(it);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kDebug( 1212 ) << "EffectsHandler::unloadEffect : Effect not loaded : " << name << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectFactory::~EffectFactory()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-02-01 17:20:48 +00:00
|
|
|
int EffectsHandler::currentDesktop() const
|
|
|
|
{
|
|
|
|
return Workspace::self()->currentDesktop();
|
|
|
|
}
|
|
|
|
|
2006-07-04 20:51:01 +00:00
|
|
|
EffectsHandler* effects;
|
|
|
|
|
2007-02-01 17:20:48 +00:00
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// EffectWindow
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
EffectWindow::EffectWindow()
|
|
|
|
: toplevel( NULL )
|
|
|
|
, sw( NULL )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-02-11 17:36:32 +00:00
|
|
|
void EffectWindow::enablePainting( int reason )
|
|
|
|
{
|
|
|
|
sceneWindow()->enablePainting( reason );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindow::disablePainting( int reason )
|
|
|
|
{
|
|
|
|
sceneWindow()->disablePainting( reason );
|
|
|
|
}
|
|
|
|
|
2007-02-01 17:20:48 +00:00
|
|
|
int EffectWindow::desktop() const
|
|
|
|
{
|
|
|
|
return toplevel->desktop();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindow::isOnCurrentDesktop() const
|
|
|
|
{
|
|
|
|
return isOnDesktop( effects->currentDesktop());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindow::isOnAllDesktops() const
|
|
|
|
{
|
|
|
|
return desktop() == NET::OnAllDesktops;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindow::isOnDesktop( int d ) const
|
|
|
|
{
|
|
|
|
return desktop() == d || isOnAllDesktops();
|
|
|
|
}
|
|
|
|
|
2006-07-04 20:51:01 +00:00
|
|
|
} // namespace
|