• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KWinLibraries

kwineffects.h

Go to the documentation of this file.
00001 /********************************************************************
00002  KWin - the KDE window manager
00003  This file is part of the KDE project.
00004 
00005 Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
00006 
00007 This program is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 This program is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 *********************************************************************/
00020 
00021 #ifndef KWINEFFECTS_H
00022 #define KWINEFFECTS_H
00023 
00024 #include <kwinconfig.h>
00025 #include <kwinglobals.h>
00026 
00027 #include <QtCore/QPair>
00028 #include <QtCore/QRect>
00029 #include <QtGui/QRegion>
00030 #include <QtGui/QFont>
00031 
00032 #include <QtCore/QVector>
00033 #include <QtCore/QList>
00034 #include <QtCore/QHash>
00035 #include <QtCore/QStack>
00036 #include <QtCore/QTimeLine>
00037 
00038 #include <KDE/KPluginFactory>
00039 #include <KDE/KShortcutsEditor>
00040 
00041 #include <assert.h>
00042 #include <limits.h>
00043 
00044 class KLibrary;
00045 class KConfigGroup;
00046 class KActionCollection;
00047 class QKeyEvent;
00048 
00049 namespace KWin
00050 {
00051 
00052 
00053 class EffectWindow;
00054 class EffectWindowGroup;
00055 class Effect;
00056 class WindowQuad;
00057 class GLRenderTarget;
00058 class GLShader;
00059 class WindowQuadList;
00060 class WindowPrePaintData;
00061 class WindowPaintData;
00062 class ScreenPrePaintData;
00063 class ScreenPaintData;
00064 
00065 typedef QPair< QString, Effect* > EffectPair;
00066 typedef QPair< Effect*, Window > InputWindowPair;
00067 typedef QList< EffectWindow* > EffectWindowList;
00068 
00069 
00163 #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor ))
00164 #define KWIN_EFFECT_API_VERSION_MAJOR 0
00165 #define KWIN_EFFECT_API_VERSION_MINOR 21
00166 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \
00167     KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR )
00168 
00172 KWIN_EXPORT inline
00173 QRect infiniteRegion()
00174     { // INT_MIN / 2 because width/height is used (INT_MIN+INT_MAX==-1)
00175     return QRect( INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX );
00176     }
00177 
00226 class KWIN_EXPORT Effect
00227     {
00228     public:
00230         // TODO: is that ok here?
00231         enum
00232         {
00236             PAINT_WINDOW_OPAQUE         = 1 << 0,
00240             PAINT_WINDOW_TRANSLUCENT    = 1 << 1,
00244             PAINT_WINDOW_TRANSFORMED    = 1 << 2,
00249             PAINT_SCREEN_REGION         = 1 << 3,
00254             PAINT_SCREEN_TRANSFORMED    = 1 << 4,
00259             PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS = 1 << 5,
00263             PAINT_SCREEN_BACKGROUND_FIRST = 1 << 6
00264         };
00265 
00269         Effect();
00273         virtual ~Effect();
00274 
00283         virtual void prePaintScreen( ScreenPrePaintData& data, int time );
00291         virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
00298         virtual void postPaintScreen();
00299 
00308         virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
00316         virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
00323         virtual void postPaintWindow( EffectWindow* w );
00324 
00330         virtual void drawWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
00337         virtual QRect transformWindowDamage( EffectWindow* w, const QRect& r );
00338 
00340         virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last );
00341         virtual void windowOpacityChanged( EffectWindow* c, double old_opacity );
00342         virtual void windowAdded( EffectWindow* c );
00343         virtual void windowClosed( EffectWindow* c );
00344         virtual void windowDeleted( EffectWindow* c );
00345         virtual void windowActivated( EffectWindow* c );
00346         virtual void windowMinimized( EffectWindow* c );
00347         virtual void windowUnminimized( EffectWindow* c );
00348         virtual void windowInputMouseEvent( Window w, QEvent* e );
00349         virtual void desktopChanged( int old );
00350         virtual void windowDamaged( EffectWindow* w, const QRect& r );
00351         virtual void windowGeometryShapeChanged( EffectWindow* w, const QRect& old );
00352         virtual void mouseChanged( const QPoint& pos, const QPoint& oldpos,
00353             Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
00354             Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers );
00355         virtual void grabbedKeyboardEvent( QKeyEvent* e );
00363         virtual void propertyNotify( EffectWindow* w, long atom );
00364 
00365         virtual void tabBoxAdded( int mode );
00366         virtual void tabBoxClosed();
00367         virtual void tabBoxUpdated();
00368         virtual bool borderActivated( ElectricBorder border );
00369 
00370         static int displayWidth();
00371         static int displayHeight();
00372         static QPoint cursorPos();
00373 
00379         static double interpolate(double x, double y, double a)
00380             {
00381             return x * (1 - a) + y * a;
00382             }
00386         static void setPositionTransformations( WindowPaintData& data, QRect& region, EffectWindow* w,
00387             const QRect& r, Qt::AspectRatioMode aspect );
00388     };
00389 
00390 
00400 #define KWIN_EFFECT( name, classname ) \
00401     extern "C" { \
00402         KWIN_EXPORT Effect* effect_create_kwin4_effect_##name() { return new classname; } \
00403         KWIN_EXPORT int effect_version_kwin4_effect_##name() { return KWIN_EFFECT_API_VERSION; } \
00404     }
00405 
00409 #define KWIN_EFFECT_SUPPORTED( name, function ) \
00410     extern "C" { \
00411         KWIN_EXPORT bool effect_supported_kwin4_effect_##name() { return function; } \
00412     }
00413 
00417 #define KWIN_EFFECT_CONFIG( name, classname ) \
00418     K_PLUGIN_FACTORY(name##_factory, registerPlugin<classname>();) \
00419     K_EXPORT_PLUGIN(name##_factory("kcm_kwineffect_" #name))
00420 
00424 #define KWIN_EFFECT_CONFIG_FACTORY K_PLUGIN_FACTORY_DECLARATION(EffectFactory)
00425 
00426 
00437 class KWIN_EXPORT EffectsHandler
00438     {
00439     friend class Effect;
00440     public:
00441         EffectsHandler(CompositingType type);
00442         virtual ~EffectsHandler();
00443         // for use by effects
00444         virtual void prePaintScreen( ScreenPrePaintData& data, int time ) = 0;
00445         virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ) = 0;
00446         virtual void postPaintScreen() = 0;
00447         virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) = 0;
00448         virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) = 0;
00449         virtual void postPaintWindow( EffectWindow* w ) = 0;
00450         virtual void drawWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) = 0;
00451         virtual QRect transformWindowDamage( EffectWindow* w, const QRect& r );
00452         // Functions for handling input - e.g. when an Expose-like effect is shown, an input window
00453         // covering the whole screen is created and all mouse events will be intercepted by it.
00454         // The effect's windowInputMouseEvent() will get called with such events.
00455         virtual Window createInputWindow( Effect* e, int x, int y, int w, int h, const QCursor& cursor ) = 0;
00456         Window createInputWindow( Effect* e, const QRect& r, const QCursor& cursor );
00457         virtual Window createFullScreenInputWindow( Effect* e, const QCursor& cursor );
00458         virtual void destroyInputWindow( Window w ) = 0;
00459         virtual QPoint cursorPos() const = 0;
00460         virtual bool grabKeyboard( Effect* effect ) = 0;
00461         virtual void ungrabKeyboard() = 0;
00462 
00463         virtual void checkElectricBorder(const QPoint &pos, Time time) = 0;
00464         virtual void reserveElectricBorder( ElectricBorder border ) = 0;
00465         virtual void unreserveElectricBorder( ElectricBorder border ) = 0;
00466         virtual void reserveElectricBorderSwitching( bool reserve ) = 0;
00467 
00468         // functions that allow controlling windows/desktop
00469         virtual void activateWindow( EffectWindow* c ) = 0;
00470         virtual EffectWindow* activeWindow() const = 0 ;
00471         virtual void moveWindow( EffectWindow* w, const QPoint& pos ) = 0;
00472         virtual void windowToDesktop( EffectWindow* w, int desktop ) = 0;
00473         // 
00474         virtual int currentDesktop() const = 0;
00475         virtual int numberOfDesktops() const = 0;
00476         virtual void setCurrentDesktop( int desktop ) = 0;
00477         virtual QString desktopName( int desktop ) const = 0;
00478         virtual int activeScreen() const = 0; // Xinerama
00479         virtual int numScreens() const = 0; // Xinerama
00480         virtual int screenNumber( const QPoint& pos ) const = 0; // Xinerama
00481         virtual QRect clientArea( clientAreaOption, int screen, int desktop ) const = 0;
00482         virtual QRect clientArea( clientAreaOption, const EffectWindow* c ) const = 0;
00483         virtual QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const = 0;
00484         virtual void calcDesktopLayout(int* x, int* y, Qt::Orientation* orientation) const = 0;
00485         virtual bool optionRollOverDesktops() const = 0;
00486         virtual int desktopToLeft( int desktop, bool wrap ) const = 0;
00487         virtual int desktopToRight( int desktop, bool wrap ) const = 0;
00488         virtual int desktopUp( int desktop, bool wrap ) const = 0;
00489         virtual int desktopDown( int desktop, bool wrap ) const = 0;
00490 
00491         virtual EffectWindow* findWindow( WId id ) const = 0;
00492         virtual EffectWindowList stackingOrder() const = 0;
00493         // window will be temporarily painted as if being at the top of the stack
00494         virtual void setElevatedWindow( EffectWindow* w, bool set ) = 0;
00495 
00496         virtual void setTabBoxWindow(EffectWindow*) = 0;
00497         virtual void setTabBoxDesktop(int) = 0;
00498         virtual EffectWindowList currentTabBoxWindowList() const = 0;
00499         virtual void refTabBox() = 0;
00500         virtual void unrefTabBox() = 0;
00501         virtual void closeTabBox() = 0;
00502         virtual QList< int > currentTabBoxDesktopList() const = 0;
00503         virtual int currentTabBoxDesktop() const = 0;
00504         virtual EffectWindow* currentTabBoxWindow() const = 0;
00505 
00506         virtual void setActiveFullScreenEffect( Effect* e ) = 0;
00507         virtual Effect* activeFullScreenEffect() const = 0;
00508 
00509         virtual void pushRenderTarget(GLRenderTarget* target) = 0;
00510         virtual GLRenderTarget* popRenderTarget() = 0;
00511 
00517         virtual void addRepaintFull() = 0;
00518         virtual void addRepaint( const QRect& r ) = 0;
00519         virtual void addRepaint( const QRegion& r ) = 0;
00520         virtual void addRepaint( int x, int y, int w, int h ) = 0;
00521 
00522         CompositingType compositingType() const;
00523         virtual unsigned long xrenderBufferPicture() = 0;
00524         bool saturationSupported() const;
00525         virtual void reconfigure() = 0;
00526 
00533         virtual void registerPropertyType( long atom, bool reg ) = 0;
00534 
00543         bool paintText( const QString& text, const QPoint& center, int maxwidth,
00544                         const QColor& color, const QFont& font = QFont() );
00545         bool paintTextWithBackground( const QString& text, const QPoint& center, int maxwidth,
00546                                       const QColor& color, const QColor& bgcolor,
00547                                       const QFont& font = QFont() );
00548 
00549 
00555         static void sendReloadMessage( const QString& effectname );
00559         static KConfigGroup effectConfig( const QString& effectname );
00560 
00561 
00562     protected:
00563         QVector< EffectPair > loaded_effects;
00564         QHash< QString, KLibrary* > effect_libraries;
00565         QList< InputWindowPair > input_windows;
00566         //QHash< QString, EffectFactory* > effect_factories;
00567         int current_paint_screen;
00568         int current_paint_window;
00569         int current_draw_window;
00570         int current_transform;
00571         CompositingType compositing_type;
00572     };
00573 
00574 
00581 class KWIN_EXPORT EffectWindow
00582     {
00583     public:
00585         enum
00586         {
00588             PAINT_DISABLED              = 1 << 0,
00590             PAINT_DISABLED_BY_DELETE    = 1 << 1,
00592             PAINT_DISABLED_BY_DESKTOP   = 1 << 2,
00594             PAINT_DISABLED_BY_MINIMIZE  = 1 << 3
00595         };
00596 
00597         EffectWindow();
00598         virtual ~EffectWindow();
00599 
00600         virtual void enablePainting( int reason ) = 0;
00601         virtual void disablePainting( int reason ) = 0;
00602         virtual bool isPaintingEnabled() = 0;
00603         virtual void addRepaint( const QRect& r ) = 0;
00604         virtual void addRepaint( int x, int y, int w, int h ) = 0;
00605         virtual void addRepaintFull() = 0;
00606 
00607         virtual void refWindow() = 0;
00608         virtual void unrefWindow() = 0;
00609         virtual bool isDeleted() const = 0;
00610 
00611         virtual bool isMinimized() const = 0;
00612         virtual double opacity() const = 0;
00613 
00614         virtual bool isOnDesktop( int d ) const;
00615         virtual bool isOnCurrentDesktop() const;
00616         virtual bool isOnAllDesktops() const = 0;
00617         virtual int desktop() const = 0; // prefer isOnXXX()
00618 
00619         virtual int x() const = 0;
00620         virtual int y() const = 0;
00621         virtual int width() const = 0;
00622         virtual int height() const = 0;
00623         virtual QRect geometry() const = 0;
00624         virtual QRegion shape() const = 0;
00625         virtual int screen() const = 0;
00627         virtual bool hasOwnShape() const = 0; // only for shadow effect, for now
00628         virtual QPoint pos() const = 0;
00629         virtual QSize size() const = 0;
00630         virtual QRect rect() const = 0;
00631         virtual bool isMovable() const = 0;
00632         virtual bool isUserMove() const = 0;
00633         virtual bool isUserResize() const = 0;
00634         virtual QRect iconGeometry() const = 0;
00638         virtual QRect contentsRect() const = 0;
00639         bool hasDecoration() const;
00640         virtual QByteArray readProperty( long atom, long type, int format ) const = 0;
00641 
00642         virtual QString caption() const = 0;
00643         virtual QPixmap icon() const = 0;
00644         virtual QString windowClass() const = 0;
00645         virtual QString windowRole() const = 0;
00646         virtual const EffectWindowGroup* group() const = 0;
00647 
00652         virtual bool isDesktop() const = 0;
00657         virtual bool isDock() const = 0;
00662         virtual bool isToolbar() const = 0;
00667         virtual bool isTopMenu() const = 0;
00672         virtual bool isMenu() const = 0;
00678         virtual bool isNormalWindow() const = 0; // normal as in 'NET::Normal or NET::Unknown non-transient'
00684         virtual bool isSpecialWindow() const = 0;
00689         virtual bool isDialog() const = 0;
00695         virtual bool isSplash() const = 0;
00700         virtual bool isUtility() const = 0;
00706         virtual bool isDropdownMenu() const = 0;
00711         virtual bool isPopupMenu() const = 0; // a context popup, not dropdown, not torn-off
00716         virtual bool isTooltip() const = 0;
00721         virtual bool isNotification() const = 0;
00726         virtual bool isComboBox() const = 0;
00731         virtual bool isDNDIcon() const = 0;
00736         virtual bool isManaged() const = 0; // whether it's managed or override-redirect
00737 
00738         virtual bool isModal() const = 0;
00739         virtual EffectWindow* findModal() = 0;
00740         virtual EffectWindowList mainWindows() const = 0;
00741 
00742         // TODO internal?
00743         virtual WindowQuadList buildQuads() const = 0;
00744     };
00745 
00746 class KWIN_EXPORT EffectWindowGroup
00747     {
00748     public:
00749         virtual ~EffectWindowGroup();
00750         virtual EffectWindowList members() const = 0;
00751     };
00752 
00753 class KWIN_EXPORT GlobalShortcutsEditor : public KShortcutsEditor
00754     {
00755     public:
00756         GlobalShortcutsEditor( QWidget *parent );
00757     };
00758 
00765 class KWIN_EXPORT WindowVertex
00766     {
00767     public:
00768         double x() const;
00769         double y() const;
00770         void move( double x, double y );
00771         void setX( double x );
00772         void setY( double y );
00773         double originalX() const;
00774         double originalY() const;
00775         WindowVertex();
00776         WindowVertex( double x, double y, double tx, double ty );
00777     private:
00778         friend class WindowQuad;
00779         friend class WindowQuadList;
00780         double px, py; // position
00781         double ox, oy; // origional position
00782         double tx, ty; // texture coords
00783     };
00784 
00785 enum WindowQuadType
00786     {
00787     WindowQuadError, // for the stupid default ctor
00788     WindowQuadContents,
00789     WindowQuadDecoration
00790     };
00791 
00797 // NOTE: This class expects the (original) vertices to be in the clockwise order starting from topleft.
00798 class KWIN_EXPORT WindowQuad
00799     {
00800     public:
00801         explicit WindowQuad( WindowQuadType type );
00802         WindowQuad makeSubQuad( double x1, double y1, double x2, double y2 ) const;
00803         WindowVertex& operator[]( int index );
00804         const WindowVertex& operator[]( int index ) const;
00805         bool decoration() const;
00806         double left() const;
00807         double right() const;
00808         double top() const;
00809         double bottom() const;
00810         double originalLeft() const;
00811         double originalRight() const;
00812         double originalTop() const;
00813         double originalBottom() const;
00814         bool smoothNeeded() const;
00815         bool isTransformed() const;
00816     private:
00817         friend class WindowQuadList;
00818         WindowVertex verts[ 4 ];
00819         WindowQuadType type; // 0 - contents, 1 - decoration
00820     };
00821 
00822 class KWIN_EXPORT WindowQuadList
00823     : public QList< WindowQuad >
00824     {
00825     public:
00826         WindowQuadList splitAtX( double x ) const;
00827         WindowQuadList splitAtY( double y ) const;
00828         WindowQuadList makeGrid( int maxquadsize ) const;
00829         WindowQuadList makeRegularGrid( int xSubdivisions, int ySubdivisions ) const;
00830         WindowQuadList select( WindowQuadType type ) const;
00831         WindowQuadList filterOut( WindowQuadType type ) const;
00832         bool smoothNeeded() const;
00833         void makeArrays( float** vertices, float** texcoords ) const;
00834     };
00835 
00836 class KWIN_EXPORT WindowPrePaintData
00837     {
00838     public:
00839         int mask;
00843         QRegion paint;
00848         QRegion clip;
00849         WindowQuadList quads;
00854         void setTranslucent();
00858         void setTransformed();
00859     };
00860 
00861 class KWIN_EXPORT WindowPaintData
00862     {
00863     public:
00864         WindowPaintData( EffectWindow* w );
00870         double opacity;
00871         double contents_opacity;
00872         double decoration_opacity;
00873         double xScale;
00874         double yScale;
00875         int xTranslate;
00876         int yTranslate;
00885         double saturation;
00891         double brightness;
00892         WindowQuadList quads;
00896         GLShader* shader;
00897     };
00898 
00899 class KWIN_EXPORT ScreenPaintData
00900     {
00901     public:
00902         ScreenPaintData();
00903         double xScale;
00904         double yScale;
00905         int xTranslate;
00906         int yTranslate;
00907     };
00908 
00909 class KWIN_EXPORT ScreenPrePaintData
00910     {
00911     public:
00912         int mask;
00913         QRegion paint;
00914     };
00915 
00925 class KWIN_EXPORT PaintClipper
00926     {
00927     public:
00931         PaintClipper( const QRegion& allowed_area );
00935         ~PaintClipper();
00940         static void push( const QRegion& allowed_area );
00944         static void pop( const QRegion& allowed_area );
00948         static bool clip();
00953         static QRegion paintArea();
00964         class KWIN_EXPORT Iterator
00965             {
00966             public:
00967                 Iterator();
00968                 ~Iterator();
00969                 bool isDone();
00970                 void next();
00971                 QRect boundingRect() const;
00972             private:
00973                 struct Data;
00974                 Data* data;
00975             };
00976     private:
00977         QRegion area;
00978         static QStack< QRegion >* areas;
00979     };
00980 
00981 
01024 class KWIN_EXPORT TimeLine
01025     {
01026 
01027     Q_ENUMS( CurveShape )
01028 
01029     public:
01035         enum CurveShape
01036         {
01037             EaseInCurve = 0,
01038             EaseOutCurve,
01039             EaseInOutCurve,
01040             LinearCurve,
01041             SineCurve
01042         };
01043 
01050         explicit TimeLine(const int duration = 250);
01051 
01056         TimeLine(const TimeLine &other);
01060         ~TimeLine();
01064         int duration() const;
01068         void setDuration(const int msec);
01076         double value() const;
01082         double valueForTime(const int msec) const;
01087         int time() const;
01092         double progress() const;
01096         void addProgress(const double progress);
01101         void addTime(const int msec);
01107         void removeTime(const int msec);
01114         void setProgress(const double progress);
01120         void setCurveShape(CurveShape curveShape);
01125         //void setCurveShape(CurveShape curveShape);
01126 
01127     private:
01128         QTimeLine* m_TimeLine;
01129         int m_Time;
01130         double m_Progress;
01131         int m_Duration;
01132         CurveShape m_CurveShape;
01133         //Q_DISABLE_COPY(TimeLine)
01134     };
01135 
01139 extern KWIN_EXPORT EffectsHandler* effects;
01140 
01141 /***************************************************************
01142  WindowVertex
01143 ***************************************************************/
01144 
01145 inline
01146 WindowVertex::WindowVertex()
01147     : px( 0 ), py( 0 ), tx( 0 ), ty( 0 )
01148     {
01149     }
01150 
01151 inline
01152 WindowVertex::WindowVertex( double _x, double _y, double _tx, double _ty )
01153     : px( _x ), py( _y ), ox( _x ), oy( _y ), tx( _tx ), ty( _ty )
01154     {
01155     }
01156 
01157 inline
01158 double WindowVertex::x() const
01159     {
01160     return px;
01161     }
01162 
01163 inline
01164 double WindowVertex::y() const
01165     {
01166     return py;
01167     }
01168 
01169 inline
01170 double WindowVertex::originalX() const
01171     {
01172     return ox;
01173     }
01174 
01175 inline
01176 double WindowVertex::originalY() const
01177     {
01178     return oy;
01179     }
01180 
01181 inline
01182 void WindowVertex::move( double x, double y )
01183     {
01184     px = x;
01185     py = y;
01186     }
01187 
01188 inline
01189 void WindowVertex::setX( double x )
01190     {
01191     px = x;
01192     }
01193 
01194 inline
01195 void WindowVertex::setY( double y )
01196     {
01197     py = y;
01198     }
01199 
01200 /***************************************************************
01201  WindowQuad
01202 ***************************************************************/
01203 
01204 inline
01205 WindowQuad::WindowQuad( WindowQuadType t )
01206     : type( t )
01207     {
01208     }
01209 
01210 inline
01211 WindowVertex& WindowQuad::operator[]( int index )
01212     {
01213     assert( index >= 0 && index < 4 );
01214     return verts[ index ];
01215     }
01216 
01217 inline
01218 const WindowVertex& WindowQuad::operator[]( int index ) const
01219     {
01220     assert( index >= 0 && index < 4 );
01221     return verts[ index ];
01222     }
01223 
01224 inline
01225 bool WindowQuad::decoration() const
01226     {
01227     assert( type != WindowQuadError );
01228     return type == WindowQuadDecoration;
01229     }
01230 
01231 inline
01232 bool WindowQuad::isTransformed() const
01233     {
01234     return !( verts[ 0 ].px == verts[ 0 ].ox && verts[ 0 ].py == verts[ 0 ].oy
01235         && verts[ 1 ].px == verts[ 1 ].ox && verts[ 1 ].py == verts[ 1 ].oy
01236         && verts[ 2 ].px == verts[ 2 ].ox && verts[ 2 ].py == verts[ 2 ].oy
01237         && verts[ 3 ].px == verts[ 3 ].ox && verts[ 3 ].py == verts[ 3 ].oy );
01238     }
01239 
01240 inline
01241 double WindowQuad::left() const
01242     {
01243     return qMin( verts[ 0 ].px, qMin( verts[ 1 ].px, qMin( verts[ 2 ].px, verts[ 3 ].px )));
01244     }
01245 
01246 inline
01247 double WindowQuad::right() const
01248     {
01249     return qMax( verts[ 0 ].px, qMax( verts[ 1 ].px, qMax( verts[ 2 ].px, verts[ 3 ].px )));
01250     }
01251 
01252 inline
01253 double WindowQuad::top() const
01254     {
01255     return qMin( verts[ 0 ].py, qMin( verts[ 1 ].py, qMin( verts[ 2 ].py, verts[ 3 ].py )));
01256     }
01257 
01258 inline
01259 double WindowQuad::bottom() const
01260     {
01261     return qMax( verts[ 0 ].py, qMax( verts[ 1 ].py, qMax( verts[ 2 ].py, verts[ 3 ].py )));
01262     }
01263 
01264 inline
01265 double WindowQuad::originalLeft() const
01266     {
01267     return verts[ 0 ].ox;
01268     }
01269 
01270 inline
01271 double WindowQuad::originalRight() const
01272     {
01273     return verts[ 2 ].ox;
01274     }
01275 
01276 inline
01277 double WindowQuad::originalTop() const
01278     {
01279     return verts[ 0 ].oy;
01280     }
01281 
01282 inline
01283 double WindowQuad::originalBottom() const
01284     {
01285     return verts[ 2 ].oy;
01286     }
01287 
01288 } // namespace
01289 
01292 #endif // KWINEFFECTS_H

KWinLibraries

Skip menu "KWinLibraries"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal