From 28e3726f2ed184c3f1f39ecd702cae452214a6d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 6 Jul 2006 19:02:14 +0000 Subject: [PATCH] Basic transformations on the whole workspace. svn path=/branches/work/kwin_composite/; revision=559204 --- effects.cpp | 45 +++++++++++++++++++++++++++++++++++++++------ effects.h | 21 ++++++++++++++++++--- main.cpp | 32 ++++++++++++++++++++------------ scene_xrender.cpp | 4 +++- 4 files changed, 80 insertions(+), 22 deletions(-) diff --git a/effects.cpp b/effects.cpp index a4a6b1f13e..5cfa4b5bdb 100644 --- a/effects.cpp +++ b/effects.cpp @@ -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; diff --git a/effects.h b/effects.h index b0e1e9bce2..1951b37617 100644 --- a/effects.h +++ b/effects.h @@ -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 diff --git a/main.cpp b/main.cpp index a3a1c00727..9fff11ceb4 100644 --- a/main.cpp +++ b/main.cpp @@ -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 ); diff --git a/scene_xrender.cpp b/scene_xrender.cpp index bd5b13ea61..d9c85068d6 100644 --- a/scene_xrender.cpp +++ b/scene_xrender.cpp @@ -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;