Basic transformations on the whole workspace.

svn path=/branches/work/kwin_composite/; revision=559204
This commit is contained in:
Luboš Luňák 2006-07-06 19:02:14 +00:00
parent e6c23e4cd3
commit 28e3726f2e
4 changed files with 80 additions and 22 deletions

View file

@ -136,7 +136,7 @@ void Effect::transformWindow( Toplevel*, Matrix&, EffectData& )
{
}
void Effect::transformWorkspace( Workspace*, Matrix&, EffectData& )
void Effect::transformWorkspace( Matrix&, EffectData& )
{
}
@ -239,19 +239,44 @@ void GrowMove::windowUserMovedResized( Toplevel* c, bool first, bool last )
}
}
ShiftWorkspaceUp::ShiftWorkspaceUp( Workspace* ws )
: up( false )
, wspace( ws )
{
connect( &timer, SIGNAL( timeout()), SLOT( tick()));
timer.start( 2000 );
}
void ShiftWorkspaceUp::transformWorkspace( Matrix& matrix, EffectData& )
{
if( !up )
return;
Matrix m;
m.m[ 1 ][ 3 ] = -10;
matrix *= m;
}
void ShiftWorkspaceUp::tick()
{
up = !up;
wspace->addDamage( 0, 0, displayWidth(), displayHeight());
}
static MakeHalfTransparent* mht;
static ShakyMove* sm;
static GrowMove* gm;
static ShiftWorkspaceUp* swu;
//****************************************
// EffectsHandler
//****************************************
EffectsHandler::EffectsHandler()
EffectsHandler::EffectsHandler( Workspace* ws )
{
mht = new MakeHalfTransparent;
sm = new ShakyMove;
// gm = new GrowMove;
swu = new ShiftWorkspaceUp( ws );
}
void EffectsHandler::windowUserMovedResized( Toplevel* c, bool first, bool last )
@ -262,6 +287,8 @@ void EffectsHandler::windowUserMovedResized( Toplevel* c, bool first, bool last
sm->windowUserMovedResized( c, first, last );
if( gm )
gm->windowUserMovedResized( c, first, last );
if( swu )
swu->windowUserMovedResized( c, first, last );
}
void EffectsHandler::transformWindow( Toplevel* c, Matrix& matrix, EffectData& data )
@ -272,16 +299,20 @@ void EffectsHandler::transformWindow( Toplevel* c, Matrix& matrix, EffectData& d
sm->transformWindow( c, matrix, data );
if( gm )
gm->transformWindow( c, matrix, data );
if( swu )
swu->transformWindow( c, matrix, data );
}
void EffectsHandler::transformWorkspace( Workspace* w, Matrix& matrix, EffectData& data )
void EffectsHandler::transformWorkspace( Matrix& matrix, EffectData& data )
{
if( mht )
mht->transformWorkspace( w, matrix, data );
mht->transformWorkspace( matrix, data );
if( sm )
sm->transformWorkspace( w, matrix, data );
sm->transformWorkspace( matrix, data );
if( gm )
gm->transformWorkspace( w, matrix, data );
gm->transformWorkspace( matrix, data );
if( swu )
swu->transformWorkspace( matrix, data );
}
void EffectsHandler::windowDeleted( Toplevel* c )
@ -292,6 +323,8 @@ void EffectsHandler::windowDeleted( Toplevel* c )
sm->windowDeleted( c );
if( gm )
gm->windowDeleted( c );
if( swu )
swu->windowDeleted( c );
}
EffectsHandler* effects;

View file

@ -73,17 +73,17 @@ class Effect
virtual void windowUserMovedResized( Toplevel* c, bool first, bool last );
virtual void windowDeleted( Toplevel* c );
virtual void transformWindow( Toplevel* c, Matrix& m, EffectData& data );
virtual void transformWorkspace( Workspace*, Matrix& m, EffectData& data );
virtual void transformWorkspace( Matrix& m, EffectData& data );
};
class EffectsHandler
{
public:
EffectsHandler();
EffectsHandler( Workspace* ws );
void windowUserMovedResized( Toplevel* c, bool first, bool last );
void windowDeleted( Toplevel* c );
void transformWindow( Toplevel* c, Matrix& m, EffectData& data );
void transformWorkspace( Workspace*, Matrix& m, EffectData& data );
void transformWorkspace( Matrix& m, EffectData& data );
};
extern EffectsHandler* effects;
@ -120,6 +120,21 @@ class GrowMove
virtual void transformWindow( Toplevel* c, Matrix& m, EffectData& data );
};
class ShiftWorkspaceUp
: public QObject, public Effect
{
Q_OBJECT
public:
ShiftWorkspaceUp( Workspace* ws );
virtual void transformWorkspace( Matrix& m, EffectData& data );
private slots:
void tick();
private:
QTimer timer;
bool up;
Workspace* wspace;
};
} // namespace
#endif

View file

@ -29,6 +29,8 @@ License. See the file "COPYING" for the exact licensing terms.
#include "atoms.h"
#include "options.h"
#include "sm.h"
#include "utils.h"
#include "effects.h"
#define INT8 _X11INT8
#define INT32 _X11INT32
@ -93,7 +95,7 @@ Application::Application( )
}
if (screen_number == -1)
screen_number = DefaultScreen(QX11Info::display());
screen_number = DefaultScreen(display());
if( !owner.claim( args->isSet( "replace" ), true ))
{
@ -111,14 +113,18 @@ Application::Application( )
XSetErrorHandler( x11ErrorHandler );
// check whether another windowmanager is running
XSelectInput(QX11Info::display(), QX11Info::appRootWindow(), SubstructureRedirectMask );
XSelectInput(display(), rootWindow(), SubstructureRedirectMask );
syncX(); // trigger error now
options = new Options;
atoms = new Atoms;
initting = false; // TODO
// create workspace.
(void) new Workspace( isSessionRestored() );
Workspace* workspace = new Workspace( isSessionRestored() );
effects = new EffectsHandler( workspace );
syncX(); // trigger possible errors, there's still a chance to abort
@ -128,27 +134,29 @@ Application::Application( )
ksplash.call( "upAndRunning", QString( "wm started" ));
XEvent e;
e.xclient.type = ClientMessage;
e.xclient.message_type = XInternAtom( QX11Info::display(), "_KDE_SPLASH_PROGRESS", False );
e.xclient.display = QX11Info::display();
e.xclient.window = QX11Info::appRootWindow();
e.xclient.message_type = XInternAtom( display(), "_KDE_SPLASH_PROGRESS", False );
e.xclient.display = display();
e.xclient.window = rootWindow();
e.xclient.format = 8;
strcpy( e.xclient.data.b, "wm started" );
XSendEvent( QX11Info::display(), QX11Info::appRootWindow(), False, SubstructureNotifyMask, &e );
XSendEvent( display(), rootWindow(), False, SubstructureNotifyMask, &e );
}
Application::~Application()
{
delete Workspace::self();
if( owner.ownerWindow() != None ) // if there was no --replace (no new WM)
XSetInputFocus( QX11Info::display(), PointerRoot, RevertToPointerRoot, QX11Info::appTime() );
XSetInputFocus( display(), PointerRoot, RevertToPointerRoot, xTime() );
delete options;
delete effects;
delete atoms;
}
void Application::lostSelection()
{
delete Workspace::self();
// remove windowmanager privileges
XSelectInput(QX11Info::display(), QX11Info::appRootWindow(), PropertyChangeMask );
XSelectInput(display(), rootWindow(), PropertyChangeMask );
quit();
}
@ -272,13 +280,13 @@ KDE_EXPORT int kdemain( int argc, char * argv[] )
KWinInternal::SessionManaged weAreIndeed;
KWinInternal::SessionSaveDoneHelper helper;
fcntl(ConnectionNumber(QX11Info::display()), F_SETFD, 1);
fcntl(XConnectionNumber(KWinInternal::display()), F_SETFD, 1);
QString appname;
if (KWinInternal::screen_number == 0)
appname = "org.kde.kwin";
appname = "kwin";
else
appname.sprintf("org.kde.kwin-screen-%d", KWinInternal::screen_number);
appname.sprintf("kwin-screen-%d", KWinInternal::screen_number);
QDBus::sessionBus().interface()->registerService( appname, QDBusConnectionInterface::DontQueueService );

View file

@ -70,6 +70,7 @@ void SceneXrender::paint( XserverRegion damage, ToplevelList windows )
continue;
}
effects->transformWindow( c, data.matrix, data.effect ); // TODO remove, instead add initWindow() to effects
effects->transformWorkspace( data.matrix, data.effect );
saveWindowClipRegion( c, damage );
if( data.simpleTransformation() && isOpaque( c ))
{ // is opaque, has simple shape, can be clipped, will be painted using simpler faster method
@ -172,6 +173,7 @@ void SceneXrender::updateTransformation( Toplevel* c )
resetWindowData( c );
WindowData& data = window_data[ c ];
effects->transformWindow( c, data.matrix, data.effect );
effects->transformWorkspace( data.matrix, data.effect );
}
void SceneXrender::resetWindowData( Toplevel* c )
@ -319,7 +321,7 @@ void SceneXrender::createBuffer()
XFreePixmap( display(), pixmap ); // The picture owns the pixmap now
}
void SceneXrender::setPictureMatrix( Picture pic, const Matrix& m )
void SceneXrender::setPictureMatrix( Picture pic, const Matrix& )
{
if( pic == None )
return;