• Skip to content
  • Skip to link menu
KDE 4.1 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         // saved data for 2nd pass of optimized screen painting
00111         struct Phase2Data
00112             {
00113             Phase2Data( Window* w, QRegion r, QRegion c, int m, const WindowQuadList& q )
00114                 : window( w ), region( r ), clip( c ), mask( m ), quads( q ) {}
00115             Phase2Data()  { window = 0; mask = 0; }
00116             Window* window;
00117             QRegion region;
00118             QRegion clip;
00119             int mask;
00120             WindowQuadList quads;
00121             };
00122         // windows in their stacking order
00123         QVector< Window* > stacking_order;
00124         // The region which actually has been painted by paintScreen() and should be
00125         // copied from the buffer to the screen. I.e. the region returned from Scene::paintScreen().
00126         // Since prePaintWindow() can extend areas to paint, these changes would have to propagate
00127         // up all the way from paintSimpleScreen() up to paintScreen(), so save them here rather
00128         // than propagate them up in arguments.
00129         QRegion painted_region;
00130         // time since last repaint
00131         int time_diff;
00132         QTime last_time;
00133         Workspace* wspace;
00134         bool has_waitSync;
00135     };
00136 
00137 // The base class for windows representations in composite backends
00138 class Scene::Window
00139     {
00140     public:
00141         Window( Toplevel* c );
00142         virtual ~Window();
00143         // perform the actual painting of the window
00144         virtual void performPaint( int mask, QRegion region, WindowPaintData data ) = 0;
00145         // do any cleanup needed when the window's composite pixmap is discarded
00146         virtual void pixmapDiscarded()  {}
00147         int x() const;
00148         int y() const;
00149         int width() const;
00150         int height() const;
00151         QRect geometry() const;
00152         QPoint pos() const;
00153         QSize size() const;
00154         QRect rect() const;
00155         // access to the internal window class
00156         // TODO eventually get rid of this
00157         Toplevel* window();
00158         // should the window be painted
00159         bool isPaintingEnabled() const;
00160         void resetPaintingEnabled();
00161         // Flags explaining why painting should be disabled
00162         enum
00163             {
00164             // Window will not be painted
00165             PAINT_DISABLED              = 1 << 0,
00166             // Window will not be painted because it is deleted
00167             PAINT_DISABLED_BY_DELETE    = 1 << 1,
00168             // Window will not be painted because of which desktop it's on
00169             PAINT_DISABLED_BY_DESKTOP   = 1 << 2,
00170             // Window will not be painted because it is minimized
00171             PAINT_DISABLED_BY_MINIMIZE  = 1 << 3
00172             };
00173         void enablePainting( int reason );
00174         void disablePainting( int reason );
00175         // is the window visible at all
00176         bool isVisible() const;
00177         // is the window fully opaque
00178         bool isOpaque() const;
00179         // shape of the window
00180         QRegion shape() const;
00181         void discardShape();
00182         void updateToplevel( Toplevel* c );
00183         // creates initial quad list for the window
00184         virtual WindowQuadList buildQuads() const;
00185     protected:
00186         WindowQuadList makeQuads( WindowQuadType type, const QRegion& reg ) const;
00187         Toplevel* toplevel;
00188         ImageFilterType filter;
00189     private:
00190         int disable_painting;
00191         mutable QRegion shape_region;
00192         mutable bool shape_valid;
00193         mutable WindowQuadList* cached_quad_list;
00194         Q_DISABLE_COPY(Window)
00195     };
00196 
00197 extern Scene* scene;
00198 
00199 inline
00200 int Scene::Window::x() const
00201     {
00202     return toplevel->x();
00203     }
00204     
00205 inline
00206 int Scene::Window::y() const
00207     {
00208     return toplevel->y();
00209     }
00210 
00211 inline
00212 int Scene::Window::width() const
00213     {
00214     return toplevel->width();
00215     }
00216     
00217 inline
00218 int Scene::Window::height() const
00219     {
00220     return toplevel->height();
00221     }
00222 
00223 inline
00224 QRect Scene::Window::geometry() const
00225     {
00226     return toplevel->geometry();
00227     }
00228 
00229 inline
00230 QSize Scene::Window::size() const
00231     {
00232     return toplevel->size();
00233     }
00234     
00235 inline
00236 QPoint Scene::Window::pos() const
00237     {
00238     return toplevel->pos();
00239     }
00240     
00241 inline
00242 QRect Scene::Window::rect() const
00243     {
00244     return toplevel->rect();
00245     }
00246 
00247 inline
00248 Toplevel* Scene::Window::window()
00249     {
00250     return toplevel;
00251     }
00252 
00253 inline
00254 void Scene::Window::updateToplevel( Toplevel* c )
00255     {
00256     toplevel = c;
00257     }
00258 
00259 } // namespace
00260 
00261 #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
  •   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