2 * kate: space-indent on; tab-width 8; indent-width 4; indent-mode cstyle;
4 * This file is part of the KDE project, module kdesktop.
5 * Copyright (C) 1999 Geert Jansen <g.t.jansen@stud.tue.nl>
7 * You can Freely distribute this program under the GNU Library General
8 * Public License. See the file "COPYING.LIB" for the exact licensing terms.
11 #ifndef BGRender_h_Included
12 #define BGRender_h_Included
18 #include <Qt3Support/Q3PtrVector>
19 #include <ksharedconfig.h>
21 #include "bgsettings.h"
34 * This class renders a desktop background to a QImage. The operation is
35 * asynchronous: connect to the signal imageDone() to find out when the
36 * rendering is finished. It also has support for preview images, like
37 * the monitor in kcmdisplay.
39 class KBackgroundRenderer
:
41 public KBackgroundSettings
46 KBackgroundRenderer(int desk
, int screen
, bool drawBackgroundPerScreen
, const KSharedConfigPtr
&config
= KSharedConfigPtr(), bool kdmMode
= false);
47 ~KBackgroundRenderer();
49 void load(int desk
, int screen
, bool drawBackgroundPerScreen
, bool reparseConfig
=true);
51 void setPreview(const QSize
&size
);
52 void setSize(const QSize
&size
);
56 bool isActive() { return m_State
& Rendering
; }
59 void enableTiling( bool enable
) { m_TilingEnabled
= enable
; }
62 void start(bool enableBusyCursor
= false);
64 void desktopResized();
67 void imageDone(int desk
, int screen
);
68 void programFailure(int desk
, int exitstatus
); //Guaranteed either programFailure or
69 void programSuccess(int desk
); //programSuccess is emitted after imageDone
72 void slotBackgroundDone(K3Process
*);
77 enum { Error
, Wait
, WaitUpdate
, Done
};
78 enum { Rendering
= 1, InitCheck
= 2,
79 BackgroundStarted
= 4, BackgroundDone
= 8,
80 WallpaperStarted
= 0x10, WallpaperDone
= 0x20,
83 QString
buildCommand();
84 void createTempFile();
85 void tile(QImage
& dst
, const QRect
&rect
, const QImage
& src
);
86 void blend(QImage
& dst
, const QRect
&dr
, const QImage
& src
, const QPoint
&soffs
= QPoint(0, 0), int blendFactor
=100);
88 void wallpaperBlend();
89 void fastWallpaperBlend();
90 void fullWallpaperBlend();
92 int doBackground(bool quit
=false);
93 int doWallpaper(bool quit
=false);
94 void setBusyCursor(bool isBusy
);
95 QString
cacheFileName();
96 bool useCacheFile() const;
100 bool m_enableBusyCursor
;
104 bool m_TilingEnabled
;
106 KTemporaryFile
* m_Tempfile
;
107 QSize m_Size
, m_rSize
;
108 QRect m_WallpaperRect
;
109 QImage m_Image
, m_Background
, m_Wallpaper
;
113 KStandardDirs
*m_pDirs
;
114 K3ShellProcess
*m_pProc
;
118 * In xinerama mode, each screen is rendered separately by KBackgroundRenderer.
119 * This class controls a set of renderers for a desktop, and coallates the
120 * images. Usage is similar to KBackgroundRenderer: connect to the imageDone
123 class KVirtualBGRenderer
: public QObject
127 explicit KVirtualBGRenderer(int desk
, const KSharedConfigPtr
&config
= KSharedConfigPtr(), bool kdmMode
= false);
128 ~KVirtualBGRenderer();
130 KBackgroundRenderer
* renderer(unsigned screen
);
131 unsigned numRenderers() const { return m_numRenderers
; }
135 void setPreview(const QSize
& size
);
137 bool needProgramUpdate();
138 void programUpdate();
140 bool needWallpaperChange();
141 void changeWallpaper();
145 void setEnabled( bool enable
);
146 void desktopResized();
148 void load(int desk
, bool reparseConfig
=true);
152 void saveCacheFile();
153 void enableTiling( bool enable
);
156 void imageDone(int desk
);
159 void screenDone(int desk
, int screen
);
162 QSize
renderSize(int screen
); // the size the renderer should be
163 void initRenderers();
165 KSharedConfigPtr m_pConfig
;
169 unsigned m_numRenderers
;
170 bool m_bDrawBackgroundPerScreen
;
171 bool m_bCommonScreen
;
175 QVector
<bool> m_bFinished
;
176 Q3PtrVector
<KBackgroundRenderer
> m_renderer
;
181 #endif // BGRender_h_Included