KWin
scene.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00038 class Scene
00039 {
00040 public:
00041 Scene( Workspace* ws );
00042 virtual ~Scene() = 0;
00043 class Window;
00044
00045
00046 virtual bool initFailed() const = 0;
00047 virtual CompositingType compositingType() const = 0;
00048
00049
00050 virtual void paint( QRegion damage, ToplevelList windows ) = 0;
00051
00052
00053
00054
00055
00056 virtual void windowGeometryShapeChanged( Toplevel* ) = 0;
00057
00058 virtual void windowOpacityChanged( Toplevel* ) = 0;
00059
00060 virtual void windowAdded( Toplevel* ) = 0;
00061
00062 virtual void windowClosed( Toplevel*, Deleted* ) = 0;
00063
00064 virtual void windowDeleted( Deleted* ) = 0;
00065
00066 enum
00067 {
00068
00069 PAINT_WINDOW_OPAQUE = 1 << 0,
00070
00071 PAINT_WINDOW_TRANSLUCENT = 1 << 1,
00072
00073 PAINT_WINDOW_TRANSFORMED = 1 << 2,
00074
00075
00076 PAINT_SCREEN_REGION = 1 << 3,
00077
00078 PAINT_SCREEN_TRANSFORMED = 1 << 4,
00079
00080 PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS = 1 << 5,
00081
00082 PAINT_SCREEN_BACKGROUND_FIRST = 1 << 6
00083 };
00084
00085 enum ImageFilterType { ImageFilterFast, ImageFilterGood };
00086
00087 void idle();
00088 bool waitSyncAvailable() { return has_waitSync; }
00089 protected:
00090
00091 void paintScreen( int* mask, QRegion* region );
00092 friend class EffectsHandlerImpl;
00093
00094 void finalPaintScreen( int mask, QRegion region, ScreenPaintData& data );
00095
00096
00097 virtual void paintGenericScreen( int mask, ScreenPaintData data );
00098
00099 virtual void paintSimpleScreen( int mask, QRegion region );
00100
00101 virtual void paintBackground( QRegion region ) = 0;
00102
00103 void finalPaintWindow( EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data );
00104
00105 virtual void paintWindow( Window* w, int mask, QRegion region, WindowQuadList quads );
00106
00107 void finalDrawWindow( EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data );
00108
00109 void updateTimeDiff();
00110 QList< QPoint > selfCheckPoints() const;
00111
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
00124 QVector< Window* > stacking_order;
00125
00126
00127
00128
00129
00130 QRegion painted_region;
00131
00132 int time_diff;
00133 QTime last_time;
00134 Workspace* wspace;
00135 bool has_waitSync;
00136 };
00137
00138
00139 class Scene::Window
00140 {
00141 public:
00142 Window( Toplevel* c );
00143 virtual ~Window();
00144
00145 virtual void performPaint( int mask, QRegion region, WindowPaintData data ) = 0;
00146
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
00157
00158 Toplevel* window();
00159
00160 bool isPaintingEnabled() const;
00161 void resetPaintingEnabled();
00162
00163 enum
00164 {
00165
00166 PAINT_DISABLED = 1 << 0,
00167
00168 PAINT_DISABLED_BY_DELETE = 1 << 1,
00169
00170 PAINT_DISABLED_BY_DESKTOP = 1 << 2,
00171
00172 PAINT_DISABLED_BY_MINIMIZE = 1 << 3
00173 };
00174 void enablePainting( int reason );
00175 void disablePainting( int reason );
00176
00177 bool isVisible() const;
00178
00179 bool isOpaque() const;
00180
00181 QRegion shape() const;
00182 void discardShape();
00183 void updateToplevel( Toplevel* c );
00184
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 }
00268
00269 #endif