diff --git a/effects.cpp b/effects.cpp index 3c527b495d..2f5c87d897 100644 --- a/effects.cpp +++ b/effects.cpp @@ -55,7 +55,7 @@ Matrix operator*( const Matrix& m1, const Matrix& m2 ) for( int k = 0; k < 4; ++k ) - s += m1.m[ i ][ k ] * m2.m[ k ][ j ]; + s += m1.m[ k ][ j ] * m2.m[ i ][ k ]; r.m[ i ][ j ] = s; } return r; @@ -102,6 +102,24 @@ bool Matrix::isOnlyTranslate() const && m[ 3 ][ 3 ] == 1; } +QPoint Matrix::transform( const QPoint& p ) const + { + int vec[ 4 ] = { p.x(), p.y(), 0, 1 }; + int res[ 4 ]; + for( int i = 0; + i < 4; + ++i ) + { + double s = 0; + for( int j = 0; + j < 4; + ++j ) + s += m[ i ][ j ] * vec[ j ]; + res[ i ] = int( s ); + } + return QPoint( res[ 0 ], res[ 1 ] ); + } + //**************************************** // Effect //**************************************** diff --git a/effects.h b/effects.h index 6997c5d226..92bdb91a03 100644 --- a/effects.h +++ b/effects.h @@ -13,8 +13,9 @@ License. See the file "COPYING" for the exact licensing terms. #ifndef KWIN_EFFECTS_H #define KWIN_EFFECTS_H -#include -#include +#include +#include +#include namespace KWinInternal { @@ -32,6 +33,7 @@ class Matrix double xTranslate() const; double yTranslate() const; double zTranslate() const; + QPoint transform( const QPoint& p ) const; double m[ 4 ][ 4 ]; };