not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kwin / effects.h
blob8eaeb4fb7c6137515c9c797db26450243d9be7b2
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
21 #ifndef KWIN_EFFECTSIMPL_H
22 #define KWIN_EFFECTSIMPL_H
24 #include "kwineffects.h"
26 #include "scene.h"
28 #include <QStack>
29 #include <QMap>
32 class KService;
35 namespace KWin
38 class EffectsHandlerImpl : public EffectsHandler
40 public:
41 EffectsHandlerImpl(CompositingType type);
42 virtual ~EffectsHandlerImpl();
43 virtual void prePaintScreen( ScreenPrePaintData& data, int time );
44 virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
45 virtual void postPaintScreen();
46 virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
47 virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
48 virtual void postPaintWindow( EffectWindow* w );
50 virtual void drawWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
52 virtual void buildQuads( EffectWindow* w, WindowQuadList& quadList );
54 virtual void activateWindow( EffectWindow* c );
55 virtual EffectWindow* activeWindow() const;
56 virtual void moveWindow( EffectWindow* w, const QPoint& pos );
57 virtual void windowToDesktop( EffectWindow* w, int desktop );
59 virtual int currentDesktop() const;
60 virtual int numberOfDesktops() const;
61 virtual void setCurrentDesktop( int desktop );
62 virtual QString desktopName( int desktop ) const;
63 virtual int displayWidth() const;
64 virtual int displayHeight() const;
65 virtual QPoint cursorPos() const;
66 virtual bool grabKeyboard( Effect* effect );
67 virtual void ungrabKeyboard();
68 virtual EffectWindow* findWindow( WId id ) const;
69 virtual EffectWindowList stackingOrder() const;
70 virtual void setElevatedWindow( EffectWindow* w, bool set );
72 virtual void setTabBoxWindow(EffectWindow*);
73 virtual void setTabBoxDesktop(int);
74 virtual EffectWindowList currentTabBoxWindowList() const;
75 virtual void refTabBox();
76 virtual void unrefTabBox();
77 virtual void closeTabBox();
78 virtual QList< int > currentTabBoxDesktopList() const;
79 virtual int currentTabBoxDesktop() const;
80 virtual EffectWindow* currentTabBoxWindow() const;
82 virtual void setActiveFullScreenEffect( Effect* e );
83 virtual Effect* activeFullScreenEffect() const;
85 virtual void pushRenderTarget(GLRenderTarget* target);
86 virtual GLRenderTarget* popRenderTarget();
88 virtual void addRepaintFull();
89 virtual void addRepaint( const QRect& r );
90 virtual void addRepaint( const QRegion& r );
91 virtual void addRepaint( int x, int y, int w, int h );
92 virtual int activeScreen() const;
93 virtual int numScreens() const;
94 virtual int screenNumber( const QPoint& pos ) const;
95 virtual QRect clientArea( clientAreaOption, int screen, int desktop ) const;
96 virtual QRect clientArea( clientAreaOption, const EffectWindow* c ) const;
97 virtual QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const;
98 virtual void calcDesktopLayout(int* x, int* y, Qt::Orientation* orientation) const;
99 virtual bool optionRollOverDesktops() const;
100 virtual int desktopToLeft( int desktop, bool wrap ) const;
101 virtual int desktopToRight( int desktop, bool wrap ) const;
102 virtual int desktopUp( int desktop, bool wrap ) const;
103 virtual int desktopDown( int desktop, bool wrap ) const;
104 virtual double animationTimeFactor() const;
105 virtual WindowQuadType newWindowQuadType();
107 virtual Window createInputWindow( Effect* e, int x, int y, int w, int h, const QCursor& cursor );
108 using EffectsHandler::createInputWindow;
109 virtual void destroyInputWindow( Window w );
110 virtual bool checkInputWindowEvent( XEvent* e );
111 virtual void checkInputWindowStacking();
113 virtual void checkElectricBorder(const QPoint &pos, Time time);
114 virtual void reserveElectricBorder( ElectricBorder border );
115 virtual void unreserveElectricBorder( ElectricBorder border );
116 virtual void reserveElectricBorderSwitching( bool reserve );
118 virtual unsigned long xrenderBufferPicture();
119 virtual void reconfigure();
120 virtual void registerPropertyType( long atom, bool reg );
122 virtual bool hasDecorationShadows() const;
123 virtual QList< QList<QImage> > shadowTextures();
124 virtual int shadowTextureList( ShadowType type ) const;
126 // internal (used by kwin core or compositing code)
127 void startPaint();
128 void windowUserMovedResized( EffectWindow* c, bool first, bool last );
129 void windowOpacityChanged( EffectWindow* c, double old_opacity );
130 void windowAdded( EffectWindow* c );
131 void windowClosed( EffectWindow* c );
132 void windowDeleted( EffectWindow* c );
133 void windowActivated( EffectWindow* c );
134 void windowMinimized( EffectWindow* c );
135 void windowUnminimized( EffectWindow* c );
136 void desktopChanged( int old );
137 void windowDamaged( EffectWindow* w, const QRect& r );
138 void windowGeometryShapeChanged( EffectWindow* w, const QRect& old );
139 void tabBoxAdded( int mode );
140 void tabBoxClosed();
141 void tabBoxUpdated();
142 bool borderActivated( ElectricBorder border );
143 void mouseChanged( const QPoint& pos, const QPoint& oldpos,
144 Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
145 Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers );
146 void grabbedKeyboardEvent( QKeyEvent* e );
147 bool hasKeyboardGrab() const;
148 void propertyNotify( EffectWindow* c, long atom );
150 bool loadEffect( const QString& name );
151 void toggleEffect( const QString& name );
152 void unloadEffect( const QString& name );
153 void reconfigureEffect( const QString& name );
154 bool isEffectLoaded( const QString& name );
155 QStringList loadedEffects() const;
156 QStringList listOfEffects() const;
158 QList<EffectWindow*> elevatedWindows() const;
160 protected:
161 KLibrary* findEffectLibrary( KService* service );
162 void effectsChanged();
164 Effect* keyboard_grab_effect;
165 QStack<GLRenderTarget*> render_targets;
166 Effect* fullscreen_effect;
167 QList<EffectWindow*> elevated_windows;
168 QMultiMap< int, EffectPair > effect_order;
169 QHash< long, int > registered_atoms;
170 int next_window_quad_type;
173 class EffectWindowImpl : public EffectWindow
175 public:
176 EffectWindowImpl();
177 virtual ~EffectWindowImpl();
179 virtual void enablePainting( int reason );
180 virtual void disablePainting( int reason );
181 virtual bool isPaintingEnabled();
182 virtual void addRepaint( const QRect& r );
183 virtual void addRepaint( int x, int y, int w, int h );
184 virtual void addRepaintFull();
186 virtual void refWindow();
187 virtual void unrefWindow();
188 virtual bool isDeleted() const;
190 virtual bool isOnAllDesktops() const;
191 virtual int desktop() const; // prefer isOnXXX()
192 virtual bool isMinimized() const;
193 virtual double opacity() const;
194 virtual QString caption() const;
195 virtual QPixmap icon() const;
196 virtual QString windowClass() const;
197 virtual QString windowRole() const;
198 virtual const EffectWindowGroup* group() const;
200 virtual int x() const;
201 virtual int y() const;
202 virtual int width() const;
203 virtual int height() const;
204 virtual QRect geometry() const;
205 virtual QRegion shape() const;
206 virtual int screen() const;
207 virtual bool hasOwnShape() const;
208 virtual QPoint pos() const;
209 virtual QSize size() const;
210 virtual QRect rect() const;
211 virtual bool isMovable() const;
212 virtual bool isMovableAcrossScreens() const;
213 virtual bool isUserMove() const;
214 virtual bool isUserResize() const;
215 virtual QRect iconGeometry() const;
216 virtual QRect contentsRect() const;
217 virtual QByteArray readProperty( long atom, long type, int format ) const;
219 virtual bool isDesktop() const;
220 virtual bool isDock() const;
221 virtual bool isToolbar() const;
222 virtual bool isTopMenu() const;
223 virtual bool isMenu() const;
224 virtual bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient'
225 virtual bool isSpecialWindow() const;
226 virtual bool isDialog() const;
227 virtual bool isSplash() const;
228 virtual bool isUtility() const;
229 virtual bool isDropdownMenu() const;
230 virtual bool isPopupMenu() const; // a context popup, not dropdown, not torn-off
231 virtual bool isTooltip() const;
232 virtual bool isNotification() const;
233 virtual bool isComboBox() const;
234 virtual bool isDNDIcon() const;
235 virtual bool isManaged() const; // managed or override-redirect
237 virtual bool isModal() const;
238 virtual EffectWindow* findModal();
239 virtual EffectWindowList mainWindows() const;
241 virtual QList<QRect> shadowQuads( ShadowType type ) const;
242 virtual double shadowOpacity( ShadowType type ) const;
243 virtual double shadowBrightness( ShadowType type ) const;
244 virtual double shadowSaturation( ShadowType type ) const;
246 virtual WindowQuadList buildQuads( bool force = false ) const;
248 const Toplevel* window() const;
249 Toplevel* window();
251 void setWindow( Toplevel* w ); // internal
252 void setSceneWindow( Scene::Window* w ); // internal
253 const Scene::Window* sceneWindow() const; // internal
254 Scene::Window* sceneWindow(); // internal
255 private:
256 Toplevel* toplevel;
257 Scene::Window* sw; // This one is used only during paint pass.
260 class EffectWindowGroupImpl
261 : public EffectWindowGroup
263 public:
264 EffectWindowGroupImpl( Group* g );
265 virtual EffectWindowList members() const;
266 private:
267 Group* group;
271 inline
272 QList<EffectWindow*> EffectsHandlerImpl::elevatedWindows() const
274 return elevated_windows;
278 inline
279 EffectWindowGroupImpl::EffectWindowGroupImpl( Group* g )
280 : group( g )
284 EffectWindow* effectWindow( Toplevel* w );
285 EffectWindow* effectWindow( Scene::Window* w );
287 inline
288 const Scene::Window* EffectWindowImpl::sceneWindow() const
290 return sw;
293 inline
294 Scene::Window* EffectWindowImpl::sceneWindow()
296 return sw;
299 inline
300 const Toplevel* EffectWindowImpl::window() const
302 return toplevel;
305 inline
306 Toplevel* EffectWindowImpl::window()
308 return toplevel;
312 } // namespace
314 #endif