The rest ported to plugins, BoxSwich being the only exception.
svn path=/branches/work/kwin_composite/; revision=652990
This commit is contained in:
parent
561fdef0ff
commit
0b4f83fc90
26 changed files with 214 additions and 189 deletions
|
@ -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 )
|
||||
|
||||
|
|
|
@ -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 <config.h>
|
||||
|
||||
#include "tabbox.h"
|
||||
#include "client.h"
|
||||
#include "scene_xrender.h"
|
||||
#include "scene_opengl.h"
|
||||
#include "boxswitch.h"
|
||||
|
||||
#include <QSize>
|
||||
|
||||
|
@ -21,9 +18,13 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#include <GL/gl.h>
|
||||
#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
|
||||
|
|
4
effects/boxswitch.desktop
Normal file
4
effects/boxswitch.desktop
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=BoxSwitch
|
||||
X-KDE-Library=kwin4_effect_builtins
|
|
@ -11,9 +11,10 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#ifndef KWIN_BOXSWITCH_H
|
||||
#define KWIN_BOXSWITCH_H
|
||||
|
||||
#include <effects.h>
|
||||
#include "scene_xrender.h"
|
||||
#include "scene_opengl.h"
|
||||
#if 0
|
||||
// TODO
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QPixmap>
|
||||
|
@ -21,6 +22,12 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#include <QRegion>
|
||||
#include <QSize>
|
||||
|
||||
#include <kwinglutils.h>
|
||||
|
||||
#ifdef HAVE_XRENDER
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#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
|
||||
|
|
|
@ -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"
|
4
effects/demo_shiftworkspaceup.desktop
Normal file
4
effects/demo_shiftworkspaceup.desktop
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=DemoShiftWorkspaceUp
|
||||
X-KDE-Library=kwin4_effect_demos
|
|
@ -11,13 +11,13 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include "demo_taskbarthumbnail.h"
|
||||
|
||||
#include <workspace.h>
|
||||
#include <client.h>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
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();
|
||||
|
|
4
effects/demo_taskbarthumbnail.desktop
Normal file
4
effects/demo_taskbarthumbnail.desktop
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=DemoTaskbarThumbnail
|
||||
X-KDE-Library=kwin4_effect_demos
|
|
@ -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 <effects.h>
|
||||
#include <kwineffects.h>
|
||||
|
||||
|
||||
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;
|
||||
|
|
|
@ -10,12 +10,11 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include "desktopchangeslide.h"
|
||||
|
||||
#include <options.h>
|
||||
#include <workspace.h>
|
||||
|
||||
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
|
||||
|
|
4
effects/desktopchangeslide.desktop
Normal file
4
effects/desktopchangeslide.desktop
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=DesktopChangeSlide
|
||||
X-KDE-Library=kwin4_effect_builtins
|
|
@ -11,7 +11,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#ifndef KWIN_DESKTOPCHANGESLIDE_H
|
||||
#define KWIN_DESKTOPCHANGESLIDE_H
|
||||
|
||||
#include <effects.h>
|
||||
#include <kwineffects.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
|
|
@ -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 <client.h>
|
||||
|
||||
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<Client *>(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<Client *>(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<Client *>(t);
|
||||
if( !c )
|
||||
return false;
|
||||
return c->findModal() != NULL;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
|
4
effects/dialogparent.desktop
Normal file
4
effects/dialogparent.desktop
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=DialogParent
|
||||
X-KDE-Library=kwin4_effect_builtins
|
|
@ -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 <effects.h>
|
||||
#include <kwineffects.h>
|
||||
|
||||
|
||||
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<EffectWindow*, float> effectStrength;
|
||||
|
|
|
@ -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 )
|
||||
|
|
4
effects/drunken.desktop
Normal file
4
effects/drunken.desktop
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Drunken
|
||||
X-KDE-Library=kwin4_effect_builtins
|
|
@ -11,7 +11,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#ifndef KWIN_DRUNKEN_H
|
||||
#define KWIN_DRUNKEN_H
|
||||
|
||||
#include <effects.h>
|
||||
#include <kwineffects.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
|
|
@ -10,12 +10,11 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include "fade.h"
|
||||
|
||||
#include <client.h>
|
||||
#include <deleted.h>
|
||||
|
||||
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 )
|
||||
|
|
4
effects/fade.desktop
Normal file
4
effects/fade.desktop
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Fade
|
||||
X-KDE-Library=kwin4_effect_builtins
|
|
@ -11,7 +11,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#ifndef KWIN_FADE_H
|
||||
#define KWIN_FADE_H
|
||||
|
||||
#include <effects.h>
|
||||
#include <kwineffects.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
|
|
@ -10,18 +10,18 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include "fallapart.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <deleted.h>
|
||||
#include <scene_opengl.h>
|
||||
|
||||
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 )
|
||||
|
|
4
effects/fallapart.desktop
Normal file
4
effects/fallapart.desktop
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=FallApart
|
||||
X-KDE-Library=kwin4_effect_builtins
|
|
@ -11,7 +11,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#ifndef KWIN_FALLAPART_H
|
||||
#define KWIN_FALLAPART_H
|
||||
|
||||
#include <effects.h>
|
||||
#include <kwineffects.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=TestShiftWorkspaceUp
|
||||
X-KDE-Library=kwin4_effect_tests
|
Loading…
Reference in a new issue