From 0b4f83fc90f4a04c1a6cb6036f38d5921a269810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 12 Apr 2007 13:12:11 +0000 Subject: [PATCH] The rest ported to plugins, BoxSwich being the only exception. svn path=/branches/work/kwin_composite/; revision=652990 --- effects/CMakeLists.txt | 18 ++- effects/boxswitch.cpp | 12 +- effects/boxswitch.desktop | 4 + effects/boxswitch.h | 16 +- ...kspaceup.cpp => demo_shiftworkspaceup.cpp} | 6 +- effects/demo_shiftworkspaceup.desktop | 4 + ...tworkspaceup.h => demo_shiftworkspaceup.h} | 0 effects/demo_taskbarthumbnail.cpp | 35 ++--- effects/demo_taskbarthumbnail.desktop | 4 + effects/demo_taskbarthumbnail.h | 4 +- effects/desktopchangeslide.cpp | 41 +++--- effects/desktopchangeslide.desktop | 4 + effects/desktopchangeslide.h | 2 +- effects/dialogparent.cpp | 40 ++--- effects/dialogparent.desktop | 4 + effects/dialogparent.h | 4 +- effects/drunken.cpp | 10 +- effects/drunken.desktop | 4 + effects/drunken.h | 2 +- effects/fade.cpp | 35 +++-- effects/fade.desktop | 4 + effects/fade.h | 2 +- effects/fallapart.cpp | 138 +++++++++--------- effects/fallapart.desktop | 4 + effects/fallapart.h | 2 +- effects/test_shiftworkspaceup.desktop | 4 - 26 files changed, 214 insertions(+), 189 deletions(-) create mode 100644 effects/boxswitch.desktop rename effects/{test_shiftworkspaceup.cpp => demo_shiftworkspaceup.cpp} (91%) create mode 100644 effects/demo_shiftworkspaceup.desktop rename effects/{test_shiftworkspaceup.h => demo_shiftworkspaceup.h} (100%) create mode 100644 effects/demo_taskbarthumbnail.desktop create mode 100644 effects/desktopchangeslide.desktop create mode 100644 effects/dialogparent.desktop create mode 100644 effects/drunken.desktop create mode 100644 effects/fade.desktop create mode 100644 effects/fallapart.desktop delete mode 100644 effects/test_shiftworkspaceup.desktop diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 951ce32366..68b72bc5ba 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -11,7 +11,13 @@ include_directories( ) SET(kwin4_effect_builtins_sources + boxswitch.cpp + desktopchangeslide.cpp + dialogparent.cpp diminactive.cpp + drunken.cpp + fade.cpp + fallapart.cpp flame.cpp maketransparent.cpp minimizeanimation.cpp @@ -22,9 +28,10 @@ SET(kwin4_effect_builtins_sources ) SET(kwin4_effect_tests_sources + demo_shiftworkspaceup.cpp + demo_taskbarthumbnail.cpp howto.cpp test_input.cpp - test_shiftworkspaceup.cpp test_thumbnail.cpp ) @@ -62,7 +69,13 @@ endif (X11_Xrender_FOUND) KWIN4_ADD_EFFECT(tests ${kwin4_effect_tests_sources}) install( FILES + boxswitch.desktop + desktopchangeslide.desktop + dialogparent.desktop diminactive.desktop + drunken.desktop + fade.desktop + fallapart.desktop flame.desktop howto.desktop maketransparent.desktop @@ -71,8 +84,9 @@ install( FILES scalein.desktop shakymove.desktop zoom.desktop + demo_shiftworkspaceup.desktop + demo_taskbarthumbnail.desktop test_input.desktop - test_shiftworkspaceup.desktop test_thumbnail.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin/effects ) diff --git a/effects/boxswitch.cpp b/effects/boxswitch.cpp index 0e5101db4d..02aeb40644 100644 --- a/effects/boxswitch.cpp +++ b/effects/boxswitch.cpp @@ -8,12 +8,9 @@ You can Freely distribute this program under the GNU General Public License. See the file "COPYING" for the exact licensing terms. ******************************************************************/ -#include "boxswitch.h" +#include -#include "tabbox.h" -#include "client.h" -#include "scene_xrender.h" -#include "scene_opengl.h" +#include "boxswitch.h" #include @@ -21,9 +18,13 @@ License. See the file "COPYING" for the exact licensing terms. #include #endif +#if 0 +// TODO namespace KWin { +KWIN_EFFECT( BoxSwitch, BoxSwitchEffect ) + BoxSwitchEffect::BoxSwitchEffect() : mActivated( 0 ) , mMode( 0 ) @@ -626,3 +627,4 @@ void BoxSwitchEffect::paintWindowIcon( EffectWindow* w ) } } // namespace +#endif diff --git a/effects/boxswitch.desktop b/effects/boxswitch.desktop new file mode 100644 index 0000000000..52713aefe7 --- /dev/null +++ b/effects/boxswitch.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=BoxSwitch +X-KDE-Library=kwin4_effect_builtins diff --git a/effects/boxswitch.h b/effects/boxswitch.h index 6585794422..66a788d8d3 100644 --- a/effects/boxswitch.h +++ b/effects/boxswitch.h @@ -11,9 +11,10 @@ License. See the file "COPYING" for the exact licensing terms. #ifndef KWIN_BOXSWITCH_H #define KWIN_BOXSWITCH_H -#include -#include "scene_xrender.h" -#include "scene_opengl.h" +#if 0 +// TODO + +#include #include #include @@ -21,6 +22,12 @@ License. See the file "COPYING" for the exact licensing terms. #include #include +#include + +#ifdef HAVE_XRENDER +#include +#endif + namespace KWin { @@ -66,7 +73,7 @@ class BoxSwitchEffect QSize item_max_size; // maximum item display size (including highlight) QHash< EffectWindow*, ItemInfo* > windows; - ClientList original_windows; + EffectWindowList original_windows; EffectWindow* selected_window; QHash< int, ItemInfo* > desktops; QList< int > original_desktops; @@ -97,3 +104,4 @@ class BoxSwitchEffect::ItemInfo } // namespace #endif +#endif diff --git a/effects/test_shiftworkspaceup.cpp b/effects/demo_shiftworkspaceup.cpp similarity index 91% rename from effects/test_shiftworkspaceup.cpp rename to effects/demo_shiftworkspaceup.cpp index de0d3e7545..7bf20a47ac 100644 --- a/effects/test_shiftworkspaceup.cpp +++ b/effects/demo_shiftworkspaceup.cpp @@ -8,12 +8,12 @@ You can Freely distribute this program under the GNU General Public License. See the file "COPYING" for the exact licensing terms. ******************************************************************/ -#include "test_shiftworkspaceup.h" +#include "demo_shiftworkspaceup.h" namespace KWin { -KWIN_EFFECT( ShiftWorkspaceUp, ShiftWorkspaceUpEffect ) +KWIN_EFFECT( DemoShiftWorkspaceUp, ShiftWorkspaceUpEffect ) ShiftWorkspaceUpEffect::ShiftWorkspaceUpEffect() : up( false ) @@ -56,4 +56,4 @@ void ShiftWorkspaceUpEffect::tick() } // namespace -#include "test_shiftworkspaceup.moc" +#include "demo_shiftworkspaceup.moc" diff --git a/effects/demo_shiftworkspaceup.desktop b/effects/demo_shiftworkspaceup.desktop new file mode 100644 index 0000000000..5c79dc2fd2 --- /dev/null +++ b/effects/demo_shiftworkspaceup.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=DemoShiftWorkspaceUp +X-KDE-Library=kwin4_effect_demos diff --git a/effects/test_shiftworkspaceup.h b/effects/demo_shiftworkspaceup.h similarity index 100% rename from effects/test_shiftworkspaceup.h rename to effects/demo_shiftworkspaceup.h diff --git a/effects/demo_taskbarthumbnail.cpp b/effects/demo_taskbarthumbnail.cpp index 31c65fd439..724678e89b 100644 --- a/effects/demo_taskbarthumbnail.cpp +++ b/effects/demo_taskbarthumbnail.cpp @@ -11,13 +11,13 @@ License. See the file "COPYING" for the exact licensing terms. #include "demo_taskbarthumbnail.h" -#include -#include - +#include namespace KWin { +KWIN_EFFECT( DemoTaskbarThumbnail, TaskbarThumbnailEffect ) + TaskbarThumbnailEffect::TaskbarThumbnailEffect() { mLastCursorPos = QPoint(-1, -1); @@ -31,7 +31,7 @@ void TaskbarThumbnailEffect::prePaintScreen( int* mask, QRegion* region, int tim QPoint cpos = cursorPos(); if(cpos != mLastCursorPos || mThumbnails.count() > 0) { - *mask |= Scene::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; + *mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; mThumbnails.clear(); mLastCursorPos = cpos; } @@ -41,15 +41,9 @@ void TaskbarThumbnailEffect::prePaintScreen( int* mask, QRegion* region, int tim void TaskbarThumbnailEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, int time ) { - Client* c = dynamic_cast< Client* >( w->window() ); - if( c ) - { - QRect iconGeo = c->iconGeometry(); - if(iconGeo.contains( mLastCursorPos )) - { - mThumbnails.append( w ); - } - } + QRect iconGeo = w->iconGeometry(); + if(iconGeo.contains( mLastCursorPos )) + mThumbnails.append( w ); effects->prePaintWindow( w, mask, paint, clip, time ); } @@ -61,23 +55,22 @@ void TaskbarThumbnailEffect::postPaintScreen() int space = 4; foreach( EffectWindow* w, mThumbnails ) { - Client* c = static_cast< Client* >( w->window() ); - QRect thumb = getThumbnailPosition(c, &space); + QRect thumb = getThumbnailPosition( w, &space); WindowPaintData thumbdata; - thumbdata.xTranslate = thumb.x() - c->x(); - thumbdata.yTranslate = thumb.y() - c->y(); - thumbdata.xScale = thumb.width() / (float)c->width(); - thumbdata.yScale = thumb.height() / (float)c->height(); + thumbdata.xTranslate = thumb.x() - w->x(); + thumbdata.yTranslate = thumb.y() - w->y(); + thumbdata.xScale = thumb.width() / (float)w->width(); + thumbdata.yScale = thumb.height() / (float)w->height(); // From Scene::Window::infiniteRegion() QRegion infRegion = QRegion( INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX ); - effects->paintWindow( w, Scene::PAINT_WINDOW_TRANSFORMED, infRegion, thumbdata ); + effects->paintWindow( w, PAINT_WINDOW_TRANSFORMED, infRegion, thumbdata ); } // Call the next effect. effects->postPaintScreen(); } -QRect TaskbarThumbnailEffect::getThumbnailPosition( Client* c, int* space ) const +QRect TaskbarThumbnailEffect::getThumbnailPosition( EffectWindow* c, int* space ) const { QRect thumb; QRect icon = c->iconGeometry(); diff --git a/effects/demo_taskbarthumbnail.desktop b/effects/demo_taskbarthumbnail.desktop new file mode 100644 index 0000000000..f03e488713 --- /dev/null +++ b/effects/demo_taskbarthumbnail.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=DemoTaskbarThumbnail +X-KDE-Library=kwin4_effect_demos diff --git a/effects/demo_taskbarthumbnail.h b/effects/demo_taskbarthumbnail.h index 32cfc20d32..10941306f1 100644 --- a/effects/demo_taskbarthumbnail.h +++ b/effects/demo_taskbarthumbnail.h @@ -12,7 +12,7 @@ License. See the file "COPYING" for the exact licensing terms. #define KWIN_TASKBARTHUMBNAIL_H // Include with base class for effects. -#include +#include namespace KWin @@ -37,7 +37,7 @@ class TaskbarThumbnailEffect protected: - QRect getThumbnailPosition( Client*c, int* space ) const; + QRect getThumbnailPosition( EffectWindow* c, int* space ) const; private: QList< EffectWindow* > mThumbnails; diff --git a/effects/desktopchangeslide.cpp b/effects/desktopchangeslide.cpp index 6b09c423b0..0ecb8d2286 100644 --- a/effects/desktopchangeslide.cpp +++ b/effects/desktopchangeslide.cpp @@ -10,12 +10,11 @@ License. See the file "COPYING" for the exact licensing terms. #include "desktopchangeslide.h" -#include -#include - namespace KWin { +KWIN_EFFECT( DesktopChangeSlide, DesktopChangeSlideEffect ) + const int MAX_PROGRESS = 500; // ms DesktopChangeSlideEffect::DesktopChangeSlideEffect() @@ -29,7 +28,7 @@ void DesktopChangeSlideEffect::prePaintScreen( int* mask, QRegion* region, int t // PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once, // so with normal screen painting second screen paint would erase parts of the first paint if( progress != MAX_PROGRESS ) - *mask |= Scene::PAINT_SCREEN_TRANSFORMED | Scene::PAINT_SCREEN_BACKGROUND_FIRST; + *mask |= PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST; effects->prePaintScreen( mask, region, time ); } @@ -40,14 +39,14 @@ void DesktopChangeSlideEffect::prePaintWindow( EffectWindow* w, int* mask, QRegi if( w->isOnAllDesktops()) { if( painting_sticky ) - *mask |= Scene::PAINT_WINDOW_TRANSFORMED; + *mask |= PAINT_WINDOW_TRANSFORMED; else - w->disablePainting( Scene::Window::PAINT_DISABLED_BY_DESKTOP ); + w->disablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP ); } else if( w->isOnDesktop( painting_desktop )) - w->enablePainting( Scene::Window::PAINT_DISABLED_BY_DESKTOP ); + w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP ); else - w->disablePainting( Scene::Window::PAINT_DISABLED_BY_DESKTOP ); + w->disablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP ); } effects->prePaintWindow( w, mask, paint, clip, time ); } @@ -64,15 +63,15 @@ void DesktopChangeSlideEffect::paintScreen( int mask, QRegion region, ScreenPain of it, the destination is computed from the current desktop. Positions of desktops are done using their topleft corner. */ - QPoint destPos = desktopPos( Workspace::self()->currentDesktop()); + QPoint destPos = desktopPos( effects->currentDesktop()); QPoint diffPos = destPos - startPos; int w = 0; int h = 0; - if( options->rollOverDesktops ) + if( effects->optionRollOverDesktops()) { int x, y; Qt::Orientation orientation; - Workspace::self()->calcDesktopLayout( &x, &y, &orientation ); + effects->calcDesktopLayout( &x, &y, &orientation ); w = x * displayWidth(); h = y * displayHeight(); // wrap around if shorter @@ -88,7 +87,7 @@ void DesktopChangeSlideEffect::paintScreen( int mask, QRegion region, ScreenPain QPoint currentPos = startPos + progress * diffPos / MAX_PROGRESS; QSize displaySize( displayWidth(), displayHeight()); QRegion currentRegion = QRect( currentPos, displaySize ); - if( options->rollOverDesktops ) + if( effects->optionRollOverDesktops()) { currentRegion |= ( currentRegion & QRect( -w, 0, w, h )).translated( w, 0 ); currentRegion |= ( currentRegion & QRect( 0, -h, w, h )).translated( 0, h ); @@ -97,7 +96,7 @@ void DesktopChangeSlideEffect::paintScreen( int mask, QRegion region, ScreenPain } bool do_sticky = true; for( int desktop = 1; - desktop <= Workspace::self()->numberOfDesktops(); + desktop <= effects->numberOfDesktops(); ++desktop ) { QRect desktopRect( desktopPos( desktop ), displaySize ); @@ -106,7 +105,7 @@ void DesktopChangeSlideEffect::paintScreen( int mask, QRegion region, ScreenPain painting_desktop = desktop; painting_sticky = do_sticky; painting_diff = desktopRect.topLeft() - currentPos; - if( options->rollOverDesktops ) + if( effects->optionRollOverDesktops()) { if( painting_diff.x() > displayWidth()) painting_diff.setX( painting_diff.x() - w ); @@ -143,7 +142,7 @@ void DesktopChangeSlideEffect::paintWindow( EffectWindow* w, int mask, QRegion r void DesktopChangeSlideEffect::postPaintScreen() { if( progress != MAX_PROGRESS ) - Workspace::self()->addRepaintFull(); // trigger next animation repaint + effects->addRepaintFull(); // trigger next animation repaint effects->postPaintScreen(); } @@ -152,7 +151,7 @@ QPoint DesktopChangeSlideEffect::desktopPos( int desktop ) { int x, y; Qt::Orientation orientation; - Workspace::self()->calcDesktopLayout( &x, &y, &orientation ); + effects->calcDesktopLayout( &x, &y, &orientation ); --desktop; // make it start with 0 if( orientation == Qt::Vertical ) return QPoint(( desktop % x ) * displayWidth(), ( desktop / x ) * displayHeight()); @@ -167,11 +166,11 @@ void DesktopChangeSlideEffect::desktopChanged( int old ) QPoint diffPos = desktopPos( old ) - startPos; int w = 0; int h = 0; - if( options->rollOverDesktops ) + if( effects->optionRollOverDesktops()) { int x, y; Qt::Orientation orientation; - Workspace::self()->calcDesktopLayout( &x, &y, &orientation ); + effects->calcDesktopLayout( &x, &y, &orientation ); w = x * displayWidth(); h = y * displayHeight(); // wrap around if shorter @@ -186,14 +185,14 @@ void DesktopChangeSlideEffect::desktopChanged( int old ) } QPoint currentPos = startPos + progress * diffPos / MAX_PROGRESS; QRegion currentRegion = QRect( currentPos, QSize( displayWidth(), displayHeight())); - if( options->rollOverDesktops ) + if( effects->optionRollOverDesktops()) { currentRegion |= ( currentRegion & QRect( -w, 0, w, h )).translated( w, 0 ); currentRegion |= ( currentRegion & QRect( 0, -h, w, h )).translated( 0, h ); currentRegion |= ( currentRegion & QRect( w, 0, w, h )).translated( -w, 0 ); currentRegion |= ( currentRegion & QRect( 0, h, w, h )).translated( 0, -h ); } - QRect desktopRect( desktopPos( Workspace::self()->currentDesktop()), QSize( displayWidth(), displayHeight())); + QRect desktopRect( desktopPos( effects->currentDesktop()), QSize( displayWidth(), displayHeight())); if( currentRegion.contains( desktopRect )) { // current position is in new current desktop (e.g. quickly changing back), // don't do full progress @@ -213,7 +212,7 @@ void DesktopChangeSlideEffect::desktopChanged( int old ) progress = 0; startPos = desktopPos( old ); } - Workspace::self()->addRepaintFull(); + effects->addRepaintFull(); } } // namespace diff --git a/effects/desktopchangeslide.desktop b/effects/desktopchangeslide.desktop new file mode 100644 index 0000000000..b83cf4905c --- /dev/null +++ b/effects/desktopchangeslide.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=DesktopChangeSlide +X-KDE-Library=kwin4_effect_builtins diff --git a/effects/desktopchangeslide.h b/effects/desktopchangeslide.h index 326081de8f..73983cb4ad 100644 --- a/effects/desktopchangeslide.h +++ b/effects/desktopchangeslide.h @@ -11,7 +11,7 @@ License. See the file "COPYING" for the exact licensing terms. #ifndef KWIN_DESKTOPCHANGESLIDE_H #define KWIN_DESKTOPCHANGESLIDE_H -#include +#include namespace KWin { diff --git a/effects/dialogparent.cpp b/effects/dialogparent.cpp index 0469164a87..e6d919dacf 100644 --- a/effects/dialogparent.cpp +++ b/effects/dialogparent.cpp @@ -8,14 +8,13 @@ You can Freely distribute this program under the GNU General Public License. See the file "COPYING" for the exact licensing terms. ******************************************************************/ - #include "dialogparent.h" -#include - namespace KWin { +KWIN_EFFECT( DialogParent, DialogParentEffect ) + void DialogParentEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, int time ) { // How long does it take for the effect to get it's full strength (in ms) @@ -23,7 +22,7 @@ void DialogParentEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* pa // Check if this window has a modal dialog and change the window's // effect's strength accordingly - bool hasDialog = hasModalWindow(w->window()); + bool hasDialog = w->findModal() != NULL; if( hasDialog ) { // Increase effect strength of this window @@ -60,49 +59,38 @@ void DialogParentEffect::postPaintWindow( EffectWindow* w ) // If strength is between 0 and 1, the effect is still in progress and the // window has to be repainted during the next pass if( s > 0.0 && s < 1.0 ) - w->window()->addRepaintFull(); // trigger next animation repaint + w->addRepaintFull(); // trigger next animation repaint // Call the next effect. effects->postPaintWindow( w ); } -void DialogParentEffect::windowActivated( EffectWindow* t ) +void DialogParentEffect::windowActivated( EffectWindow* w ) { // If this window is a dialog, we need to repaint it's parent window, so // that the effect could be run for it // Set the window to be faded (or NULL if no window is active). - Client* c = qobject_cast(t?t->window():NULL); - if ( c && c->isModal() ) + if( w && w->isModal() ) { - // c is a modal dialog - ClientList mainclients = c->mainClients(); - foreach( Client* parent, mainclients ) + // w is a modal dialog + EffectWindowList mainwindows = w->mainWindows(); + foreach( EffectWindow* parent, mainwindows ) parent->addRepaintFull(); } } -void DialogParentEffect::windowClosed( EffectWindow* t ) +void DialogParentEffect::windowClosed( EffectWindow* w ) { // If this window is a dialog, we need to repaint it's parent window, so // that the effect could be run for it // Set the window to be faded (or NULL if no window is active). - Client* c = qobject_cast(t->window()); - if ( c && c->isModal() ) + if ( w && w->isModal() ) { - // c is a modal dialog - ClientList mainclients = c->mainClients(); - foreach( Client* parent, mainclients ) + // w is a modal dialog + EffectWindowList mainwindows = w->mainWindows(); + foreach( EffectWindow* parent, mainwindows ) parent->addRepaintFull(); } } -bool DialogParentEffect::hasModalWindow( Toplevel* t ) - { - Client* c = qobject_cast(t); - if( !c ) - return false; - return c->findModal() != NULL; - } - - } // namespace diff --git a/effects/dialogparent.desktop b/effects/dialogparent.desktop new file mode 100644 index 0000000000..8d3be21172 --- /dev/null +++ b/effects/dialogparent.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=DialogParent +X-KDE-Library=kwin4_effect_builtins diff --git a/effects/dialogparent.h b/effects/dialogparent.h index 677077346d..0bf31c110a 100644 --- a/effects/dialogparent.h +++ b/effects/dialogparent.h @@ -12,7 +12,7 @@ License. See the file "COPYING" for the exact licensing terms. #define KWIN_DIALOGPARENT_H // Include with base class for effects. -#include +#include namespace KWin @@ -36,7 +36,7 @@ class DialogParentEffect virtual void windowActivated( EffectWindow* c ); protected: - bool hasModalWindow( Toplevel* t ); + bool hasModalWindow( EffectWindow* t ); private: // The progress of the fading. QHash effectStrength; diff --git a/effects/drunken.cpp b/effects/drunken.cpp index dc86e7cee7..3133444fd9 100644 --- a/effects/drunken.cpp +++ b/effects/drunken.cpp @@ -15,10 +15,12 @@ License. See the file "COPYING" for the exact licensing terms. namespace KWin { +KWIN_EFFECT( Drunken, DrunkenEffect ) + void DrunkenEffect::prePaintScreen( int* mask, QRegion* region, int time ) { if( !windows.isEmpty()) - *mask |= Scene::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; + *mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; effects->prePaintScreen( mask, region, time ); } @@ -28,7 +30,7 @@ void DrunkenEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, { windows[ w ] += time / 1000.; if( windows[ w ] < 1 ) - *mask |= Scene::PAINT_WINDOW_TRANSFORMED; + *mask |= PAINT_WINDOW_TRANSFORMED; else windows.remove( w ); } @@ -57,14 +59,14 @@ void DrunkenEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wind void DrunkenEffect::postPaintWindow( EffectWindow* w ) { if( windows.contains( w )) - w->window()->addRepaintFull(); + w->addRepaintFull(); effects->postPaintWindow( w ); } void DrunkenEffect::windowAdded( EffectWindow* w ) { windows[ w ] = 0; - w->window()->addRepaintFull(); + w->addRepaintFull(); } void DrunkenEffect::windowClosed( EffectWindow* w ) diff --git a/effects/drunken.desktop b/effects/drunken.desktop new file mode 100644 index 0000000000..e8e9714f22 --- /dev/null +++ b/effects/drunken.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Drunken +X-KDE-Library=kwin4_effect_builtins diff --git a/effects/drunken.h b/effects/drunken.h index 0eb937f9e1..0650769274 100644 --- a/effects/drunken.h +++ b/effects/drunken.h @@ -11,7 +11,7 @@ License. See the file "COPYING" for the exact licensing terms. #ifndef KWIN_DRUNKEN_H #define KWIN_DRUNKEN_H -#include +#include namespace KWin { diff --git a/effects/fade.cpp b/effects/fade.cpp index 9b30fc3945..fd9f7cbb5c 100644 --- a/effects/fade.cpp +++ b/effects/fade.cpp @@ -10,12 +10,11 @@ License. See the file "COPYING" for the exact licensing terms. #include "fade.h" -#include -#include - namespace KWin { +KWIN_EFFECT( Fade, FadeEffect ) + FadeEffect::FadeEffect() : fade_in_speed( 20 ) , fade_out_speed( 70 ) @@ -43,16 +42,16 @@ void FadeEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRe { if( windows[ w ].deleted ) { - static_cast< Deleted* >( w->window())->unrefWindow(); + w->unrefWindow(); windows.remove( w ); } } else { - *mask |= Scene::PAINT_WINDOW_TRANSLUCENT; - *mask &= ~Scene::PAINT_WINDOW_OPAQUE; + *mask |= PAINT_WINDOW_TRANSLUCENT; + *mask &= ~PAINT_WINDOW_OPAQUE; if( windows[ w ].deleted ) - w->enablePainting( Scene::Window::PAINT_DISABLED_BY_DELETE ); + w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE ); } } effects->prePaintWindow( w, mask, paint, clip, time ); @@ -61,20 +60,20 @@ void FadeEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRe void FadeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) { if( windows.contains( w )) - data.opacity = ( data.opacity + ( w->window()->opacity() == 0.0 ? 1 : 0 )) * windows[ w ].current; + data.opacity = ( data.opacity + ( w->opacity() == 0.0 ? 1 : 0 )) * windows[ w ].current; effects->paintWindow( w, mask, region, data ); } void FadeEffect::postPaintWindow( EffectWindow* w ) { if( windows.contains( w ) && windows.value( w ).isFading()) - w->window()->addRepaintFull(); // trigger next animation repaint + w->addRepaintFull(); // trigger next animation repaint effects->postPaintWindow( w ); } void FadeEffect::windowOpacityChanged( EffectWindow* c, double old_opacity ) { - double new_opacity = c->window()->opacity(); + double new_opacity = c->opacity(); if( !windows.contains( c )) windows[ c ].current = 1; if( new_opacity == 0.0 ) @@ -89,14 +88,14 @@ void FadeEffect::windowOpacityChanged( EffectWindow* c, double old_opacity ) windows[ c ].target = 1; windows[ c ].step_mult = 1 / new_opacity; } - c->window()->addRepaintFull(); + c->addRepaintFull(); } void FadeEffect::windowAdded( EffectWindow* c ) { if( !windows.contains( c )) windows[ c ].current = 0; - if( c->window()->opacity() == 0.0 ) + if( c->opacity() == 0.0 ) { windows[ c ].target = 0; windows[ c ].step_mult = 1; @@ -104,23 +103,23 @@ void FadeEffect::windowAdded( EffectWindow* c ) else { windows[ c ].target = 1; - windows[ c ].step_mult = 1 / c->window()->opacity(); + windows[ c ].step_mult = 1 / c->opacity(); } - c->window()->addRepaintFull(); + c->addRepaintFull(); } void FadeEffect::windowClosed( EffectWindow* c ) { if( !windows.contains( c )) windows[ c ].current = 1; - if( c->window()->opacity() == 0.0 ) + if( c->opacity() == 0.0 ) windows[ c ].step_mult = 1; else - windows[ c ].step_mult = 1 / c->window()->opacity(); + windows[ c ].step_mult = 1 / c->opacity(); windows[ c ].target = 0; windows[ c ].deleted = true; - c->window()->addRepaintFull(); - static_cast< Deleted* >( c->window())->refWindow(); + c->addRepaintFull(); + c->refWindow(); } void FadeEffect::windowDeleted( EffectWindow* c ) diff --git a/effects/fade.desktop b/effects/fade.desktop new file mode 100644 index 0000000000..f9b7c24a95 --- /dev/null +++ b/effects/fade.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Fade +X-KDE-Library=kwin4_effect_builtins diff --git a/effects/fade.h b/effects/fade.h index 7b4ad8a85b..ae7771a219 100644 --- a/effects/fade.h +++ b/effects/fade.h @@ -11,7 +11,7 @@ License. See the file "COPYING" for the exact licensing terms. #ifndef KWIN_FADE_H #define KWIN_FADE_H -#include +#include namespace KWin { diff --git a/effects/fallapart.cpp b/effects/fallapart.cpp index 71d369477f..94030ae11e 100644 --- a/effects/fallapart.cpp +++ b/effects/fallapart.cpp @@ -10,18 +10,18 @@ License. See the file "COPYING" for the exact licensing terms. #include "fallapart.h" +#include #include -#include -#include - namespace KWin { +KWIN_EFFECT( FallApart, FallApartEffect ) + void FallApartEffect::prePaintScreen( int* mask, QRegion* region, int time ) { if( !windows.isEmpty()) - *mask |= Scene::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; + *mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; effects->prePaintScreen(mask, region, time); } @@ -29,22 +29,18 @@ void FallApartEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* paint { if( windows.contains( w )) { - SceneOpenGL::Window* glwin = dynamic_cast< SceneOpenGL::Window* >( w->sceneWindow()); - if( glwin ) + if( windows[ w ] < 1 ) { - if( windows[ w ] < 1 ) - { - windows[ w ] += time / 1000.; - *mask |= Scene::PAINT_WINDOW_TRANSFORMED; - glwin->enablePainting( Scene::Window::PAINT_DISABLED_BY_DELETE ); - // Request the window to be divided into cells - glwin->requestVertexGrid( 40 ); - } - else - { - windows.remove( w ); - static_cast< Deleted* >( w->window())->unrefWindow(); - } + windows[ w ] += time / 1000.; + *mask |= PAINT_WINDOW_TRANSFORMED; + w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE ); + // Request the window to be divided into cells + w->requestVertexGrid( 40 ); + } + else + { + windows.remove( w ); + w->unrefWindow(); } } effects->prePaintWindow( w, mask, paint, clip, time ); @@ -54,61 +50,57 @@ void FallApartEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi { if( windows.contains( w )) { - SceneOpenGL::Window* glwin = dynamic_cast< SceneOpenGL::Window* >( w->sceneWindow() ); - if( glwin ) + QVector< Vertex >& vertices = w->vertices(); + assert( vertices.count() % 4 == 0 ); + for( int i = 0; + i < vertices.count(); + i += 4 ) { - QVector< SceneOpenGL::Window::Vertex >& vertices = glwin->vertices(); - assert( vertices.count() % 4 == 0 ); - for( int i = 0; - i < vertices.count(); - i += 4 ) + // make fragments move in various directions, based on where + // they are (left pieces generally move to the left, etc.) + QPointF p1( vertices[ i ].pos[ 0 ], vertices[ i ].pos[ 1 ] ); + double xdiff = 0; + if( p1.x() < w->width() / 2 ) + xdiff = -( w->width() / 2 - p1.x()) / w->width() * 100; + if( p1.x() > w->width() / 2 ) + xdiff = ( p1.x() - w->width() / 2 ) / w->width() * 100; + double ydiff = 0; + if( p1.y() < w->height() / 2 ) + ydiff = -( w->height() / 2 - p1.y()) / w->height() * 100; + if( p1.y() > w->height() / 2 ) + ydiff = ( p1.y() - w->height() / 2 ) / w->height() * 100; + double modif = windows[ w ] * windows[ w ] * 64; + srandom( i ); // change direction randomly but consistently + xdiff += ( rand() % 21 - 10 ); + ydiff += ( rand() % 21 - 10 ); + for( int j = 0; + j < 4; + ++j ) { - // make fragments move in various directions, based on where - // they are (left pieces generally move to the left, etc.) - QPointF p1( vertices[ i ].pos[ 0 ], vertices[ i ].pos[ 1 ] ); - double xdiff = 0; - if( p1.x() < w->width() / 2 ) - xdiff = -( w->width() / 2 - p1.x()) / w->width() * 100; - if( p1.x() > w->width() / 2 ) - xdiff = ( p1.x() - w->width() / 2 ) / w->width() * 100; - double ydiff = 0; - if( p1.y() < w->height() / 2 ) - ydiff = -( w->height() / 2 - p1.y()) / w->height() * 100; - if( p1.y() > w->height() / 2 ) - ydiff = ( p1.y() - w->height() / 2 ) / w->height() * 100; - double modif = windows[ w ] * windows[ w ] * 64; - srandom( i ); // change direction randomly but consistently - xdiff += ( rand() % 21 - 10 ); - ydiff += ( rand() % 21 - 10 ); - for( int j = 0; - j < 4; - ++j ) - { - vertices[ i + j ].pos[ 0 ] += xdiff * modif; - vertices[ i + j ].pos[ 1 ] += ydiff * modif; - } - // also make the fragments rotate around their center - QPointF center(( vertices[ i ].pos[ 0 ] + vertices[ i + 1 ].pos[ 0 ] - + vertices[ i + 2 ].pos[ 0 ] + vertices[ i + 3 ].pos[ 0 ] ) / 4, - ( vertices[ i ].pos[ 1 ] + vertices[ i + 1 ].pos[ 1 ] - + vertices[ i + 2 ].pos[ 1 ] + vertices[ i + 3 ].pos[ 1 ] ) / 4 ); - double adiff = ( rand() % 720 - 360 ) / 360. * 2 * M_PI; // spin randomly - for( int j = 0; - j < 4; - ++j ) - { - double x = vertices[ i + j ].pos[ 0 ] - center.x(); - double y = vertices[ i + j ].pos[ 1 ] - center.y(); - double angle = atan2( y, x ); - angle += windows[ w ] * adiff; - double dist = sqrt( x * x + y * y ); - x = dist * cos( angle ); - y = dist * sin( angle ); - vertices[ i + j ].pos[ 0 ] = center.x() + x; - vertices[ i + j ].pos[ 1 ] = center.y() + y; - } + vertices[ i + j ].pos[ 0 ] += xdiff * modif; + vertices[ i + j ].pos[ 1 ] += ydiff * modif; } - glwin->markVerticesDirty(); + // also make the fragments rotate around their center + QPointF center(( vertices[ i ].pos[ 0 ] + vertices[ i + 1 ].pos[ 0 ] + + vertices[ i + 2 ].pos[ 0 ] + vertices[ i + 3 ].pos[ 0 ] ) / 4, + ( vertices[ i ].pos[ 1 ] + vertices[ i + 1 ].pos[ 1 ] + + vertices[ i + 2 ].pos[ 1 ] + vertices[ i + 3 ].pos[ 1 ] ) / 4 ); + double adiff = ( rand() % 720 - 360 ) / 360. * 2 * M_PI; // spin randomly + for( int j = 0; + j < 4; + ++j ) + { + double x = vertices[ i + j ].pos[ 0 ] - center.x(); + double y = vertices[ i + j ].pos[ 1 ] - center.y(); + double angle = atan2( y, x ); + angle += windows[ w ] * adiff; + double dist = sqrt( x * x + y * y ); + x = dist * cos( angle ); + y = dist * sin( angle ); + vertices[ i + j ].pos[ 0 ] = center.x() + x; + vertices[ i + j ].pos[ 1 ] = center.y() + y; + } + w->markVerticesDirty(); } } effects->paintWindow( w, mask, region, data ); @@ -117,14 +109,14 @@ void FallApartEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi void FallApartEffect::postPaintScreen() { if( !windows.isEmpty()) - workspace()->addRepaintFull(); + effects->addRepaintFull(); effects->postPaintScreen(); } void FallApartEffect::windowClosed( EffectWindow* c ) { windows[ c ] = 0; - static_cast< Deleted* >( c->window())->refWindow(); + c->refWindow(); } void FallApartEffect::windowDeleted( EffectWindow* c ) diff --git a/effects/fallapart.desktop b/effects/fallapart.desktop new file mode 100644 index 0000000000..b8485176ee --- /dev/null +++ b/effects/fallapart.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=FallApart +X-KDE-Library=kwin4_effect_builtins diff --git a/effects/fallapart.h b/effects/fallapart.h index b75ab65c5f..6161690a95 100644 --- a/effects/fallapart.h +++ b/effects/fallapart.h @@ -11,7 +11,7 @@ License. See the file "COPYING" for the exact licensing terms. #ifndef KWIN_FALLAPART_H #define KWIN_FALLAPART_H -#include +#include namespace KWin { diff --git a/effects/test_shiftworkspaceup.desktop b/effects/test_shiftworkspaceup.desktop deleted file mode 100644 index 15fb5e5edc..0000000000 --- a/effects/test_shiftworkspaceup.desktop +++ /dev/null @@ -1,4 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=TestShiftWorkspaceUp -X-KDE-Library=kwin4_effect_tests