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

KWin

scene.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 KWIN_SCENE_H
00022 #define KWIN_SCENE_H
00023 
00024 #include <QDateTime>
00025 
00026 #include "toplevel.h"
00027 #include "utils.h"
00028 #include "kwineffects.h"
00029 
00030 namespace KWin
00031 {
00032 
00033 class Workspace;
00034 class Deleted;
00035 class EffectWindowImpl;
00036 
00037 // The base class for compositing backends.
00038 class Scene
00039     {
00040     public:
00041         Scene( Workspace* ws );
00042         virtual ~Scene() = 0;
00043         class Window;
00044 
00045         // Returns true if the ctor failed to properly initialize.
00046         virtual bool initFailed() const = 0;
00047         virtual CompositingType compositingType() const = 0;
00048         // Repaints the given screen areas, windows provides the stacking order.
00049         // The entry point for the main part of the painting pass.
00050         virtual void paint( QRegion damage, ToplevelList windows ) = 0;
00051         
00052         // Notification function - KWin core informs about changes.
00053         // Used to mainly discard cached data.
00054         
00055         // shape/size of a window changed
00056         virtual void windowGeometryShapeChanged( Toplevel* ) = 0;
00057         // opacity of a window changed
00058         virtual void windowOpacityChanged( Toplevel* ) = 0;
00059         // a new window has been created
00060         virtual void windowAdded( Toplevel* ) = 0;
00061         // a window has been closed
00062         virtual void windowClosed( Toplevel*, Deleted* ) = 0;
00063         // a window has been destroyed
00064         virtual void windowDeleted( Deleted* ) = 0;
00065         // Flags controlling how painting is done.
00066         enum
00067             {
00068             // Window (or at least part of it) will be painted opaque.
00069             PAINT_WINDOW_OPAQUE         = 1 << 0,
00070             // Window (or at least part of it) will be painted translucent.
00071             PAINT_WINDOW_TRANSLUCENT    = 1 << 1,
00072             // Window will be painted with transformed geometry.
00073             PAINT_WINDOW_TRANSFORMED    = 1 << 2,
00074             // Paint only a region of the screen (can be optimized, cannot
00075             // be used together with TRANSFORMED flags).
00076             PAINT_SCREEN_REGION         = 1 << 3,
00077             // Whole screen will be painted with transformed geometry.
00078             PAINT_SCREEN_TRANSFORMED    = 1 << 4,
00079             // At least one window will be painted with transformed geometry.
00080             PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS = 1 << 5,
00081             // Clear whole background as the very first step, without optimizing it
00082             PAINT_SCREEN_BACKGROUND_FIRST = 1 << 6
00083             };
00084         // types of filtering available
00085         enum ImageFilterType { ImageFilterFast, ImageFilterGood };
00086         // there's nothing to paint (adjust time_diff later)
00087         void idle();
00088         bool waitSyncAvailable() { return has_waitSync; }
00089     protected:
00090         // shared implementation, starts painting the screen
00091         void paintScreen( int* mask, QRegion* region );
00092         friend class EffectsHandlerImpl;
00093         // called after all effects had their paintScreen() called
00094         void finalPaintScreen( int mask, QRegion region, ScreenPaintData& data );
00095         // shared implementation of painting the screen in the generic
00096         // (unoptimized) way
00097         virtual void paintGenericScreen( int mask, ScreenPaintData data );
00098         // shared implementation of painting the screen in an optimized way
00099         virtual void paintSimpleScreen( int mask, QRegion region );
00100         // paint the background (not the desktop background - the whole background)
00101         virtual void paintBackground( QRegion region ) = 0;
00102         // called after all effects had their paintWindow() called
00103         void finalPaintWindow( EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data );
00104         // shared implementation, starts painting the window
00105         virtual void paintWindow( Window* w, int mask, QRegion region, WindowQuadList quads );
00106         // called after all effects had their drawWindow() called
00107         void finalDrawWindow( EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data );
00108         // compute time since the last repaint
00109         void updateTimeDiff();
00110         QList< QPoint > selfCheckPoints() const;
00111         // saved data for 2nd pass of optimized screen painting
00112         struct Phase2Data
00113             {
00114             Phase2Data( Window* w, QRegion r, QRegion c, int m, const WindowQuadList& q )
00115                 : window( w ), region( r ), clip( c ), mask( m ), quads( q ) {}
00116             Phase2Data()  { window = 0; mask = 0; }
00117             Window* window;
00118             QRegion region;
00119             QRegion clip;
00120             int mask;
00121             WindowQuadList quads;
00122             };
00123         // windows in their stacking order
00124         QVector< Window* > stacking_order;
00125         // The region which actually has been painted by paintScreen() and should be
00126         // copied from the buffer to the screen. I.e. the region returned from Scene::paintScreen().
00127         // Since prePaintWindow() can extend areas to paint, these changes would have to propagate
00128         // up all the way from paintSimpleScreen() up to paintScreen(), so save them here rather
00129         // than propagate them up in arguments.
00130         QRegion painted_region;
00131         // time since last repaint
00132         int time_diff;
00133         QTime last_time;
00134         Workspace* wspace;
00135         bool has_waitSync;
00136     };
00137 
00138 // The base class for windows representations in composite backends
00139 class Scene::Window
00140     {
00141     public:
00142         Window( Toplevel* c );
00143         virtual ~Window();
00144         // perform the actual painting of the window
00145         virtual void performPaint( int mask, QRegion region, WindowPaintData data ) = 0;
00146         // do any cleanup needed when the window's composite pixmap is discarded
00147         virtual void pixmapDiscarded()  {}
00148         int x() const;
00149         int y() const;
00150         int width() const;
00151         int height() const;
00152         QRect geometry() const;
00153         QPoint pos() const;
00154         QSize size() const;
00155         QRect rect() const;
00156         // access to the internal window class
00157         // TODO eventually get rid of this
00158         Toplevel* window();
00159         // should the window be painted
00160         bool isPaintingEnabled() const;
00161         void resetPaintingEnabled();
00162         // Flags explaining why painting should be disabled
00163         enum
00164             {
00165             // Window will not be painted
00166             PAINT_DISABLED              = 1 << 0,
00167             // Window will not be painted because it is deleted
00168             PAINT_DISABLED_BY_DELETE    = 1 << 1,
00169             // Window will not be painted because of which desktop it's on
00170             PAINT_DISABLED_BY_DESKTOP   = 1 << 2,
00171             // Window will not be painted because it is minimized
00172             PAINT_DISABLED_BY_MINIMIZE  = 1 << 3
00173             };
00174         void enablePainting( int reason );
00175         void disablePainting( int reason );
00176         // is the window visible at all
00177         bool isVisible() const;
00178         // is the window fully opaque
00179         bool isOpaque() const;
00180         // shape of the window
00181         QRegion shape() const;
00182         void discardShape();
00183         void updateToplevel( Toplevel* c );
00184         // creates initial quad list for the window
00185         virtual WindowQuadList buildQuads( bool force = false ) const;
00186         void suspendUnredirect( bool suspend );
00187     protected:
00188         WindowQuadList makeQuads( WindowQuadType type, const QRegion& reg ) const;
00189         Toplevel* toplevel;
00190         ImageFilterType filter;
00191     private:
00192         int disable_painting;
00193         mutable QRegion shape_region;
00194         mutable bool shape_valid;
00195         mutable WindowQuadList* cached_quad_list;
00196         Q_DISABLE_COPY(Window)
00197     };
00198 
00199 extern Scene* scene;
00200 
00201 inline
00202 int Scene::Window::x() const
00203     {
00204     return toplevel->x();
00205     }
00206     
00207 inline
00208 int Scene::Window::y() const
00209     {
00210     return toplevel->y();
00211     }
00212 
00213 inline
00214 int Scene::Window::width() const
00215     {
00216     return toplevel->width();
00217     }
00218     
00219 inline
00220 int Scene::Window::height() const
00221     {
00222     return toplevel->height();
00223     }
00224 
00225 inline
00226 QRect Scene::Window::geometry() const
00227     {
00228     return toplevel->geometry();
00229     }
00230 
00231 inline
00232 QSize Scene::Window::size() const
00233     {
00234     return toplevel->size();
00235     }
00236     
00237 inline
00238 QPoint Scene::Window::pos() const
00239     {
00240     return toplevel->pos();
00241     }
00242     
00243 inline
00244 QRect Scene::Window::rect() const
00245     {
00246     return toplevel->rect();
00247     }
00248 
00249 inline
00250 Toplevel* Scene::Window::window()
00251     {
00252     return toplevel;
00253     }
00254 
00255 inline
00256 void Scene::Window::updateToplevel( Toplevel* c )
00257     {
00258     toplevel = c;
00259     }
00260 
00261 inline
00262 void Scene::Window::suspendUnredirect( bool suspend )
00263     {
00264     toplevel->suspendUnredirect( suspend );
00265     }
00266 
00267 } // namespace
00268 
00269 #endif

KWin

Skip menu "KWin"
  • Main Page
  • 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
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
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